namespace UOP1.StateMachine { /// /// Class that represents a conditional statement. /// public abstract class Condition : IStateComponent { /// /// Specify the statement to evaluate. /// /// public abstract bool Statement(); /// /// Awake is called when creating a new instance. Use this method to cache the components needed for the condition. /// /// The this instance belongs to. public virtual void Awake(StateMachine stateMachine) { } public virtual void OnStateEnter() { } public virtual void OnStateExit() { } } /// /// Struct containing a Condition and its expected result. /// public readonly struct StateCondition { internal readonly Condition _condition; internal readonly bool _expectedResult; public StateCondition(Condition condition, bool expectedResult) { _condition = condition; _expectedResult = expectedResult; } public bool IsMet => _condition.Statement() == _expectedResult; } }