using System;

namespace VOID.Generic.Objects.Unit.Actions
{
    public class CustomAction : AbstractAction
    {
        private event Action<UnitObject> Action;
        private readonly UnitObject _unit;

        public CustomAction(UnitObject unit, Action<UnitObject> actionToDo)
        {
            _unit = unit;
            Action += actionToDo;
        }

        public override bool IsInRange() => true;
        public override bool CanSkipQueue() => true;

        protected override void OnCancelIt() {}
        protected override void OnEndIt() {}
        public override void CanDoIt() {}

        protected override void OnDoIt()
        {
            BeforePerform();
            Action?.Invoke(_unit);
            AfterPerform();
            EndIt();
        }
    }
}