mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 03:19:56 +00:00
Core - Fix node script and pin bugs found by the tests (#911)
* Core - Keep nodes of missing plugins and the connection an input reads from in node scripts - Saving a script keeps nodes whose plugin is missing, and their connections, so they come back once the plugin is available again - Loading keeps the first connection of an input, the one it reads from - Disabling a node provider only removes the nodes it created, not those of another provider registering the same type - RemoveNode only raises NodeRemoved for nodes that were in the script * Core - Fix pin connections, null values and failing nodes - Connecting pins that are already connected no longer adds a second connection - Untyped pins turn null into the default value for value types, as intended - A new InputPin<T> reads its connection right away instead of after its first reset - Matching a specific enum to a pin of any enum now depends on forgivingEnumMatching - A node that fails to evaluate sets its outputs to their default values, so it is evaluated once per run and old values don't flow on * Core - Round Numeric to long and clamp it to the range of an sbyte
This commit is contained in:
1 parent
83cf6da830
commit
5ddd50b4a8
12 files changed
+118
-92
No files matched your search
@@ -85,9 +85,19 @@ public abstract class Pin : CorePropertyChanged, IPin
|
||||
IsEvaluated = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of an output pin to the default value of its type, used when its node fails to evaluate
|
||||
/// </summary>
|
||||
internal virtual void SetDefaultValue()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ConnectTo(IPin pin)
|
||||
{
|
||||
if (_connectedTo.Contains(pin))
|
||||
return;
|
||||
|
||||
_connectedTo.Add(pin);
|
||||
if (!pin.ConnectedTo.Contains(this))
|
||||
pin.ConnectTo(this);
|
||||
@@ -129,11 +139,15 @@ public abstract class Pin : CorePropertyChanged, IPin
|
||||
/// <inheritdoc />
|
||||
public bool IsTypeCompatible(Type type, bool forgivingEnumMatching = true)
|
||||
{
|
||||
return Type == type
|
||||
|| (Direction == PinDirection.Input && type.IsAssignableTo(Type))
|
||||
|| (Direction == PinDirection.Output && type.IsAssignableFrom(Type))
|
||||
|| (Direction == PinDirection.Input && Type == typeof(Enum) && type.IsEnum && forgivingEnumMatching)
|
||||
|| (Direction == PinDirection.Output && type == typeof(Enum) && Type.IsEnum && forgivingEnumMatching);
|
||||
if (Type == type)
|
||||
return true;
|
||||
|
||||
// A specific enum and a pin of any enum only match when forgiving, every enum is assignable to Enum otherwise
|
||||
if ((Direction == PinDirection.Input && Type == typeof(Enum) && type.IsEnum) || (Direction == PinDirection.Output && type == typeof(Enum) && Type.IsEnum))
|
||||
return forgivingEnumMatching;
|
||||
|
||||
return (Direction == PinDirection.Input && type.IsAssignableTo(Type))
|
||||
|| (Direction == PinDirection.Output && type.IsAssignableFrom(Type));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user