mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System.Collections;
|
|
using Artemis.Core;
|
|
|
|
namespace Artemis.VisualScripting.Nodes.Operators;
|
|
|
|
[Node("Greater than", "Checks if the first input is greater than the second.", "Operators", InputType = typeof(object), OutputType = typeof(bool))]
|
|
public class GreaterThanNode : Node
|
|
{
|
|
#region Constructors
|
|
|
|
public GreaterThanNode()
|
|
{
|
|
Input1 = CreateInputPin<object>();
|
|
Input2 = CreateInputPin<object>();
|
|
Result = CreateOutputPin<bool>();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
public override void Evaluate()
|
|
{
|
|
if (Input1.Value is Numeric numeric1 && Input2.Value is Numeric numeric2)
|
|
{
|
|
Result.Value = numeric1 > numeric2;
|
|
return;
|
|
}
|
|
|
|
if (Input2.Value != null && Input1.Value != null && Input1.Value.IsNumber() && Input2.Value.IsNumber())
|
|
{
|
|
Result.Value = Convert.ToSingle(Input1.Value) > Convert.ToSingle(Input2.Value);
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
Result.Value = Comparer.DefaultInvariant.Compare(Input1.Value, Input2.Value) == 1;
|
|
}
|
|
catch
|
|
{
|
|
Result.Value = false;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties & Fields
|
|
|
|
public InputPin<object> Input1 { get; }
|
|
public InputPin<object> Input2 { get; }
|
|
|
|
public OutputPin<bool> Result { get; }
|
|
|
|
#endregion
|
|
} |