A game about forced loneliness, made by TACStudios
1namespace Unity.VisualScripting
2{
3 /// <summary>
4 /// Returns true if one input is true and the other is false.
5 /// </summary>
6 [UnitCategory("Logic")]
7 [UnitOrder(2)]
8 public sealed class ExclusiveOr : Unit
9 {
10 /// <summary>
11 /// The first boolean.
12 /// </summary>
13 [DoNotSerialize]
14 public ValueInput a { get; private set; }
15
16 /// <summary>
17 /// The second boolean.
18 /// </summary>
19 [DoNotSerialize]
20 public ValueInput b { get; private set; }
21
22 /// <summary>
23 /// True if either A or B is true but not the other; false otherwise.
24 /// </summary>
25 [DoNotSerialize]
26 [PortLabel("A \u2295 B")]
27 public ValueOutput result { get; private set; }
28
29 protected override void Definition()
30 {
31 a = ValueInput<bool>(nameof(a));
32 b = ValueInput<bool>(nameof(b));
33 result = ValueOutput(nameof(result), Operation).Predictable();
34
35 Requirement(a, result);
36 Requirement(b, result);
37 }
38
39 public bool Operation(Flow flow)
40 {
41 return flow.GetValue<bool>(a) ^ flow.GetValue<bool>(b);
42 }
43 }
44}