public void SetState(Type stateType, TParamStruct parameters) { // Set the state to a certain state type if (ActiveState != null) { ActiveState.Exit(parameters); } ActiveState = States[typeMap[stateType]]; ActiveState.Enter(parameters); }
public UStateMachine(TParamStruct p, params UState <TParamStruct>[] states) { States = states; typeMap = new Dictionary <Type, int>(); for (int i = 0; i < states.Length; i++) { states[i].Parent = this; typeMap.Add(states[i].GetType(), i); } ActiveState = states[0]; ActiveState.Enter(p); }