// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2023 Kybernetik // using System; namespace Animancer.FSM { /// An that uses delegates to define its behaviour. /// /// Documentation: State Types /// /// https://kybernetik.com.au/animancer/api/Animancer.FSM/DelegateState /// public class DelegateState : IState { /************************************************************************************************************************/ /// Determines whether this state can be entered. Null is treated as returning true. public Func canEnter; /// [] Calls to determine whether this state can be entered. public virtual bool CanEnterState => canEnter == null || canEnter(); /************************************************************************************************************************/ /// Determines whether this state can be exited. Null is treated as returning true. public Func canExit; /// [] Calls to determine whether this state can be exited. public virtual bool CanExitState => canExit == null || canExit(); /************************************************************************************************************************/ /// Called when this state is entered. public Action onEnter; /// [] Calls when this state is entered. public virtual void OnEnterState() => onEnter?.Invoke(); /************************************************************************************************************************/ /// Called when this state is exited. public Action onExit; /// [] Calls when this state is exited. public virtual void OnExitState() => onExit?.Invoke(); /************************************************************************************************************************/ } }