using Godot; namespace Newlon.Components.Plants; public partial class SnipachBehaviour : BaseBehaviour { [Export] public AreaAttack attackBox; [Export] public Timer timer; [Export] public Timer guardTimer; private bool dragging = false; public void OnDragBegin() { if (timer.TimeLeft > 0 || guardTimer.TimeLeft > 0) return; dragging = true; attackBox.Visible = dragging; } public void OnDragEnd(bool aborted) { if (dragging == false) return; dragging = false; attackBox.Visible = dragging; if (aborted) return; attackBox.Attack(); timer.Start(); } public override void _PhysicsProcess(double delta) { if (dragging) { attackBox.GlobalPosition = (Cursor.GetCursorPosition() / FieldParams.Tile).Ceil() * FieldParams.Tile - new Vector2(20, 14); } if (timer.TimeLeft > 0) { GetParent().Modulate = Colors.DeepSkyBlue; } else { GetParent().Modulate = Colors.White; } } }