🚧 watering fields kinda works now
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
using Babushka.scripts.CSharp.Common.Inventory;
|
||||
using Babushka.scripts.CSharp.Low_Code.Events;
|
||||
using Babushka.scripts.CSharp.Low_Code.Variables;
|
||||
using Godot;
|
||||
|
||||
@@ -23,6 +24,8 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
[Export] public InteractionArea2D FieldInteractionArea;
|
||||
[Export] public VariableResource _sceneKeyProvider;
|
||||
[Export] private VariableNode _fieldIndex;
|
||||
[Export] private CpuParticles2D _wateringParticles;
|
||||
[Export] private EventResource _wateringEvent;
|
||||
|
||||
|
||||
public Vector2 FieldPosition;
|
||||
@@ -30,15 +33,18 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
private bool _seedsActive;
|
||||
private bool _wateringCanActive;
|
||||
|
||||
private bool _canPlant;
|
||||
private bool _canWater;
|
||||
|
||||
[Signal] public delegate void PlantedEventHandler();
|
||||
|
||||
private void UpdateInteractionArea()
|
||||
{
|
||||
// fieldstate == tilled / watered && samen im Inventar
|
||||
bool canPlant = (FieldState == FieldState.Tilled || FieldState == FieldState.Watered) && _seedsActive;
|
||||
_canPlant = (FieldState == FieldState.Tilled || FieldState == FieldState.Watered) && _seedsActive;
|
||||
// fieldstate == tilled && watering can ausgewählt
|
||||
bool canWater = FieldState == FieldState.Tilled && _wateringCanActive;
|
||||
FieldInteractionArea.IsActive = canPlant || canWater;
|
||||
_canWater = FieldState == FieldState.Tilled && _wateringCanActive;
|
||||
FieldInteractionArea.IsActive = _canPlant || _canWater;
|
||||
}
|
||||
|
||||
public void ActivatedSeedInInventory(bool activated)
|
||||
@@ -97,6 +103,9 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
public void Water()
|
||||
{
|
||||
UpdateFieldState(FieldState.Watered);
|
||||
_wateringParticles.Emitting = true;
|
||||
WateringCanState.Water();
|
||||
_wateringEvent.Raise();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -104,11 +113,16 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
/// </summary>
|
||||
public void Farm()
|
||||
{
|
||||
if (TryPlant())
|
||||
if (_canPlant || TryPlant())
|
||||
{
|
||||
EmitSignal(SignalName.Planted);
|
||||
UpdateFieldState(FieldState.Planted);
|
||||
}
|
||||
|
||||
if (_canWater)
|
||||
{
|
||||
Water();
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryPlant()
|
||||
|
||||
Reference in New Issue
Block a user