No Description
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.

NesterStateTransition.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Collections.Generic;
  2. using UnityObject = UnityEngine.Object;
  3. namespace Unity.VisualScripting
  4. {
  5. public abstract class NesterStateTransition<TGraph, TMacro> : StateTransition, INesterStateTransition
  6. where TGraph : class, IGraph, new()
  7. where TMacro : Macro<TGraph>
  8. {
  9. protected NesterStateTransition()
  10. {
  11. nest.nester = this;
  12. }
  13. protected NesterStateTransition(IState source, IState destination) : base(source, destination)
  14. {
  15. nest.nester = this;
  16. }
  17. [Serialize]
  18. public GraphNest<TGraph, TMacro> nest { get; private set; } = new GraphNest<TGraph, TMacro>();
  19. [DoNotSerialize]
  20. IGraphNest IGraphNester.nest => nest;
  21. [DoNotSerialize]
  22. IGraph IGraphParent.childGraph => nest.graph;
  23. [DoNotSerialize]
  24. bool IGraphParent.isSerializationRoot => nest.source == GraphSource.Macro;
  25. [DoNotSerialize]
  26. UnityObject IGraphParent.serializedObject => nest.macro;
  27. [DoNotSerialize]
  28. public override IEnumerable<ISerializationDependency> deserializationDependencies => nest.deserializationDependencies;
  29. public override IEnumerable<object> GetAotStubs(HashSet<object> visited)
  30. {
  31. return LinqUtility.Concat<object>(base.GetAotStubs(visited), nest.GetAotStubs(visited));
  32. }
  33. protected void CopyFrom(NesterStateTransition<TGraph, TMacro> source)
  34. {
  35. base.CopyFrom(source);
  36. nest = source.nest;
  37. }
  38. public abstract TGraph DefaultGraph();
  39. IGraph IGraphParent.DefaultGraph() => DefaultGraph();
  40. void IGraphNester.InstantiateNest() => InstantiateNest();
  41. void IGraphNester.UninstantiateNest() => UninstantiateNest();
  42. }
  43. }