ZMWSLI0-SL2021-GR11/Projekt/MWSProjekt/Library/PackageCache/com.unity.visualscripting@1.6.1/Runtime/VisualScripting.State/TriggerStateTransition.cs

36 lines
969 B
C#
Raw Normal View History

2021-07-05 21:20:56 +02:00
namespace Unity.VisualScripting
{
/// <summary>
/// Triggers the transition in the parent state graph.
/// </summary>
[UnitSurtitle("State")]
[UnitCategory("Nesting")]
[UnitShortTitle("Trigger Transition")]
[TypeIcon(typeof(IStateTransition))]
public sealed class TriggerStateTransition : Unit
{
/// <summary>
/// The moment at which the parent state transition should be triggered.
/// </summary>
[DoNotSerialize]
[PortLabelHidden]
public ControlInput trigger { get; private set; }
protected override void Definition()
{
trigger = ControlInput(nameof(trigger), Trigger);
}
private ControlOutput Trigger(Flow flow)
{
var stateTransition = flow.stack.GetParent<INesterStateTransition>();
flow.stack.ExitParentElement();
stateTransition.Branch(flow);
return null;
}
}
}