summaryrefslogtreecommitdiff
path: root/Other/NodeEditorExamples/Assets/xNode-examples/Examples/LogicToy/Nodes/NotNode.cs
blob: 1170757d81de3d4b465362c98d1252b7996cb18d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System.Linq;
using UnityEngine;

namespace XNode.Examples.LogicToy {
	[NodeWidth(140), NodeTint(100, 100, 50)]
	public class NotNode : LogicNode {
		[Input, HideInInspector] public bool input;
		[Output, HideInInspector] public bool output = true;
		public override bool led { get { return output; } }

		protected override void OnInputChanged() {
			bool newInput = GetPort("input").GetInputValues<bool>().Any(x => x);

			if (input != newInput) {
				input = newInput;
				output = !newInput;
				SendSignal(GetPort("output"));
			}
		}

		public override object GetValue(NodePort port) {
			return output;
		}
	}
}