A game about forced loneliness, made by TACStudios
1using System;
2using UnityEngine;
3
4namespace Unity.VisualScripting
5{
6 /// <summary>
7 /// Compares two numbers to determine if they are not approximately equal (disregarding floating point precision errors).
8 /// </summary>
9 [UnitCategory("Logic")]
10 [UnitShortTitle("Not Equal")]
11 [UnitSubtitle("(Approximately)")]
12 [UnitOrder(8)]
13 [Obsolete("Use the Not Equal node with Numeric enabled instead.")]
14 public sealed class NotApproximatelyEqual : Unit
15 {
16 /// <summary>
17 /// The first number.
18 /// </summary>
19 [DoNotSerialize]
20 public ValueInput a { get; private set; }
21
22 /// <summary>
23 /// The second number.
24 /// </summary>
25 [DoNotSerialize]
26 public ValueInput b { get; private set; }
27
28 /// <summary>
29 /// Whether A is not approximately equal to B.
30 /// </summary>
31 [DoNotSerialize]
32 [PortLabel("A \u2249 B")]
33 public ValueOutput notEqual { get; private set; }
34
35 protected override void Definition()
36 {
37 a = ValueInput<float>(nameof(a));
38 b = ValueInput<float>(nameof(b), 0);
39 notEqual = ValueOutput(nameof(notEqual), Comparison).Predictable();
40
41 Requirement(a, notEqual);
42 Requirement(b, notEqual);
43 }
44
45 public bool Comparison(Flow flow)
46 {
47 return !Mathf.Approximately(flow.GetValue<float>(a), flow.GetValue<float>(b));
48 }
49 }
50}