using System;
using RebootKit.Engine.Simulation;

namespace RebootKit.Engine.AI {
    public interface IStrategy {
        BehaviourNode.Status Process(Actor target, float dt);
        void Reset() {
        }
    }
    
    public class Condition : IStrategy {
        readonly Func<bool> m_Predicate;

        public Condition(Func<bool> predicate) {
            m_Predicate = predicate;
        }
        
        public BehaviourNode.Status Process(Actor target, float dt) {
            if (m_Predicate()) {
                return BehaviourNode.Status.Success;
            }

            return BehaviourNode.Status.Failure;
        }
    }
    
    public class ActionStrategy : IStrategy {
        readonly Action m_Action;

        public ActionStrategy(Action action) {
            m_Action = action;
        }

        public BehaviourNode.Status Process(Actor target, float dt) {
            m_Action();
            return BehaviourNode.Status.Success;
        }
    }
}