#if HAVE_SLATE using System; using UnityEngine; using Slate; using Framework.Input; using Framework.Input.States; using Framework.Services; namespace Framework.Cinematics { /// Skips a cutscene when the escape key is pressed public class CutsceneSkipKeyListener : ScriptComponent { /// /// Called once after the GameObject the script is attached to is created /// protected void Start() { this.cutscene = GetComponent(); if(this.cutscene == null) { Debug.LogWarning( "CutsceneSkipKeyListener was added to '" + gameObject.name + "' which " + "does not have a Slate 'Cutscene' component. Skipping won't work." ); } } /// Provides the instance with services it depends on /// Input manager by which the keys will be checked protected virtual void Inject(IInputManager inputManager) { this.inputManager = inputManager; } /// Called once per visual frame to update the input devices protected virtual void Update() { if((this.cutscene != null) && (this.inputManager != null)) { CinematicInputState state = this.inputManager.GetState(); // Allow the cutscene to be skipped if(state.Skip.WasTriggered) { if(this.cutscene.isActive) { this.cutscene.SkipCurrentSection(); } } } } /// Input manager that is used to check input device states [NonSerialized] private IInputManager inputManager; /// Cutscene that can be skipped or paused by this script [NonSerialized] private Cutscene cutscene; } } // namespace Framework.Cinematics #endif // HAVE_SLATE