🐛 Fixed field interaction bug
This commit is contained in:
@@ -38,7 +38,7 @@ z_index = 1
|
|||||||
scale = Vector2(1.3499999, 1.5)
|
scale = Vector2(1.3499999, 1.5)
|
||||||
texture = ExtResource("9_wx561")
|
texture = ExtResource("9_wx561")
|
||||||
|
|
||||||
[node name="FieldBehaviour" type="Sprite2D" parent="." node_paths=PackedStringArray("_fieldIndex", "_saveIdHolder", "_fieldSprite", "_maskSprite", "_outlineSprite", "PlantingInteraction", "FieldInteractionArea", "PlantingPlaceholder", "_wateringParticles")]
|
[node name="FieldBehaviour" type="Sprite2D" parent="." node_paths=PackedStringArray("_fieldIndex", "_saveIdHolder", "_fieldSprite", "_maskSprite", "_outlineSprite", "PlantingInteraction", "PlantingPlaceholder", "_wateringParticles")]
|
||||||
visible = false
|
visible = false
|
||||||
z_index = -1
|
z_index = -1
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
@@ -56,7 +56,6 @@ _maskTexture = Array[Texture2D]([ExtResource("2_w8caw"), ExtResource("3_c014y"),
|
|||||||
Tilled = ExtResource("5_wx561")
|
Tilled = ExtResource("5_wx561")
|
||||||
Watered = ExtResource("6_7m4xq")
|
Watered = ExtResource("6_7m4xq")
|
||||||
PlantingInteraction = NodePath("InteractionArea")
|
PlantingInteraction = NodePath("InteractionArea")
|
||||||
FieldInteractionArea = NodePath("InteractionArea")
|
|
||||||
PlantingPlaceholder = NodePath("PlantPlaceholder")
|
PlantingPlaceholder = NodePath("PlantPlaceholder")
|
||||||
ItemRepository = ExtResource("7_w8caw")
|
ItemRepository = ExtResource("7_w8caw")
|
||||||
_wateringParticles = NodePath("../pouring water vfx")
|
_wateringParticles = NodePath("../pouring water vfx")
|
||||||
@@ -79,7 +78,6 @@ position = Vector2(-28.88889, -57)
|
|||||||
scale = Vector2(1.1111112, 1)
|
scale = Vector2(1.1111112, 1)
|
||||||
_active = false
|
_active = false
|
||||||
_spritesToOutline = [NodePath("../../OutlineSprite")]
|
_spritesToOutline = [NodePath("../../OutlineSprite")]
|
||||||
_showLabel = false
|
|
||||||
|
|
||||||
[node name="PlantCreationEventRaiser" type="Node" parent="."]
|
[node name="PlantCreationEventRaiser" type="Node" parent="."]
|
||||||
script = ExtResource("9_teirr")
|
script = ExtResource("9_teirr")
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ radius = 150.0
|
|||||||
[sub_resource type="Theme" id="Theme_5ajrf"]
|
[sub_resource type="Theme" id="Theme_5ajrf"]
|
||||||
default_font_size = 30
|
default_font_size = 30
|
||||||
|
|
||||||
[node name="InteractionArea" type="Node2D" node_paths=PackedStringArray("_area", "_label")]
|
[node name="InteractionArea" type="Node2D" node_paths=PackedStringArray("_selectionChangeListener", "_area", "_label")]
|
||||||
script = ExtResource("1_5ajrf")
|
script = ExtResource("1_5ajrf")
|
||||||
|
_selectionChangeListener = NodePath("SelectionListener")
|
||||||
_area = NodePath("Area2D")
|
_area = NodePath("Area2D")
|
||||||
_label = NodePath("Area2D/CanvasLayer/MarginContainer/Label")
|
_label = NodePath("Area2D/CanvasLayer/MarginContainer/Label")
|
||||||
_outlineMaterial = ExtResource("2_qoey7")
|
_outlineMaterial = ExtResource("2_qoey7")
|
||||||
|
|||||||
+2
-2
@@ -187,8 +187,8 @@ directories/tres_directory={
|
|||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_width=1980
|
window/size/viewport_width=1920
|
||||||
window/size/viewport_height=1020
|
window/size/viewport_height=1080
|
||||||
window/stretch/mode="viewport"
|
window/stretch/mode="viewport"
|
||||||
window/stretch/aspect="keep_height"
|
window/stretch/aspect="keep_height"
|
||||||
|
|
||||||
|
|||||||
@@ -1001,9 +1001,7 @@ metadata/SaveID = "5a823507-8107-40ce-8b32-6d0f81a3c44e"
|
|||||||
[node name="SpawnWithItem" parent="YSorted/CanGenericPickup" index="0"]
|
[node name="SpawnWithItem" parent="YSorted/CanGenericPickup" index="0"]
|
||||||
_blueprint = ExtResource("28_ipqaa")
|
_blueprint = ExtResource("28_ipqaa")
|
||||||
|
|
||||||
[node name="PickupInteractionArea" parent="YSorted/CanGenericPickup" index="3" node_paths=PackedStringArray("_spritesToOutline")]
|
[node name="PickupInteractionArea" parent="YSorted/CanGenericPickup" index="3"]
|
||||||
_outlineMaterial = null
|
|
||||||
_spritesToOutline = []
|
|
||||||
metadata/SaveID = "0c006f5c-c472-4f89-908b-d8f34503ba37"
|
metadata/SaveID = "0c006f5c-c472-4f89-908b-d8f34503ba37"
|
||||||
|
|
||||||
[node name="CollisionShape3D" parent="YSorted/CanGenericPickup/PickupInteractionArea/Area2D" index="0"]
|
[node name="CollisionShape3D" parent="YSorted/CanGenericPickup/PickupInteractionArea/Area2D" index="0"]
|
||||||
@@ -1019,9 +1017,7 @@ metadata/SaveID = "e13886b1-2131-4072-bc06-7d8abb19357b"
|
|||||||
[node name="SpawnWithItem" parent="YSorted/RakeGenericPickup" index="0"]
|
[node name="SpawnWithItem" parent="YSorted/RakeGenericPickup" index="0"]
|
||||||
_blueprint = ExtResource("28_6b2nr")
|
_blueprint = ExtResource("28_6b2nr")
|
||||||
|
|
||||||
[node name="PickupInteractionArea" parent="YSorted/RakeGenericPickup" index="3" node_paths=PackedStringArray("_spritesToOutline")]
|
[node name="PickupInteractionArea" parent="YSorted/RakeGenericPickup" index="3"]
|
||||||
_outlineMaterial = null
|
|
||||||
_spritesToOutline = []
|
|
||||||
metadata/SaveID = "c148aa78-114b-4770-a040-8498483edb1d"
|
metadata/SaveID = "c148aa78-114b-4770-a040-8498483edb1d"
|
||||||
|
|
||||||
[node name="CollisionShape3D" parent="YSorted/RakeGenericPickup/PickupInteractionArea/Area2D" index="0"]
|
[node name="CollisionShape3D" parent="YSorted/RakeGenericPickup/PickupInteractionArea/Area2D" index="0"]
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ region_enabled = true
|
|||||||
region_rect = Rect2(1156, 1185, 940, 189)
|
region_rect = Rect2(1156, 1185, 940, 189)
|
||||||
|
|
||||||
[node name="Katze" type="Sprite2D" parent="BackWall/Bench"]
|
[node name="Katze" type="Sprite2D" parent="BackWall/Bench"]
|
||||||
z_index = -10
|
z_index = 10
|
||||||
position = Vector2(61, -87)
|
position = Vector2(61, -87)
|
||||||
scale = Vector2(2, 2)
|
scale = Vector2(2, 2)
|
||||||
texture = ExtResource("15_sndxu")
|
texture = ExtResource("15_sndxu")
|
||||||
|
|||||||
@@ -8,16 +8,17 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
|||||||
public partial class DetectableInteractionArea : Area2D
|
public partial class DetectableInteractionArea : Area2D
|
||||||
{
|
{
|
||||||
[Export] public InteractionArea2D interactionArea2D;
|
[Export] public InteractionArea2D interactionArea2D;
|
||||||
|
|
||||||
|
|
||||||
public void InteractionAreaSelectionChanged(Variant instanceID)
|
public void InteractionAreaSelectionChanged(Variant instanceID)
|
||||||
{
|
{
|
||||||
if (instanceID.AsString() == GetInstanceId().ToString())
|
if (instanceID.AsString() == GetInstanceId().ToString())
|
||||||
{
|
{
|
||||||
|
GD.Print("InteractionArea: Selected.");
|
||||||
interactionArea2D.HighlightInteractable();
|
interactionArea2D.HighlightInteractable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
GD.Print("InteractionArea: Not Selected.");
|
||||||
interactionArea2D.ResetHighlight();
|
interactionArea2D.ResetHighlight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Babushka.scripts.CSharp.Common.Services;
|
using Babushka.scripts.CSharp.Common.Services;
|
||||||
|
using Babushka.scripts.CSharp.Low_Code.Variables;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||||
|
|
||||||
public partial class InteractionArea2D : Node2D
|
public partial class InteractionArea2D : Node2D
|
||||||
{
|
{
|
||||||
[ExportGroup("Settings")]
|
[ExportGroup("Settings")]
|
||||||
|
[Export] private VariableListener _selectionChangeListener;
|
||||||
[Export] private Area2D _area;
|
[Export] private Area2D _area;
|
||||||
[Export] private Label _label;
|
[Export] private Label _label;
|
||||||
[Export] private bool _active = true;
|
[Export] private bool _active = true;
|
||||||
@@ -29,6 +31,7 @@ public partial class InteractionArea2D : Node2D
|
|||||||
{
|
{
|
||||||
ProcessMode = value ? ProcessModeEnum.Inherit : ProcessModeEnum.Disabled;
|
ProcessMode = value ? ProcessModeEnum.Inherit : ProcessModeEnum.Disabled;
|
||||||
Visible = value;
|
Visible = value;
|
||||||
|
_selectionChangeListener.ProcessMode = value ? ProcessModeEnum.Inherit : ProcessModeEnum.Disabled;
|
||||||
_active = value;
|
_active = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,6 +53,7 @@ public partial class InteractionArea2D : Node2D
|
|||||||
|
|
||||||
public void HighlightInteractable()
|
public void HighlightInteractable()
|
||||||
{
|
{
|
||||||
|
GD.Print($"InteractionArea: Trying to highlight interactable. Current state: Active {_active}, Input Enabled {InputService.Instance.InputEnabled}, show label: {_showLabel} and use outline {_useOutline}.");
|
||||||
IsSelectedByDetector = true;
|
IsSelectedByDetector = true;
|
||||||
|
|
||||||
if (!_active || !InputService.Instance.InputEnabled)
|
if (!_active || !InputService.Instance.InputEnabled)
|
||||||
@@ -63,13 +67,13 @@ public partial class InteractionArea2D : Node2D
|
|||||||
|
|
||||||
foreach (var sprite in _spritesToOutline)
|
foreach (var sprite in _spritesToOutline)
|
||||||
{
|
{
|
||||||
GD.Print($"Highlighting outline material on {sprite.Name} Nr. {GetInstanceId()}");
|
|
||||||
sprite.Material = _outlineMaterial;
|
sprite.Material = _outlineMaterial;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetHighlight()
|
public void ResetHighlight()
|
||||||
{
|
{
|
||||||
|
GD.Print($"InteractionArea: Resetting interactable. Current state: show label: {_showLabel} and use outline {_useOutline}.");
|
||||||
IsSelectedByDetector = false;
|
IsSelectedByDetector = false;
|
||||||
_label.Hide();
|
_label.Hide();
|
||||||
|
|
||||||
@@ -79,7 +83,6 @@ public partial class InteractionArea2D : Node2D
|
|||||||
for (var i = 0; i < _spritesToOutline.Length; i++)
|
for (var i = 0; i < _spritesToOutline.Length; i++)
|
||||||
{
|
{
|
||||||
var sprite = _spritesToOutline[i];
|
var sprite = _spritesToOutline[i];
|
||||||
GD.Print($"Resetting outline material on {sprite.Name} Nr. {GetInstanceId()}");
|
|
||||||
sprite.Material = _backupMaterials[i];
|
sprite.Material = _backupMaterials[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,18 +108,11 @@ public partial class InteractionArea2D : Node2D
|
|||||||
|
|
||||||
private void TryInteract()
|
private void TryInteract()
|
||||||
{
|
{
|
||||||
|
GD.Print("InteractionArea: Trying to interact.");
|
||||||
if (_area.HasOverlappingAreas())
|
if (_area.HasOverlappingAreas())
|
||||||
{
|
{
|
||||||
_label.Hide();
|
GD.Print("InteractionArea: Interacting.");
|
||||||
|
ResetHighlight();
|
||||||
if (_useOutline)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < _spritesToOutline.Length; i++)
|
|
||||||
{
|
|
||||||
var sprite = _spritesToOutline[i];
|
|
||||||
sprite.Material = _backupMaterials[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Interact();
|
Interact();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,6 +131,7 @@ public partial class InteractionArea2D : Node2D
|
|||||||
|
|
||||||
public void ToggleActive()
|
public void ToggleActive()
|
||||||
{
|
{
|
||||||
|
GD.Print("InteractionArea: Toggled active state");
|
||||||
_active = !_active;
|
_active = !_active;
|
||||||
_label.Hide();
|
_label.Hide();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ public partial class VariableListener : Node
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void EventPayloadChanged(Variant payload, Variant oldPayload)
|
public void EventPayloadChanged(Variant payload, Variant oldPayload)
|
||||||
{
|
{
|
||||||
|
if (ProcessMode == ProcessModeEnum.Disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
if(_showLog)
|
if(_showLog)
|
||||||
GD.Print($"Calling Event Payload Changed Signals on: " + Name);
|
GD.Print($"Calling Event Payload Changed Signals on: " + Name);
|
||||||
EmitSignal(SignalName.PayloadChanged, payload, oldPayload);
|
EmitSignal(SignalName.PayloadChanged, payload, oldPayload);
|
||||||
|
|||||||
Reference in New Issue
Block a user