using TriInspector; using UnityEngine; namespace R0bbie.Timeline { /// /// Step type which simply tells the timeline to immediately play another step (anywhere in the timeline). Should generally be paired with a step switch (with the GoToStep as a child option), in order to jump the timeline back or forward to a particular step based on a set condition /// public class GoToStep : Step { [Title("Next Step")] [SerializeField] Step stepToJumpTo; [Tooltip("Passes true to _overrideIfAlreadyPlaying on StepController, making it force end the current step, then play this one.")] [SerializeField] bool forceStepPlayIfOnController; /// /// Play this step, which here means telling the timeline to immediately play another step /// public override void Play() { Debug.Log(name + " - Started"); isActive = true; Continue(); } /// /// Complete this step by simply telling the timeline to play the set step /// public override void Continue() { Debug.Log(name + " - Completed"); isActive = false; wasCompleted = true; // If no step to "go to" defined, just go to next step in timeline if (stepToJumpTo == null) { Debug.Log("stepToJumpTo was null on GoToStep, just proceeding to next step in the timeline."); base.Continue(); return; } // Instruct timeline to play the requested step if (attachedStepTimeline != null) { attachedStepTimeline.GoToStepAndPlay(stepToJumpTo); } else if (attachedController) { if (forceStepPlayIfOnController) attachedController.Play(stepToJumpTo, true); else attachedController.Play(stepToJumpTo); } else Debug.LogError("Tried to play a GoToStep without a Timeline or Controller attached, which isn't currently supported."); } } }