🎨 removed plant growing call group and replaced it with an event call. Made FarmingAnimation play on event.
This commit is contained in:
@@ -21,6 +21,8 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
|
||||
public Vector2 FieldPosition;
|
||||
|
||||
[Signal] public delegate void PlantedEventHandler();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
UpdateFieldState(FieldState);
|
||||
@@ -65,13 +67,14 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the player enters the field's interaction area and presses <E>.
|
||||
/// Called when the player enters the field's interaction area and presses <E> or clicks.
|
||||
/// </summary>
|
||||
public void Farm()
|
||||
{
|
||||
if (TryPlant())
|
||||
{
|
||||
UpdateFieldState(FieldState.Planted);
|
||||
{
|
||||
EmitSignal(SignalName.Planted);
|
||||
UpdateFieldState(FieldState.Planted);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ public partial class PlantBehaviour2D : Node2D
|
||||
{
|
||||
if (_state == PlantState.None)
|
||||
{
|
||||
GetTree().CallGroup("PlantGrowing", VesnaAnimations.MethodName.PlayFarmingAnimation);
|
||||
_state = PlantState.Planted;
|
||||
_currentPlantSprite = GetRandomSprite(_seeds);
|
||||
_currentPlantSprite.Visible = true;
|
||||
@@ -52,7 +51,6 @@ public partial class PlantBehaviour2D : Node2D
|
||||
|
||||
public void Grow()
|
||||
{
|
||||
GetTree().CallGroup("PlantGrowing", VesnaAnimations.MethodName.PlayFarmingAnimation);
|
||||
GrowPlant();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user