private FSMState GetGoalState(FSMState.FSMStates goalState) { foreach (FSMState state in states) { if (state.Type == goalState) return state; } return null; }
public void ChangeState(AI_RTS_MonoGame.AI.FSM.FSMState.FSMStates state, bool reenter = false) { if (reenter || state != currentState.Type) { currentState.Exit(); currentState = GetGoalState(state); currentState.Enter(); } }
public void Reset() { if (currentState != null) currentState.Exit(); currentState = defaultState; foreach (FSMState state in states) state.Init(); if (currentState != null) currentState.Enter(); }
public void Update(GameTime gameTime) { if (currentState == null) currentState = defaultState; if (currentState == null) return; FSMState.FSMStates goalType = currentState.CheckTransitions(); ChangeState(goalType); currentState.Update(gameTime); }
public void SetDefaultState(FSMState state) { defaultState = state; }
public void AddState(FSMState state) { states.Add(state); }
public UnitFSMState(FSMState.FSMStates type, UnitController controller, GameplayManager gm) : base(type) { this.controller = controller; this.gm = gm; }
public UnitFSMState(FSMState.FSMStates type, UnitController controller) :base (type){ this.controller = controller; }