✨ added InventoryListener and made field interaction area activate only when the right item (seed) is in the inventory
This commit is contained in:
@@ -19,15 +19,33 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
[Export] public InteractionArea2D PlantingInteraction;
|
||||
[Export] public Node2D PlantingPlaceholder;
|
||||
[Export] public ItemRepository ItemRepository;
|
||||
|
||||
[Export] public InteractionArea2D FieldInteractionArea;
|
||||
|
||||
public Vector2 FieldPosition;
|
||||
|
||||
private bool _seedsActive;
|
||||
|
||||
[Signal] public delegate void PlantedEventHandler();
|
||||
|
||||
private void UpdateInteractionArea()
|
||||
{
|
||||
// fieldstate == tilled / watered && samen im Inventar
|
||||
bool canPlant = (FieldState == FieldState.Tilled || FieldState == FieldState.Watered) && _seedsActive;
|
||||
// fieldstate == tilled && watering can ausgewählt
|
||||
bool canWater = false;
|
||||
FieldInteractionArea.IsActive = canPlant || canWater;
|
||||
}
|
||||
|
||||
public void ActivatedSeedInInventory(bool activated)
|
||||
{
|
||||
_seedsActive = activated;
|
||||
UpdateInteractionArea();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
UpdateFieldState(FieldState);
|
||||
UpdateInteractionArea();
|
||||
int randomIndex = new Random().Next(0, _maskTexture.Length);
|
||||
_maskSprite.Texture = _maskTexture[randomIndex];
|
||||
_outlineSprite.Texture = _maskOutlineTextures[randomIndex];
|
||||
|
||||
Reference in New Issue
Block a user