Compare commits

..

1 Commits

Author SHA1 Message Date
jonathan 6375383373 🐛Made attack selection only select alive enemies 2025-12-11 18:49:51 +01:00
21 changed files with 65 additions and 148 deletions
+2 -4
View File
@@ -9,7 +9,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="_builds/Babushka_showcase_6a/Babushka.exe"
export_path="_builds/Babushka_win_0_5/Babushka.exe"
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
@@ -26,7 +26,6 @@ debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=false
shader_baker/enabled=false
binary_format/architecture="x86_64"
codesign/enable=false
codesign/timestamp=true
@@ -80,7 +79,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="_builds/Babushka_showcase_lux_06a/Babushka.x86_64"
export_path="_builds/Babushka_linux_0_5/Babushka.x86_64"
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
@@ -97,7 +96,6 @@ debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=false
shader_baker/enabled=false
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
+3 -3
View File
@@ -2123,6 +2123,9 @@ frame = 7
frame_progress = 0.229832
offset = Vector2(0, -450)
[node name="DetectionCross" parent="CharacterBody2D" instance=ExtResource("466_e04c3")]
position = Vector2(0, -200)
[node name="PlantCreatedEventListener" type="Node" parent="CharacterBody2D"]
script = ExtResource("467_8hbu5")
_eventResources = Array[Object]([ExtResource("468_t1d6r")])
@@ -2172,9 +2175,6 @@ scrollable = false
script = ExtResource("472_kduih")
_wateringCanFillStateNode = NodePath("../WateringCanFillState")
[node name="DetectionCross" parent="CharacterBody2D" instance=ExtResource("466_e04c3")]
position = Vector2(0, -260)
[node name="FarmingControls" type="Node2D" parent="." node_paths=PackedStringArray("_movingPlayer")]
script = ExtResource("817_6nrw3")
_sceneKeyProvider = ExtResource("471_83c4i")
+3 -1
View File
@@ -1,7 +1,8 @@
[gd_scene load_steps=24 format=3 uid="uid://muuxxgvx33fp"]
[gd_scene load_steps=25 format=3 uid="uid://muuxxgvx33fp"]
[ext_resource type="Script" uid="uid://7m1rt7agb6rm" path="res://scripts/CSharp/Common/Temp/MVPDuck.cs" id="1_54k4r"]
[ext_resource type="Texture2D" uid="uid://hvchk6t0xe7j" path="res://art/animals/Ente.png" id="1_cgxhx"]
[ext_resource type="Resource" uid="uid://tt3d166mntmi" path="res://resources/low code/farming/var_sceneNameProvider.tres" id="2_fdf3t"]
[ext_resource type="AudioStream" uid="uid://qv0aubjeyi0u" path="res://audio/sfx/Animals/SFX_Duck_Quack_01.wav" id="3_kjie1"]
[ext_resource type="Script" uid="uid://cfnrd5k1k0gxw" path="res://scripts/CSharp/Common/AudioPlayer2D.cs" id="3_rdn2q"]
[ext_resource type="AudioStream" uid="uid://da84l8e44scwh" path="res://audio/sfx/Animals/SFX_Duck_Quack_02.wav" id="4_54k4r"]
@@ -142,6 +143,7 @@ viewport_path = NodePath("SubViewport")
z_index = 1
y_sort_enabled = true
script = ExtResource("1_54k4r")
_sceneKeyProvider = ExtResource("2_fdf3t")
_transferDelayMs = 1000
_animationPlayer = NodePath("AnimationPlayer")
-1
View File
@@ -74,7 +74,6 @@ texture = ExtResource("5_wx561")
y_sort_enabled = true
[node name="InteractionArea" parent="FieldBehaviour" node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("7_2eegd")]
process_mode = 4
position = Vector2(-28.88889, -57)
scale = Vector2(1.1111112, 1)
_active = false
+6 -15
View File
@@ -1,21 +1,12 @@
[gd_scene load_steps=4 format=3 uid="uid://pflu0uaig7vv"]
[gd_scene load_steps=3 format=3 uid="uid://pflu0uaig7vv"]
[ext_resource type="Script" uid="uid://ccc6m6c5khd2x" path="res://scripts/CSharp/Common/CharacterControls/DetectionCross.cs" id="1_va8tx"]
[ext_resource type="PackedScene" uid="uid://dugr6ff1g7hi0" path="res://prefabs/interactions/detector.tscn" id="2_8hh05"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_va8tx"]
[node name="DetectionCross" type="Node2D" node_paths=PackedStringArray("_collider", "_shapeCast2D")]
[node name="DetectionCross" type="Node2D" node_paths=PackedStringArray("_detector")]
script = ExtResource("1_va8tx")
_collider = NodePath("detector")
_shapeCast2D = NodePath("ShapeCast2D")
_xOffset = 200.0
_yOffset = 200.0
_detector = NodePath("detector")
_xOffset = 400.0
_yOffset = 300.0
[node name="detector" parent="." node_paths=PackedStringArray("_shapeCast2D") instance=ExtResource("2_8hh05")]
_shapeCast2D = NodePath("../ShapeCast2D")
[node name="ShapeCast2D" type="ShapeCast2D" parent="."]
shape = SubResource("RectangleShape2D_va8tx")
target_position = Vector2(200, 0)
collide_with_areas = true
[node name="detector" parent="." instance=ExtResource("2_8hh05")]
+4 -6
View File
@@ -1,16 +1,14 @@
[gd_scene load_steps=4 format=3 uid="uid://dugr6ff1g7hi0"]
[gd_scene load_steps=3 format=3 uid="uid://dugr6ff1g7hi0"]
[ext_resource type="Script" uid="uid://c3pd60biootsx" path="res://scripts/CSharp/Common/CharacterControls/Detector.cs" id="1_6pib0"]
[ext_resource type="Resource" uid="uid://clwqh3w5aqi5e" path="res://resources/low code/interactables/var_interactableToTrigger.tres" id="2_3fanv"]
[sub_resource type="CircleShape2D" id="CircleShape2D_6pib0"]
radius = 300.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qwv4c"]
size = Vector2(100, 400)
[node name="detector" type="Area2D"]
collision_layer = 4
script = ExtResource("1_6pib0")
_itemToTriggerResource = ExtResource("2_3fanv")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_6pib0")
shape = SubResource("RectangleShape2D_qwv4c")
debug_color = Color(0.9459047, 7.2196126e-06, 0.5925879, 0.41960785)
+4 -10
View File
@@ -1,10 +1,8 @@
[gd_scene load_steps=8 format=3 uid="uid://cqc72e4hq6bcd"]
[gd_scene load_steps=6 format=3 uid="uid://cqc72e4hq6bcd"]
[ext_resource type="Script" uid="uid://ckp413wrub5fm" path="res://scripts/CSharp/Common/CharacterControls/InteractionArea2D.cs" id="1_5ajrf"]
[ext_resource type="Resource" uid="uid://clwqh3w5aqi5e" path="res://resources/low code/interactables/var_interactableToTrigger.tres" id="2_o1drf"]
[ext_resource type="Material" uid="uid://blch5kdhkbj75" path="res://art/materials/simple_interactable_outline.tres" id="2_qoey7"]
[ext_resource type="Script" uid="uid://cp2q4k62sjo6h" path="res://scripts/CSharp/Common/CharacterControls/DetectableInteractionArea.cs" id="3_2wrrq"]
[ext_resource type="Script" uid="uid://pqemey80frcq" path="res://scripts/CSharp/Low Code/Variables/VariableListener.cs" id="4_gj2nu"]
[sub_resource type="CircleShape2D" id="CircleShape2D_npluf"]
resource_local_to_scene = true
@@ -19,10 +17,9 @@ _area = NodePath("Area2D")
_label = NodePath("Area2D/CanvasLayer/MarginContainer/Label")
_outlineMaterial = ExtResource("2_qoey7")
[node name="Area2D" type="Area2D" parent="." node_paths=PackedStringArray("interactionArea2D")]
[node name="Area2D" type="Area2D" parent="."]
collision_mask = 4
script = ExtResource("3_2wrrq")
interactionArea2D = NodePath("..")
[node name="CollisionShape3D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_npluf")
@@ -54,8 +51,5 @@ text = "[E]"
horizontal_alignment = 2
vertical_alignment = 2
[node name="SelectionListener" type="Node" parent="."]
script = ExtResource("4_gj2nu")
_variableResources = Array[Object]([ExtResource("2_o1drf")])
[connection signal="NewEventPayload" from="SelectionListener" to="Area2D" method="InteractionAreaSelectionChanged"]
[connection signal="area_entered" from="Area2D" to="." method="OnPlayerEntered"]
[connection signal="area_exited" from="Area2D" to="." method="OnPlayerExited"]
-1
View File
@@ -176,7 +176,6 @@ directories/tres_directory={
"unselected_stylebox": "res://addons/dialogic/Editor/Events/styles/unselected_stylebox.tres",
"var_ColorTestValue": "res://resources/low code/test/var_ColorTestValue.tres",
"var_Counter": "res://resources/low code/test/var_Counter.tres",
"var_interactableToTrigger": "res://resources/low code/interactables/var_interactableToTrigger.tres",
"var_sceneNameProvider": "res://resources/low code/farming/var_sceneNameProvider.tres",
"var_wateredFieldPosition": "res://resources/low code/farming/var_wateredFieldPosition.tres",
"vesna_style": "res://addons/dialogic/vesna_style.tres",
@@ -1,8 +0,0 @@
[gd_resource type="Resource" script_class="VariableResource" load_steps=2 format=3 uid="uid://clwqh3w5aqi5e"]
[ext_resource type="Script" uid="uid://dtvx2cakx0bey" path="res://scripts/CSharp/Low Code/Variables/VariableResource.cs" id="1_casar"]
[resource]
script = ExtResource("1_casar")
Payload = null
metadata/_custom_type_script = "uid://dtvx2cakx0bey"
+9 -6
View File
@@ -985,8 +985,7 @@ collision_mask = 4
position = Vector2(145.5, -224)
shape = SubResource("RectangleShape2D_0sfl7")
[node name="InteractionArea" parent="YSorted/Well" node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("27_klb81")]
_spritesToOutline = [NodePath("..")]
[node name="InteractionArea" parent="YSorted/Well" instance=ExtResource("27_klb81")]
_id = 1
metadata/SaveID = "b8f7b7fe-e057-4974-ba12-9134722998de"
@@ -2314,8 +2313,9 @@ position = Vector2(3183, 2369)
offset = Vector2(1, -50)
region_rect = Rect2(207, 1184, 149, 142)
[node name="InteractionArea" parent="YSorted/trash/trashObject2" index="0"]
[node name="InteractionArea" parent="YSorted/trash/trashObject2" index="0" node_paths=PackedStringArray("_spritesToOutline")]
position = Vector2(-9, -46)
_spritesToOutline = []
metadata/SaveID = "549bbcf4-ea57-4b8f-80b1-b13ca648559b"
[node name="trashObject3" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
@@ -2325,8 +2325,9 @@ position = Vector2(4724, 3519)
offset = Vector2(1, -50)
region_rect = Rect2(400, 1053, 163, 141)
[node name="InteractionArea" parent="YSorted/trash/trashObject3" index="0"]
[node name="InteractionArea" parent="YSorted/trash/trashObject3" index="0" node_paths=PackedStringArray("_spritesToOutline")]
position = Vector2(-13, -53)
_spritesToOutline = []
metadata/SaveID = "29874314-50c1-4a21-9494-18f936d6e097"
[node name="trashObject4" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
@@ -2336,8 +2337,9 @@ position = Vector2(5385, 3391)
offset = Vector2(1, -50)
region_rect = Rect2(1048, 1092, 348, 106)
[node name="InteractionArea" parent="YSorted/trash/trashObject4" index="0"]
[node name="InteractionArea" parent="YSorted/trash/trashObject4" index="0" node_paths=PackedStringArray("_spritesToOutline")]
position = Vector2(0, -59)
_spritesToOutline = []
metadata/SaveID = "7ccaa831-5526-40ed-8ca3-31ba2ad929a6"
[node name="trashObject5" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
@@ -2374,8 +2376,9 @@ rotation = 1.77025
offset = Vector2(0, 0)
region_rect = Rect2(1048, 1092, 348, 106)
[node name="InteractionArea" parent="YSorted/trash/trashObject9" index="0"]
[node name="InteractionArea" parent="YSorted/trash/trashObject9" index="0" node_paths=PackedStringArray("_spritesToOutline")]
position = Vector2(22.40873, 25.05658)
_spritesToOutline = []
metadata/SaveID = "7bf227d6-3844-41e9-a9cd-524052aced3b"
[node name="CanvasLayer" parent="." instance=ExtResource("32_2nee2")]
@@ -553,7 +553,7 @@ region_rect = Rect2(2748, 432, 174, 191)
[node name="Vesna" parent="." instance=ExtResource("15_7a68a")]
y_sort_enabled = false
position = Vector2(-4473, 319)
position = Vector2(-920, 319)
[node name="Yeli" parent="." instance=ExtResource("16_dhsxs")]
z_index = 0
+2 -2
View File
@@ -53,7 +53,7 @@ z_index = -100
[node name="Ceiling" type="Sprite2D" parent="Background"]
z_index = -100
position = Vector2(-2453, -1303)
position = Vector2(-2453, -1419)
scale = Vector2(2, 2)
texture = ExtResource("2_qsw8g")
region_enabled = true
@@ -61,7 +61,7 @@ region_rect = Rect2(0, 1749.6222, 3840, 358.11316)
[node name="WallUpper" type="Sprite2D" parent="Background"]
z_index = -100
position = Vector2(-2469, -975)
position = Vector2(-2469, -969)
scale = Vector2(26, 2)
texture = ExtResource("2_qsw8g")
region_enabled = true
@@ -7,18 +7,4 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
/// </summary>
public partial class DetectableInteractionArea : Area2D
{
[Export] public InteractionArea2D interactionArea2D;
public void InteractionAreaSelectionChanged(Variant instanceID)
{
if (instanceID.AsString() == GetInstanceId().ToString())
{
interactionArea2D.HighlightInteractable();
}
else
{
interactionArea2D.ResetHighlight();
}
}
}
@@ -7,8 +7,7 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
/// </summary>
public partial class DetectionCross : Node2D
{
[Export] private Detector _collider;
[Export] private ShapeCast2D _shapeCast2D;
[Export] private Detector _detector;
[Export] private float _xOffset;
[Export] private float _yOffset;
@@ -18,8 +17,6 @@ public partial class DetectionCross : Node2D
/// <param name="direction"></param>
public void SetDirection(Vector2 direction)
{
Vector2 newPos = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
_collider.Position = newPos;
_shapeCast2D.TargetPosition = newPos;
_detector.Position = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
}
}
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using Babushka.scripts.CSharp.Common.Services;
using Babushka.scripts.CSharp.Low_Code.Variables;
using Godot;
namespace Babushka.scripts.CSharp.Common.CharacterControls;
@@ -10,11 +8,18 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
/// </summary>
public partial class Detector : Area2D
{
[Export] private bool _active = true;
[Export] private ShapeCast2D _shapeCast2D;
[Export] private VariableResource _itemToTriggerResource;
private List<ulong> _areasInDetector = new();
[Export] private bool _active = true;
/// <summary>
/// Called when entering an interactionArea node.
/// </summary>
[Signal] public delegate void InteractableEnteredEventHandler();
/// <summary>
/// Called when exiting an interactionArea node.
/// </summary>
[Signal] public delegate void InteractableExitedEventHandler();
public bool IsActive
{
@@ -36,64 +41,29 @@ public partial class Detector : Area2D
/// Called every time this node enters an Area2D.
/// </summary>
/// <param name="area"></param>
public void OnEnteredInteractable(Area2D area)
public void OnEnteredInteractable(Node area)
{
if (!_active || !InputService.Instance.InputEnabled)
return;
PopulateList();
CalculateClosestInteractable();
if (area is DetectableInteractionArea interactionArea2D)
{
EmitSignal(SignalName.InteractableEntered);
}
}
/// <summary>
/// Called whenever this node exits an Area2D.
/// </summary>
/// <param name="area"></param>
public void OnExitedInteractable(Area2D area)
public void OnExitedInteractable(Node area)
{
if (!_active || !InputService.Instance.InputEnabled)
return;
PopulateList();
CalculateClosestInteractable();
}
private void PopulateList()
{
// repopulate the list of areas in the detector to account for enabled / disabled areas
var currentOverlap = GetOverlappingAreas();
_areasInDetector = new List<ulong>();
foreach (var area2D in currentOverlap)
if (area is DetectableInteractionArea interactionArea2D)
{
if (area2D is DetectableInteractionArea detectable)
{
ulong id = detectable.GetInstanceId();
_areasInDetector.Add(id);
}
EmitSignal(SignalName.InteractableExited);
}
}
private void CalculateClosestInteractable()
{
GD.Print($"Areas in detector: {_areasInDetector.Count}");
float smallestDistance = float.MaxValue;
string closestInteractable = null;
foreach (var area in _areasInDetector)
{
Area2D? area2D = InstanceFromId(area) as Area2D;
if(area2D == null)
continue;
float distance = area2D.GlobalPosition.DistanceSquaredTo(ToGlobal(_shapeCast2D.TargetPosition));
if (distance < smallestDistance)
{
closestInteractable = area.ToString();
smallestDistance = distance;
}
}
GD.Print($"Closest interactable: {closestInteractable}");
_itemToTriggerResource.Payload = closestInteractable;
}
}
@@ -25,16 +25,9 @@ public partial class InteractionArea2D : Node2D
public bool IsActive
{
get => _active;
set
{
ProcessMode = value ? ProcessModeEnum.Inherit : ProcessModeEnum.Disabled;
Visible = value;
_active = value;
}
set => _active = value;
}
public bool IsSelectedByDetector { get; set; } = false;
public void SetActiveInverse(bool active)
{
IsActive = !active;
@@ -48,10 +41,8 @@ public partial class InteractionArea2D : Node2D
}
}
public void HighlightInteractable()
public void OnPlayerEntered(Node2D player)
{
IsSelectedByDetector = true;
if (!_active || !InputService.Instance.InputEnabled)
return;
@@ -63,14 +54,12 @@ public partial class InteractionArea2D : Node2D
foreach (var sprite in _spritesToOutline)
{
GD.Print($"Highlighting outline material on {sprite.Name} Nr. {GetInstanceId()}");
sprite.Material = _outlineMaterial;
}
}
public void ResetHighlight()
public void OnPlayerExited(Node2D player)
{
IsSelectedByDetector = false;
_label.Hide();
if (!_useOutline)
@@ -79,7 +68,6 @@ public partial class InteractionArea2D : Node2D
for (var i = 0; i < _spritesToOutline.Length; i++)
{
var sprite = _spritesToOutline[i];
GD.Print($"Resetting outline material on {sprite.Name} Nr. {GetInstanceId()}");
sprite.Material = _backupMaterials[i];
}
}
@@ -89,9 +77,6 @@ public partial class InteractionArea2D : Node2D
if (!_active || !InputService.Instance.InputEnabled)
return;
if(!IsSelectedByDetector)
return;
if (@event.IsAction("interact") && @event.IsPressed())
{
TryInteract();
@@ -139,5 +124,4 @@ public partial class InteractionArea2D : Node2D
_label.Hide();
}
}
@@ -32,7 +32,6 @@ public partial class FieldActivator : Node
_field.UpdateFieldState(FieldState.Tilled);
EmitSignal(SignalName.FieldCreated, _field);
_used = true;
ToggleInteractionArea();
}
}
@@ -33,6 +33,7 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
[ExportGroup("Field Interactions")]
[Export] public InteractionArea2D PlantingInteraction;
[Export] public InteractionArea2D FieldInteractionArea;
[ExportGroup("Configuration")]
[Export] public Node2D PlantingPlaceholder;
@@ -60,7 +61,7 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
// fieldstate == tilled && watering can ausgewählt
_canWater = (FieldState == FieldState.Tilled || FieldState == FieldState.Planted) && _wateringCanActive;
PlantingInteraction.IsActive = _canPlant || _canWater;
FieldInteractionArea.IsActive = _canPlant || _canWater;
}
public void ActivatedSeedInInventory(bool activated)
@@ -12,6 +12,7 @@ public class TargetSelectActionDetail : FighterAction.FighterActionDetail
// settings
public required bool selectEnemy;
public required bool selectAlly;
public required bool aliveOnly;
public VisualRange visualRange = VisualRange.Single;
// result
@@ -13,7 +13,8 @@ public class AllyAttackAction : FighterAction
public TargetSelectActionDetail targetSelect = new()
{
selectEnemy = true,
selectAlly = false
selectAlly = false,
aliveOnly = true
};
public MinigameActionDetail minigameDetail = new();
@@ -117,11 +117,13 @@ public partial class AllFightersVisual : Node
if (targetDetail.selectEnemy)
_fighterVisuals
.Where(kv => kv.Key.IsInFormation(HappeningData.enemyFighterFormation))
.Where(kv => !targetDetail.aliveOnly || kv.Key.IsAlive())// if aliveOnly: take where IsAlive
.ForEach(kv => kv.Value.SetTargetSelectionActive(true));
if (targetDetail.selectAlly)
_fighterVisuals
.Where(kv => kv.Key.IsInFormation(HappeningData.allyFighterFormation))
.Where(kv => !targetDetail.aliveOnly || kv.Key.IsAlive())// if aliveOnly: take where IsAlive
.ForEach(kv => kv.Value.SetTargetSelectionActive(true));
}