A game about forced loneliness, made by TACStudios
1namespace Unity.VisualScripting 2{ 3 /// <summary> 4 /// A special state that can trigger transitions to other states, 5 /// no matter which state is currently active. This state cannot receive 6 /// transitions. 7 /// </summary> 8 public sealed class AnyState : State 9 { 10 [DoNotSerialize] 11 public override bool canBeDestination => false; 12 13 public AnyState() : base() 14 { 15 isStart = true; 16 } 17 18 public override void OnExit(Flow flow, StateExitReason reason) 19 { 20 // Don't exit this state from branching. 21 if (reason == StateExitReason.Branch) 22 { 23 return; 24 } 25 26 base.OnExit(flow, reason); 27 } 28 29 public override void OnBranchTo(Flow flow, IState destination) 30 { 31 // Before entering the destination destination state, 32 // exit all other connected states. 33 34 foreach (var outgoingTransition in outgoingTransitionsNoAlloc) 35 { 36 if (outgoingTransition.destination != destination) 37 { 38 outgoingTransition.destination.OnExit(flow, StateExitReason.AnyBranch); 39 } 40 } 41 } 42 } 43}