mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Event condition - Added toggle off mode
Profile editor - Added element copy/pasting Shared UI - Fix namespaces
This commit is contained in:
1 parent
8c7bbc3f0f
commit
52f2338154
84 files changed
+1059
-608
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Branching;
|
||||
|
||||
[Node("Branch", "Forwards one of two values depending on an input boolean", "Branching", InputType = typeof(object), OutputType = typeof(object))]
|
||||
public class BooleanBranchNode : Node
|
||||
{
|
||||
public BooleanBranchNode() : base("Branch", "Forwards one of two values depending on an input boolean")
|
||||
{
|
||||
BooleanInput = CreateInputPin<bool>();
|
||||
TrueInput = CreateInputPin(typeof(object), "True");
|
||||
FalseInput = CreateInputPin(typeof(object), "False");
|
||||
|
||||
Output = CreateOutputPin(typeof(object));
|
||||
|
||||
TrueInput.PinConnected += InputPinConnected;
|
||||
FalseInput.PinConnected += InputPinConnected;
|
||||
TrueInput.PinDisconnected += InputPinDisconnected;
|
||||
FalseInput.PinDisconnected += InputPinDisconnected;
|
||||
}
|
||||
|
||||
private void InputPinConnected(object? sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
if (TrueInput.ConnectedTo.Any() && !FalseInput.ConnectedTo.Any())
|
||||
ChangeType(TrueInput.ConnectedTo.First().Type);
|
||||
if (FalseInput.ConnectedTo.Any() && !TrueInput.ConnectedTo.Any())
|
||||
ChangeType(FalseInput.ConnectedTo.First().Type);
|
||||
}
|
||||
|
||||
private void InputPinDisconnected(object? sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
if (!TrueInput.ConnectedTo.Any() && !FalseInput.ConnectedTo.Any())
|
||||
ChangeType(typeof(object));
|
||||
}
|
||||
|
||||
private void ChangeType(Type type)
|
||||
{
|
||||
TrueInput.ChangeType(type);
|
||||
FalseInput.ChangeType(type);
|
||||
Output.ChangeType(type);
|
||||
}
|
||||
|
||||
public InputPin<bool> BooleanInput { get; set; }
|
||||
public InputPin TrueInput { get; set; }
|
||||
public InputPin FalseInput { get; set; }
|
||||
|
||||
public OutputPin Output { get; set; }
|
||||
|
||||
#region Overrides of Node
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = BooleanInput.Value ? TrueInput.Value : FalseInput.Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user