Ejemplo n.º 1
0
        TState GetOrCreateState <TState>() where TState : AltoState, new()
        {
            var stateType = typeof(TState);

            foreach (var state in _registeredStates)
            {
                if (state.GetType() == stateType)
                {
                    return((TState)state);
                }
            }

            var newState = new TState();

            newState.context = _context;
            newState.fsm     = this;
            newState.Init();
            _registeredStates.Add(newState);

            return(newState);
        }