A game about forced loneliness, made by TACStudios
1using System.Linq; 2 3namespace Unity.VisualScripting 4{ 5 [Descriptor(typeof(FlowStateTransition))] 6 public class FlowStateTransitionDescriptor : NesterStateTransitionDescriptor<FlowStateTransition> 7 { 8 public FlowStateTransitionDescriptor(FlowStateTransition transition) : base(transition) { } 9 10 public override string Title() 11 { 12 var graph = transition.nest.graph; 13 14 if (graph != null) 15 { 16 if (!StringUtility.IsNullOrWhiteSpace(graph.title)) 17 { 18 return graph.title; 19 } 20 21 using (var recursion = Recursion.New(1)) 22 { 23 var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList(); 24 25 if (events.Count == 0) 26 { 27 return "(No Event)"; 28 } 29 else if (events.Count == 1) 30 { 31 return events[0].Description().title; 32 } 33 else // if (events.Count > 1) 34 { 35 return "(Multiple Events)"; 36 } 37 } 38 } 39 else 40 { 41 return "(No Transition)"; 42 } 43 } 44 45 public override string Summary() 46 { 47 var graph = transition.nest.graph; 48 49 if (graph != null) 50 { 51 if (!StringUtility.IsNullOrWhiteSpace(graph.summary)) 52 { 53 return graph.summary; 54 } 55 56 using (var recursion = Recursion.New(1)) 57 { 58 var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList(); 59 60 if (events.Count == 0) 61 { 62 return "Open the transition graph to add an event."; 63 } 64 else if (events.Count == 1) 65 { 66 return events[0].Description().summary; 67 } 68 else // if (events.Count > 1) 69 { 70 return "Open the transition graph to see the full transition."; 71 } 72 } 73 } 74 else 75 { 76 return "Choose a source in the graph inspector."; 77 } 78 } 79 80 public override EditorTexture Icon() 81 { 82 var graph = transition.nest.graph; 83 84 using (var recursion = Recursion.New(1)) 85 { 86 if (graph != null) 87 { 88 var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList(); 89 90 if (events.Count == 1) 91 { 92 return events[0].Description().icon; 93 } 94 else 95 { 96 return typeof(IStateTransition).Icon(); 97 } 98 } 99 else 100 { 101 return typeof(IStateTransition).Icon(); 102 } 103 } 104 } 105 } 106}