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