using System; using UnityEngine; using Framework.Input; using Framework.Input.States; using Framework.Services; namespace Framework.State { /// Skips a cutscene when the escape key is pressed public class PauseKeyListener : ScriptComponent { /// Provides the instance with services it depends on /// Input manager by which the keys will be checked /// State manager the pause state will be toggled on protected virtual void Inject(IInputManager inputManager, IStateManager stateManager) { this.inputManager = inputManager; this.stateManager = stateManager; } /// Called once per visual frame to update the input devices protected virtual void Update() { if((this.inputManager != null) && (this.stateManager != null)) { CinematicInputState state = this.inputManager.GetState(); if(state.Pause.WasTriggered) { if(this.stateManager.IsPaused) { this.stateManager.Resume(); } else { this.stateManager.Pause(); } } } } /// /// Input manager that is used to obtain the current input device state /// private IInputManager inputManager; /// /// State manager that will handle pause mode and actor notifying /// private IStateManager stateManager; } } // namespace Framework.State