public void EnterState(PhysicsStateType stateType) { if (_psmStates.ContainsKey(stateType)) { AbstractPSMState nextState = _psmStates[stateType]; EnterState(nextState); } }
void EnterState(AbstractPSMState nextState) { if (nextState == null) { return; } if (currentState != null) { currentState.ExitState(); } currentState = nextState; InitializeState(nextState); currentState.EnterState(); }
public void Awake() { animator = this.GetComponentInChildren <Animator>(); if (animator != null) { Debug.LogWarning("No Animator is present"); } Cursor.lockState = CursorLockMode.Locked; input = this.GetComponent <Abstract_Input_Handler>(); currentState = null; rigidbody = this.GetComponent <Rigidbody>(); _psmStates = new Dictionary <PhysicsStateType, AbstractPSMState>(); foreach (AbstractPSMState state in _validStates) { InitializeState(state); _psmStates.Add(state.StateType, state); } }
//manage sate entering #region STATE MANAGEMENT void InitializeState(AbstractPSMState state) { state.InitializeState(animator, input, this, movement, rigidbody); }