A game about forced loneliness, made by TACStudios
1namespace Unity.VisualScripting 2{ 3 /// <summary> 4 /// Branches flow by checking if a condition is true or false. 5 /// </summary> 6 [UnitCategory("Control")] 7 [UnitOrder(0)] 8 [RenamedFrom("Bolt.Branch")] 9 [RenamedFrom("Unity.VisualScripting.Branch")] 10 public sealed class If : Unit, IBranchUnit 11 { 12 /// <summary> 13 /// The entry point for the branch. 14 /// </summary> 15 [DoNotSerialize] 16 [PortLabelHidden] 17 public ControlInput enter { get; private set; } 18 19 /// <summary> 20 /// The condition to check. 21 /// </summary> 22 [DoNotSerialize] 23 [PortLabelHidden] 24 public ValueInput condition { get; private set; } 25 26 /// <summary> 27 /// The action to execute if the condition is true. 28 /// </summary> 29 [DoNotSerialize] 30 [PortLabel("True")] 31 public ControlOutput ifTrue { get; private set; } 32 33 /// <summary> 34 /// The action to execute if the condition is false. 35 /// </summary> 36 [DoNotSerialize] 37 [PortLabel("False")] 38 public ControlOutput ifFalse { get; private set; } 39 40 protected override void Definition() 41 { 42 enter = ControlInput(nameof(enter), Enter); 43 condition = ValueInput<bool>(nameof(condition)); 44 ifTrue = ControlOutput(nameof(ifTrue)); 45 ifFalse = ControlOutput(nameof(ifFalse)); 46 47 Requirement(condition, enter); 48 Succession(enter, ifTrue); 49 Succession(enter, ifFalse); 50 } 51 52 public ControlOutput Enter(Flow flow) 53 { 54 return flow.GetValue<bool>(condition) ? ifTrue : ifFalse; 55 } 56 } 57}