🐛 added preset fields to main outdoor scene and made them farmable
This commit is contained in:
@@ -112,7 +112,6 @@ public partial class InteractionArea2D : Node2D
|
||||
|
||||
public void SetSpriteActiveState(bool success, int id) // TODO: remove
|
||||
{
|
||||
GD.PrintErr("SetSpriteActiveState is being called.");
|
||||
if (!_active)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,51 @@
|
||||
using Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
|
||||
/// <summary>
|
||||
/// Enables a preset field in the scene sothat it can be used for farming.
|
||||
/// </summary>
|
||||
public partial class FieldActivator : Node
|
||||
{
|
||||
[Export] private Node2D _field;
|
||||
[Export] private FieldBehaviour2D _field;
|
||||
[Export] private InteractionArea2D _activatorArea;
|
||||
|
||||
private bool _activated = false;
|
||||
private bool _used = false;
|
||||
private bool _rakeInHand;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
ToggleInteractionArea();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Activates the fieldbehaviour node and sets it to the tilled state.
|
||||
/// </summary>
|
||||
public void ActivateField()
|
||||
{
|
||||
if (!_activated && _rakeInHand)
|
||||
if (!_used && _rakeInHand)
|
||||
{
|
||||
GD.Print("Tryina activate this field right here....");
|
||||
_field.Visible = true;
|
||||
_activated = true;
|
||||
_field.UpdateFieldState(FieldState.Tilled);
|
||||
_used = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reacts to changes in the inventory.
|
||||
/// If setup correctly, the field activator interactable should only trigger when using the rake.
|
||||
/// </summary>
|
||||
/// <param name="activated"></param>
|
||||
public void RakeActivated(bool activated)
|
||||
{
|
||||
_rakeInHand = activated;
|
||||
ToggleInteractionArea();
|
||||
}
|
||||
|
||||
private void ToggleInteractionArea()
|
||||
{
|
||||
_activatorArea.IsActive = !_used && _rakeInHand;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
// fieldstate == tilled / watered && samen im Inventar
|
||||
_canPlant = (FieldState == FieldState.Tilled || FieldState == FieldState.Watered) && _seedsActive;
|
||||
// fieldstate == tilled && watering can ausgewählt
|
||||
_canWater = FieldState == FieldState.Tilled && _wateringCanActive;
|
||||
_canWater = (FieldState == FieldState.Tilled || FieldState == FieldState.Planted) && _wateringCanActive;
|
||||
FieldInteractionArea.IsActive = _canPlant || _canWater;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
/// </summary>
|
||||
public void Farm()
|
||||
{
|
||||
if (_canPlant || TryPlant())
|
||||
if (_canPlant && TryPlant())
|
||||
{
|
||||
EmitSignal(SignalName.Planted);
|
||||
UpdateFieldState(FieldState.Planted);
|
||||
@@ -133,7 +133,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
bool success = false;
|
||||
int currentSlotIndex = InventoryManager.Instance.CurrentSelectedSlotIndex;
|
||||
ItemInstance? item = InventoryManager.Instance.playerInventory.Slots[currentSlotIndex].itemInstance;
|
||||
|
||||
|
||||
if (item == null || PlantingPlaceholder.GetChildCount() > 0 || item.amount == 0)
|
||||
return success;
|
||||
|
||||
@@ -155,7 +155,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
InventoryManager.Instance.playerInventory.RemoveItem(currentSlotIndex);
|
||||
success = true;
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ public partial class FieldService : Node
|
||||
//Create
|
||||
public bool TryAddEntry(string sceneName, int fieldIndex, FieldBehaviour2D field)
|
||||
{
|
||||
GD.Print("Trying to add a field at: " + fieldIndex);
|
||||
if (_outerDict != null )
|
||||
{
|
||||
FieldsInScene innerDict;
|
||||
|
||||
@@ -67,7 +67,6 @@ public partial class PlantBehaviour2D : Node2D
|
||||
return;
|
||||
}
|
||||
|
||||
GD.Print("Growing plant.");
|
||||
switch (_state)
|
||||
{
|
||||
case PlantState.None:
|
||||
|
||||
Reference in New Issue
Block a user