/// <summary> /// Add a new input state to the current input state stack. /// This will mark the current state, if any, as inactive and inform it of the new state that is taking its place. /// Then this will add the new state to the stack, mark it active, and call the BeginState method. /// </summary> /// <param name="nextInputState"></param> public void AddInputState(IInputState nextInputState) { if (nextInputState == null) { throw new ArgumentNullException(nameof(nextInputState), "Given new state passed to GameBattle AddInputState method is null"); } // Deactivate any existing state on the stack if (_inputStateStack.Any()) { var lastState = _inputStateStack.Peek(); lastState.Deactivate(); } // Add the new state to the stack and _inputStateStack.Push(nextInputState); nextInputState.Activate(); }