private void InitializeState(FWState newState) { _states.Add(newState); this.CurrentState = newState; this.CurrentStateType = newState.NpcState; for (int i = 0; i < _states.Count; i++) { if (_states[i].NpcState == CurrentStateType) { CurrentState.CleanupOldState(); CurrentState = _states[i]; CurrentState.InitializeNewState(); break; } } }
public void AddNewState(FWState newState) { if (!FWStateUtility.IsValidState(newState)) { return; } if (_states.Count == 0) // if there are no states, add state as first { InitializeState(newState); return; } for (int i = 0; i < _states.Count; i++) { if (_states[i].NpcState == newState.NpcState) { Debug.LogError("The state being added already exists in the list"); return; } } _states.Add(newState); }
public static bool IsValidState(FWState stateToCheck) { return(stateToCheck != null); }