68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
using TriInspector;
|
|
using UnityEngine;
|
|
|
|
namespace R0bbie.Timeline
|
|
{
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
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;
|
|
|
|
|
|
/// <summary>
|
|
/// Play this step, which here means telling the timeline to immediately play another step
|
|
/// </summary>
|
|
public override void Play()
|
|
{
|
|
Debug.Log(name + " - Started");
|
|
|
|
isActive = true;
|
|
|
|
Continue();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Complete this step by simply telling the timeline to play the set step
|
|
/// </summary>
|
|
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.");
|
|
|
|
}
|
|
|
|
|
|
}
|
|
} |