🚧 interaction kinda sorta works now, still needs tweaking

pull/48/head
kziolkowski 1 month ago
parent a6260efc07
commit b232cb31c3

@ -2123,9 +2123,6 @@ frame = 7
frame_progress = 0.229832 frame_progress = 0.229832
offset = Vector2(0, -450) offset = Vector2(0, -450)
[node name="DetectionCross" parent="CharacterBody2D" instance=ExtResource("466_e04c3")]
position = Vector2(0, -200)
[node name="PlantCreatedEventListener" type="Node" parent="CharacterBody2D"] [node name="PlantCreatedEventListener" type="Node" parent="CharacterBody2D"]
script = ExtResource("467_8hbu5") script = ExtResource("467_8hbu5")
_eventResources = Array[Object]([ExtResource("468_t1d6r")]) _eventResources = Array[Object]([ExtResource("468_t1d6r")])
@ -2175,6 +2172,9 @@ scrollable = false
script = ExtResource("472_kduih") script = ExtResource("472_kduih")
_wateringCanFillStateNode = NodePath("../WateringCanFillState") _wateringCanFillStateNode = NodePath("../WateringCanFillState")
[node name="DetectionCross" parent="CharacterBody2D" instance=ExtResource("466_e04c3")]
position = Vector2(0, -371)
[node name="FarmingControls" type="Node2D" parent="." node_paths=PackedStringArray("_movingPlayer")] [node name="FarmingControls" type="Node2D" parent="." node_paths=PackedStringArray("_movingPlayer")]
script = ExtResource("817_6nrw3") script = ExtResource("817_6nrw3")
_sceneKeyProvider = ExtResource("471_83c4i") _sceneKeyProvider = ExtResource("471_83c4i")

@ -5,6 +5,7 @@
[ext_resource type="Script" uid="uid://b4n0nlu4ckqga" path="res://scripts/CSharp/Common/CharacterControls/RaycastDetector.cs" id="2_va8tx"] [ext_resource type="Script" uid="uid://b4n0nlu4ckqga" path="res://scripts/CSharp/Common/CharacterControls/RaycastDetector.cs" id="2_va8tx"]
[node name="DetectionCross" type="Node2D" node_paths=PackedStringArray("_collider", "_detector")] [node name="DetectionCross" type="Node2D" node_paths=PackedStringArray("_collider", "_detector")]
position = Vector2(0, 1)
script = ExtResource("1_va8tx") script = ExtResource("1_va8tx")
_collider = NodePath("detector") _collider = NodePath("detector")
_detector = NodePath("Raycast") _detector = NodePath("Raycast")
@ -12,8 +13,7 @@ _xOffset = 200.0
_yOffset = 200.0 _yOffset = 200.0
[node name="Raycast" type="RayCast2D" parent="."] [node name="Raycast" type="RayCast2D" parent="."]
top_level = true target_position = Vector2(222, -168)
target_position = Vector2(257, -149)
collide_with_areas = true collide_with_areas = true
script = ExtResource("2_va8tx") script = ExtResource("2_va8tx")

@ -19,7 +19,7 @@ public partial class DetectionCross : Node2D
public void SetDirection(Vector2 direction) public void SetDirection(Vector2 direction)
{ {
Vector2 newPos = new Vector2(direction.X * _xOffset, direction.Y * _yOffset); Vector2 newPos = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
_collider.GlobalPosition = newPos; _collider.Position = newPos;
_detector.TargetPosition = newPos; _detector.TargetPosition = newPos;
} }
} }

@ -46,6 +46,7 @@ public partial class InteractionArea2D : Node2D
public void OnPlayerEntered(Node2D player) public void OnPlayerEntered(Node2D player)
{ {
GD.Print("OnPlayerEntered: " + this.GetParent().Name);
if (!_active || !InputService.Instance.InputEnabled) if (!_active || !InputService.Instance.InputEnabled)
return; return;

@ -32,6 +32,7 @@ public partial class RaycastDetector : RayCast2D
_lastDetected.NoLongerDetected(); _lastDetected.NoLongerDetected();
} }
GD.Print("Colliding with: " + interactionArea.GetParent().Name);
_lastDetected = interactionArea; _lastDetected = interactionArea;
interactionArea.Detected(); interactionArea.Detected();
} }

Loading…
Cancel
Save