public void CheckExitConditions(AIStateMachine self) { foreach (var condition in exitConditions) { if (condition.IsSatisfied(self)) { self.SetState(condition.nextState); break; } } }
public bool IsSatisfied(AIStateMachine self) { switch (id) { case AIExitConditionID.SeeTarget: return(self.canSeeTarget); case AIExitConditionID.CantSeeTarget: return(!self.canSeeTarget); case AIExitConditionID.TimeLimit: return(Time.time - self.enterStateTime >= timeLimit); case AIExitConditionID.CloseToTarget: return(self.targetDistance <= distance); case AIExitConditionID.NotCloseToTarget: return(self.targetDistance > distance); } return(false); }