A game about forced loneliness, made by TACStudios
1using UnityEngine;
2
3namespace Unity.VisualScripting
4{
5 [AddComponentMenu("Visual Scripting/State Machine")]
6 [RequireComponent(typeof(Variables))]
7 [DisableAnnotation]
8 [VisualScriptingHelpURL(typeof(StateMachine))]
9 public sealed class StateMachine : EventMachine<StateGraph, StateGraphAsset>
10 {
11 protected override void OnEnable()
12 {
13 if (hasGraph)
14 {
15 using (var flow = Flow.New(reference))
16 {
17 graph.Start(flow);
18 }
19 }
20
21 base.OnEnable();
22 }
23
24 protected override void OnInstantiateWhileEnabled()
25 {
26 if (hasGraph)
27 {
28 using (var flow = Flow.New(reference))
29 {
30 graph.Start(flow);
31 }
32 }
33
34 base.OnInstantiateWhileEnabled();
35 }
36
37 protected override void OnUninstantiateWhileEnabled()
38 {
39 base.OnUninstantiateWhileEnabled();
40
41 if (hasGraph)
42 {
43 using (var flow = Flow.New(reference))
44 {
45 graph.Stop(flow);
46 }
47 }
48 }
49
50 protected override void OnDisable()
51 {
52 base.OnDisable();
53
54 if (hasGraph)
55 {
56 using (var flow = Flow.New(reference))
57 {
58 graph.Stop(flow);
59 }
60 }
61 }
62
63 [ContextMenu("Show Data...")]
64 protected override void ShowData()
65 {
66 base.ShowData();
67 }
68
69 public override StateGraph DefaultGraph()
70 {
71 return StateGraph.WithStart();
72 }
73 }
74}