step-timeline/Scripts/Commands/DeactivateCommandsCmd.cs

49 lines
1.3 KiB
C#

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace R0bbie.Timeline
{
/// <summary>
/// DeactivateCommands StepCmd type, used to deactivate a list of commands which may have been left activated from a previous step
/// </summary>
[AddComponentMenu("Timeline/Commands/Deactivate Commands (Step Command)")]
[RequireComponent(typeof(Step))]
public class DeactivateCommandsCmd : StepCmd
{
[SerializeField] private List<StepCmd> commandsToDeactivate = new List<StepCmd>();
/// <summary>
/// Initialise command (called before Activate)
/// </summary>
protected override void Init()
{
init = true;
}
public override void Activate(Step _parentStep)
{
base.Activate(_parentStep);
// Loop through and deactivate all desired commands
foreach (StepCmd command in commandsToDeactivate)
{
command.DeactivateEarly();
}
// Then job of this command is done, complete it and deactivate
Complete();
}
protected override void Cleanup()
{
}
}
}