diff --git a/Editor/Inspectors/AttributedEnumInspector.cs b/Editor/Inspectors/AttributedEnumInspector.cs
new file mode 100644
index 0000000..0f095b4
--- /dev/null
+++ b/Editor/Inspectors/AttributedEnumInspector.cs
@@ -0,0 +1,84 @@
+// Visual Pinball Engine
+// Copyright (C) 2022 freezy and VPE Team
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Reflection;
+using Unity.VisualScripting;
+using UnityEditor;
+using UnityEngine;
+
+namespace VisualPinball.Unity.VisualScripting.Editor
+{
+ public abstract class AttributedEnumInspector : Inspector
+ {
+ private List Enums;
+ private string[] EnumDescriptions;
+
+ public AttributedEnumInspector(Metadata metadata) : base(metadata) {
+ }
+
+ public override void Initialize()
+ {
+ Enums = Enum.GetValues(typeof(TEnum)).Cast().ToList();
+ EnumDescriptions = Enum.GetValues(typeof(TEnum)).Cast().Select(x => GetEnumDescription(x)).ToArray();
+
+ metadata.instantiate = true;
+
+ base.Initialize();
+ }
+
+ protected override float GetHeight(float width, GUIContent label)
+ {
+ return HeightWithLabel(metadata, width, EditorGUIUtility.singleLineHeight, label);
+ }
+
+ protected override void OnGUI(Rect position, GUIContent label)
+ {
+ position = BeginLabeledBlock(metadata, position, label);
+
+ var fieldPosition = new Rect(
+ position.x,
+ position.y,
+ position.width,
+ EditorGUIUtility.singleLineHeight);
+
+ var index = Enums.FindIndex(c => c.Equals(metadata.value));
+ var newIndex = EditorGUI.Popup(fieldPosition, index, EnumDescriptions);
+
+ if (EndBlock(metadata)) {
+ metadata.RecordUndo();
+ metadata.value = Enums[newIndex];
+ }
+ }
+
+ public override float GetAdaptiveWidth()
+ {
+ return Mathf.Max(18, EditorStyles.popup.CalcSize(new GUIContent(GetEnumDescription((TEnum)metadata.value))).x);
+ }
+
+ private string GetEnumDescription(TEnum value)
+ {
+ FieldInfo field = value.GetType().GetField(value.ToString());
+
+ DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
+
+ return (attribute == null ? value.ToString() : attribute.Description).Replace('/', '\u2215');
+ }
+ }
+}
diff --git a/Editor/Inspectors/AttributedEnumInspector.cs.meta b/Editor/Inspectors/AttributedEnumInspector.cs.meta
new file mode 100644
index 0000000..7e911e0
--- /dev/null
+++ b/Editor/Inspectors/AttributedEnumInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c60df3d32f18d4d3e9019e2592b52ba9
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor/Inspectors/CompareTypeInspector.cs b/Editor/Inspectors/CompareTypeInspector.cs
new file mode 100644
index 0000000..0c51dba
--- /dev/null
+++ b/Editor/Inspectors/CompareTypeInspector.cs
@@ -0,0 +1,28 @@
+// Visual Pinball Engine
+// Copyright (C) 2022 freezy and VPE Team
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using Unity.VisualScripting;
+
+namespace VisualPinball.Unity.VisualScripting.Editor
+{
+ [Inspector(typeof(CompareType))]
+ public class CompareTypeInspector : AttributedEnumInspector
+ {
+ public CompareTypeInspector(Metadata metadata) : base(metadata)
+ {
+ }
+ }
+}
diff --git a/Editor/Inspectors/CompareTypeInspector.cs.meta b/Editor/Inspectors/CompareTypeInspector.cs.meta
new file mode 100644
index 0000000..995e733
--- /dev/null
+++ b/Editor/Inspectors/CompareTypeInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ac7985d65cfa449d389e96d71b1ac8da
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor/Inspectors/LampDataTypeInspector.cs b/Editor/Inspectors/LampDataTypeInspector.cs
new file mode 100644
index 0000000..0a7354f
--- /dev/null
+++ b/Editor/Inspectors/LampDataTypeInspector.cs
@@ -0,0 +1,28 @@
+// Visual Pinball Engine
+// Copyright (C) 2022 freezy and VPE Team
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using Unity.VisualScripting;
+
+namespace VisualPinball.Unity.VisualScripting.Editor
+{
+ [Inspector(typeof(LampDataType))]
+ public class LampDataTypeInspector : AttributedEnumInspector
+ {
+ public LampDataTypeInspector(Metadata metadata) : base(metadata)
+ {
+ }
+ }
+}
diff --git a/Editor/Inspectors/LampDataTypeInspector.cs.meta b/Editor/Inspectors/LampDataTypeInspector.cs.meta
new file mode 100644
index 0000000..e905d54
--- /dev/null
+++ b/Editor/Inspectors/LampDataTypeInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c3c891d4e51ab4d26aec2424438cc7d8
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Nodes/Lamps/LampDataType.cs b/Runtime/Nodes/Lamps/LampDataType.cs
index b58a93a..2349f6e 100644
--- a/Runtime/Nodes/Lamps/LampDataType.cs
+++ b/Runtime/Nodes/Lamps/LampDataType.cs
@@ -14,10 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+using System.ComponentModel;
+
namespace VisualPinball.Unity.VisualScripting
{
public enum LampDataType
{
- OnOff, Status, Intensity, Color,
+ [Description("On/Off")]
+ OnOff,
+
+ Status,
+ Intensity,
+ Color,
}
}
diff --git a/Runtime/Nodes/Lamps/SwitchLampUnit.cs b/Runtime/Nodes/Lamps/SwitchLampUnit.cs
index 3a24a60..d00d49c 100644
--- a/Runtime/Nodes/Lamps/SwitchLampUnit.cs
+++ b/Runtime/Nodes/Lamps/SwitchLampUnit.cs
@@ -37,6 +37,9 @@ public class SwitchLampUnit : GleUnit, IMultiInputUnit
[Serialize, Inspectable, UnitHeaderInspectable("Non Match")]
public LampDataType NonMatchDataType { get; set; }
+ [Serialize, Inspectable, UnitHeaderInspectable("Value Compare")]
+ public CompareType ValueCompareType { get; set; }
+
[DoNotSerialize]
[Inspectable, UnitHeaderInspectable("Lamp IDs")]
public int inputCount
@@ -134,8 +137,36 @@ private ControlOutput Process(Flow flow)
var lampIdValue = _lampIdValueCache[json.GetHashCode()];
- var dataType = lampIdValue.value == sourceValue ? MatchDataType : NonMatchDataType;
- var value = lampIdValue.value == sourceValue ? Match : NonMatch;
+ var match = false;
+
+ switch(ValueCompareType) {
+ case CompareType.NotEqual:
+ match = lampIdValue.value != sourceValue;
+ break;
+
+ case CompareType.GreaterThan:
+ match = lampIdValue.value > sourceValue;
+ break;
+
+ case CompareType.GreaterThanEqual:
+ match = lampIdValue.value >= sourceValue;
+ break;
+
+ case CompareType.LessThan:
+ match = lampIdValue.value < sourceValue;
+ break;
+
+ case CompareType.LessThanEqual:
+ match = lampIdValue.value <= sourceValue;
+ break;
+
+ default:
+ match = lampIdValue.value == sourceValue;
+ break;
+ }
+
+ var dataType = match ? MatchDataType : NonMatchDataType;
+ var value = match ? Match : NonMatch;
switch (dataType) {
case LampDataType.OnOff:
diff --git a/Runtime/Nodes/Logic.meta b/Runtime/Nodes/Logic.meta
new file mode 100644
index 0000000..621cc6d
--- /dev/null
+++ b/Runtime/Nodes/Logic.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 73192e7aa6c1d4d6fb9f28787a6dc0df
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Nodes/Logic/CompareType.cs b/Runtime/Nodes/Logic/CompareType.cs
new file mode 100644
index 0000000..3d74a33
--- /dev/null
+++ b/Runtime/Nodes/Logic/CompareType.cs
@@ -0,0 +1,41 @@
+// Visual Pinball Engine
+// Copyright (C) 2022 freezy and VPE Team
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using System.ComponentModel;
+
+namespace VisualPinball.Unity.VisualScripting
+{
+ public enum CompareType
+ {
+ [Description("=")]
+ Equal,
+
+ [Description("\u2260")]
+ NotEqual,
+
+ [Description("<")]
+ LessThan,
+
+ [Description("\u2264")]
+ LessThanEqual,
+
+ [Description(">")]
+ GreaterThan,
+
+ [Description("\u2265")]
+ GreaterThanEqual
+ }
+}
diff --git a/Runtime/Nodes/Logic/CompareType.cs.meta b/Runtime/Nodes/Logic/CompareType.cs.meta
new file mode 100644
index 0000000..34dd3df
--- /dev/null
+++ b/Runtime/Nodes/Logic/CompareType.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: db84bb9bc867b4f5ba03a14e54abc2ad
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: