diff --git a/prefabs/UI/Inventory/Inventory.tscn b/prefabs/UI/Inventory/Inventory.tscn
index a81dedf..61c9286 100644
--- a/prefabs/UI/Inventory/Inventory.tscn
+++ b/prefabs/UI/Inventory/Inventory.tscn
@@ -61,6 +61,7 @@ offset_right = 200.0
offset_bottom = -1.0
grow_horizontal = 2
grow_vertical = 0
+mouse_filter = 2
[node name="BackgroundContainer" type="Control" parent="Inventory/SlotsContainer/SlotsMover"]
layout_mode = 1
@@ -76,8 +77,8 @@ layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
-offset_left = 437.0
-offset_right = 341.0
+offset_left = 435.0
+offset_right = 339.0
offset_bottom = 30.0
grow_horizontal = 2
grow_vertical = 2
@@ -90,8 +91,8 @@ layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
-offset_left = -357.0
-offset_right = -453.0
+offset_left = -356.0
+offset_right = -452.0
offset_bottom = 30.0
grow_horizontal = 2
grow_vertical = 2
diff --git a/prefabs/characters/Player2D.tscn b/prefabs/characters/Player2D.tscn
index bf5dc12..d321b3e 100644
--- a/prefabs/characters/Player2D.tscn
+++ b/prefabs/characters/Player2D.tscn
@@ -2093,7 +2093,7 @@ position = Vector2(0, -374)
[node name="Animated Sprites" type="AnimatedSprite2D" parent="CharacterBody2D/visuals"]
position = Vector2(0, 450)
sprite_frames = SubResource("SpriteFrames_4yiyq")
-animation = &"side walking wateringcan"
+animation = &"front walking backpack"
offset = Vector2(0, -450)
[node name="Hoe" type="Sprite2D" parent="CharacterBody2D/visuals"]
diff --git a/scenes/Babushka_scene_farm_outside_2d.tscn b/scenes/Babushka_scene_farm_outside_2d.tscn
index 6888f8f..bfeb3e0 100644
--- a/scenes/Babushka_scene_farm_outside_2d.tscn
+++ b/scenes/Babushka_scene_farm_outside_2d.tscn
@@ -1085,8 +1085,7 @@ script = ExtResource("40_w3jkj")
[connection signal="SuccessfulPickUp" from="YSorted/RakeGenericPickup" to="YSorted/Vesna" method="HandlePickUp"]
[connection signal="Interacted" from="YSorted/Farm visuals/Static/EnterHouseInteraction" to="." method="LoadScene"]
[connection signal="FieldCreated" from="YSorted/Farm visuals/FieldParent" to="Audio/SFX/Farming SFX" method="PlayOneShot"]
-[connection signal="mouse_entered" from="YSorted/Farm visuals/FieldParent/Area2D" to="YSorted/Farm visuals/FieldParent" method="MouseEnteredAllowedArea"]
-[connection signal="mouse_exited" from="YSorted/Farm visuals/FieldParent/Area2D" to="YSorted/Farm visuals/FieldParent" method="MouseExitedAllowedArea"]
+[connection signal="input_event" from="YSorted/Farm visuals/FieldParent/Area2D" to="YSorted/Vesna/FarmingControls" method="InputEventPressedOn"]
[connection signal="finished" from="Audio/Background Music Ramp up" to="Audio/Background Music loop" method="PlayFromOffset"]
[editable path="YSorted/Vesna"]
diff --git a/scripts/CSharp/Common/Farming/FarmingControls2D.cs b/scripts/CSharp/Common/Farming/FarmingControls2D.cs
index aaa4bce..2ee80fa 100644
--- a/scripts/CSharp/Common/Farming/FarmingControls2D.cs
+++ b/scripts/CSharp/Common/Farming/FarmingControls2D.cs
@@ -51,21 +51,62 @@ public partial class FarmingControls2D : Node2D
#endregion
public override void _Input(InputEvent @event)
+ {
+ if (@event.IsActionPressed("click")
+ && _toolId == WateringCanState.WATERING_CAN_ID
+ && WateringCanState.GetFillState() > 0)
+ {
+ Vector2I adjustedPosition = GetAdjustedMousePosition();
+ WaterTheField(adjustedPosition);
+ }
+ }
+
+ private Vector2I GetAdjustedMousePosition()
{
Vector2 mousePosition = _camera.GetGlobalMousePosition();
Vector2I mousePositionInteger = (Vector2I) mousePosition;
Vector2I adjustedPosition = AdjustValue(mousePositionInteger, new Vector2I(735, 651));
+ return adjustedPosition;
+ }
+
+ ///
+ /// Called by the allowed farming area collision area 2d.
+ ///
+ ///
+ ///
+ ///
+ public void InputEventPressedOn(Node node, InputEvent inputEvent, int shapeIndex)
+ {
+ if (!inputEvent.IsPressed())
+ {
+ GD.Print("Input Event is not pressed." );
+ return;
+ }
- if (@event.IsActionPressed("click") && _toolId == 0)
+ if (!inputEvent.IsActionPressed("click"))
+ return;
+
+ if (inputEvent is InputEventMouseButton inputEventMouseButton)
{
- MakeField(adjustedPosition);
+ GD.Print("Input Event is InputEventMouseButton." );
+ if (!inputEventMouseButton.Pressed)
+ {
+ GD.Print("Input Event Mouse Button is not pressed." );
+ return;
+ }
+ }
+ else
+ {
+ GD.Print("Other Input Event registered." );
+ return;
}
- if (@event.IsActionPressed("click")
- && _toolId == WateringCanState.WATERING_CAN_ID
- && WateringCanState.GetFillState() > 0)
+ GD.Print("Current tool id: " + _toolId );
+ if (_toolId == 0)
{
- WaterTheField(adjustedPosition);
+ GD.Print("Trying to create field." );
+ Vector2I adjustedPosition = GetAdjustedMousePosition();
+ MakeField(adjustedPosition);
}
}
@@ -98,10 +139,6 @@ public partial class FarmingControls2D : Node2D
if(FieldService == null || _fieldPrefab == null)
return;
- // only try to instantiate a field if you're in the allowed area
- if (!FieldService.FieldAllowed())
- return;
-
// only instantiate a field if there isn't one already.
if(FieldService.Get(fieldPosition) == null)
{
diff --git a/scripts/CSharp/Common/Farming/FieldService2D.cs b/scripts/CSharp/Common/Farming/FieldService2D.cs
index 43536c9..5b36976 100644
--- a/scripts/CSharp/Common/Farming/FieldService2D.cs
+++ b/scripts/CSharp/Common/Farming/FieldService2D.cs
@@ -7,27 +7,24 @@ namespace Babushka.scripts.CSharp.Common.Farming;
public partial class FieldService2D : Node2D
{
[Export] private Dictionary fields = new Dictionary();
-
- private bool _fieldAllowed = false;
+
+ [Export] private Area2D _allowedArea;
[Signal] public delegate void FieldCreatedEventHandler();
-
- //Validate
-
- public void MouseEnteredAllowedArea()
- {
- _fieldAllowed = true;
- }
-
- public void MouseExitedAllowedArea()
- {
- _fieldAllowed = false;
- }
- public bool FieldAllowed()
+ /*
+ public override void _PhysicsProcess(double delta)
{
- return _fieldAllowed;
+ var spaceState = GetWorld2D().DirectSpaceState;
+ // use global coordinates, not local to node
+ var query = PhysicsRayQueryParameters2D.Create(GetGlobalMousePosition(), new Vector3(0,0,-1),
+ CollisionMask, [GetRid()]);
+ var result = spaceState.IntersectRay(query);
+ if (result.Count > 0)
+ GD.Print("Hit at point: ", result["position"]);
}
+ */
+
//Create
public bool TryAddEntry(Vector2I key, FieldBehaviour2D field)