using System;
using UnityEngine;
namespace Unity.VisualScripting
{
///
/// Compares two numbers to determine if they are approximately equal (disregarding floating point precision errors).
///
[UnitCategory("Logic")]
[UnitShortTitle("Equal")]
[UnitSubtitle("(Approximately)")]
[UnitOrder(7)]
[Obsolete("Use the Equal node with Numeric enabled instead.")]
public sealed class ApproximatelyEqual : Unit
{
///
/// The first number.
///
[DoNotSerialize]
public ValueInput a { get; private set; }
///
/// The second number.
///
[DoNotSerialize]
public ValueInput b { get; private set; }
///
/// Whether A is approximately equal to B.
///
[DoNotSerialize]
[PortLabel("A \u2248 B")]
public ValueOutput equal { get; private set; }
protected override void Definition()
{
a = ValueInput(nameof(a));
b = ValueInput(nameof(b), 0);
equal = ValueOutput(nameof(equal), Comparison).Predictable();
Requirement(a, equal);
Requirement(b, equal);
}
public bool Comparison(Flow flow)
{
return Mathf.Approximately(flow.GetValue(a), flow.GetValue(b));
}
}
}