using Babushka.scripts.CSharp.Common.CharacterControls; using Godot; namespace Babushka.scripts.CSharp.Common.Farming; /// /// Enables a preset field in the scene sothat it can be used for farming. /// public partial class FieldActivator : Node { [Export] private FieldBehaviour2D _field; [Export] private InteractionArea2D _activatorArea; private bool _used = false; private bool _rakeInHand; public override void _Ready() { ToggleInteractionArea(); } /// /// Activates the fieldbehaviour node and sets it to the tilled state. /// public void ActivateField() { if (!_used && _rakeInHand) { _field.Visible = true; _field.UpdateFieldState(FieldState.Tilled); _used = true; } } /// /// Reacts to changes in the inventory. /// If setup correctly, the field activator interactable should only trigger when using the rake. /// /// public void RakeActivated(bool activated) { _rakeInHand = activated; ToggleInteractionArea(); } private void ToggleInteractionArea() { _activatorArea.IsActive = !_used && _rakeInHand; } }