mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Visual Scripting - Fixed storage issues where connections would be lost
Visual Scripting - Added node duplication
This commit is contained in:
1 parent
c325a29cc0
commit
041ed8e0a0
11 files changed
+256
-60
No files matched your search
@@ -264,11 +264,23 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
// Only connect the nodes if they aren't already connected (LoadConnections may be called twice or more)
|
||||
if (!targetPin.ConnectedTo.Contains(sourcePin) && targetPin.IsTypeCompatible(sourcePin.Type))
|
||||
// Type checking is done later when all connections are in place
|
||||
if (!targetPin.ConnectedTo.Contains(sourcePin))
|
||||
targetPin.ConnectTo(sourcePin);
|
||||
if (!sourcePin.ConnectedTo.Contains(targetPin) && sourcePin.IsTypeCompatible(targetPin.Type))
|
||||
if (!sourcePin.ConnectedTo.Contains(targetPin))
|
||||
sourcePin.ConnectTo(targetPin);
|
||||
}
|
||||
|
||||
// With all connections restored, ensure types match (connecting pins may affect types so the check is done afterwards)
|
||||
foreach (INode node in nodes)
|
||||
{
|
||||
foreach (IPin nodePin in node.Pins.Concat(node.PinCollections.SelectMany(p => p)))
|
||||
{
|
||||
List<IPin> toDisconnect = nodePin.ConnectedTo.Where(c => !c.IsTypeCompatible(nodePin.Type)).ToList();
|
||||
foreach (IPin pin in toDisconnect)
|
||||
pin.DisconnectFrom(nodePin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -129,6 +129,7 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public bool IsTypeCompatible(Type type) => Type == type
|
||||
|| Type == typeof(Enum) && type.IsEnum
|
||||
|| Type.IsEnum && type == typeof(Enum)
|
||||
|| Direction == PinDirection.Input && Type == typeof(object)
|
||||
|| Direction == PinDirection.Output && type == typeof(object);
|
||||
|
||||
|
||||
Reference in new issue
Block a user