Fixed tomato farming again
This commit is contained in:
@@ -15,7 +15,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
[Export] private Texture2D Watered;
|
||||
[Export] public FieldState FieldState = FieldState.Tilled;
|
||||
[Export] public InteractionArea2D PlantingInteraction;
|
||||
[Export] public Node PlantingPlaceholder;
|
||||
[Export] public Node2D PlantingPlaceholder;
|
||||
|
||||
|
||||
public Vector2 FieldPosition;
|
||||
@@ -48,6 +48,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
break;
|
||||
case FieldState.Planted:
|
||||
FieldState = FieldState.Planted;
|
||||
_fieldSprite.Texture = Tilled;
|
||||
PlantingInteraction.IsActive = false;
|
||||
break;
|
||||
default:
|
||||
@@ -82,10 +83,10 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
int currentSlotIndex = InventoryManager.Instance.CurrentSelectedSlotIndex;
|
||||
ItemInstance? item = InventoryManager.Instance.playerInventory.Slots[currentSlotIndex].itemInstance;
|
||||
|
||||
if (item == null)
|
||||
if (item == null || PlantingPlaceholder.GetChildCount() > 0)
|
||||
return success;
|
||||
|
||||
PackedScene? plantPrefab = SeedRepository.Instance.GetPlant(item.blueprint);
|
||||
|
||||
PackedScene? plantPrefab = item.blueprint.itemPrefab;
|
||||
|
||||
if (plantPrefab != null)
|
||||
{
|
||||
@@ -93,6 +94,15 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
if (plantInstance is Node2D plant2d)
|
||||
{
|
||||
PlantingPlaceholder.AddChild(plant2d);
|
||||
plant2d.GlobalPosition = PlantingPlaceholder.GlobalPosition;
|
||||
PlantBehaviour2D? plantBehaviour = plant2d as PlantBehaviour2D;
|
||||
|
||||
if (plantBehaviour != null)
|
||||
{
|
||||
plantBehaviour.Field = this;
|
||||
plantBehaviour.Grow();
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user