Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. namespace 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. public AnyState() : base()
  13. {
  14. isStart = true;
  15. }
  16. public override void OnExit(Flow flow, StateExitReason reason)
  17. {
  18. // Don't exit this state from branching.
  19. if (reason == StateExitReason.Branch)
  20. {
  21. return;
  22. }
  23. base.OnExit(flow, reason);
  24. }
  25. public override void OnBranchTo(Flow flow, IState destination)
  26. {
  27. // Before entering the destination destination state,
  28. // exit all other connected states.
  29. foreach (var outgoingTransition in outgoingTransitionsNoAlloc)
  30. {
  31. if (outgoingTransition.destination != destination)
  32. {
  33. outgoingTransition.destination.OnExit(flow, StateExitReason.AnyBranch);
  34. }
  35. }
  36. }
  37. }
  38. }