A game about forced loneliness, made by TACStudios
1namespace Unity.VisualScripting 2{ 3 [UnitOrder(101)] 4 public abstract class Add<T> : Unit 5 { 6 /// <summary> 7 /// The first value. 8 /// </summary> 9 [DoNotSerialize] 10 public ValueInput a { get; private set; } 11 12 /// <summary> 13 /// The second value. 14 /// </summary> 15 [DoNotSerialize] 16 public ValueInput b { get; private set; } 17 18 /// <summary> 19 /// The sum of A and B. 20 /// </summary> 21 [DoNotSerialize] 22 [PortLabel("A + B")] 23 public ValueOutput sum { get; private set; } 24 25 [DoNotSerialize] 26 protected virtual T defaultB => default(T); 27 28 protected override void Definition() 29 { 30 a = ValueInput<T>(nameof(a)); 31 b = ValueInput(nameof(b), defaultB); 32 33 sum = ValueOutput(nameof(sum), Operation).Predictable(); 34 35 Requirement(a, sum); 36 Requirement(b, sum); 37 } 38 39 private T Operation(Flow flow) 40 { 41 return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b)); 42 } 43 44 public abstract T Operation(T a, T b); 45 } 46}