From bb96f2cd6d71b7875041bca3c7f1a919bded64ea Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 3 Aug 2023 14:53:02 +0200 Subject: [PATCH] Add `GroupArchetype` to Visject nodes spawn query check --- Source/Editor/Surface/AnimGraphSurface.cs | 6 +++--- Source/Editor/Surface/AnimationGraphFunctionSurface.cs | 4 ++-- Source/Editor/Surface/ContextMenu/VisjectCM.cs | 5 +++-- Source/Editor/Surface/MaterialFunctionSurface.cs | 4 ++-- Source/Editor/Surface/MaterialSurface.cs | 4 ++-- Source/Editor/Surface/ParticleEmitterFunctionSurface.cs | 4 ++-- Source/Editor/Surface/ParticleEmitterSurface.cs | 4 ++-- Source/Editor/Surface/VisjectSurface.CopyPaste.cs | 2 +- Source/Editor/Surface/VisjectSurface.cs | 3 ++- Source/Editor/Surface/VisjectSurfaceContext.cs | 2 +- Source/Editor/Surface/VisualScriptSurface.cs | 4 ++-- 11 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Source/Editor/Surface/AnimGraphSurface.cs b/Source/Editor/Surface/AnimGraphSurface.cs index 162b82270..3cc07813c 100644 --- a/Source/Editor/Surface/AnimGraphSurface.cs +++ b/Source/Editor/Surface/AnimGraphSurface.cs @@ -345,7 +345,7 @@ namespace FlaxEditor.Surface _cmStateMachineMenu = new VisjectCM(new VisjectCM.InitInfo { Groups = StateMachineGroupArchetypes, - CanSpawnNode = arch => true, + CanSpawnNode = (_, _) => true, }); _cmStateMachineMenu.ShowExpanded = true; } @@ -406,9 +406,9 @@ namespace FlaxEditor.Surface } /// - public override bool CanUseNodeType(NodeArchetype nodeArchetype) + public override bool CanUseNodeType(GroupArchetype groupArchetype, NodeArchetype nodeArchetype) { - return (nodeArchetype.Flags & NodeFlags.AnimGraph) != 0 && base.CanUseNodeType(nodeArchetype); + return (nodeArchetype.Flags & NodeFlags.AnimGraph) != 0 && base.CanUseNodeType(groupArchetype, nodeArchetype); } /// diff --git a/Source/Editor/Surface/AnimationGraphFunctionSurface.cs b/Source/Editor/Surface/AnimationGraphFunctionSurface.cs index fa6619e1d..d5d4ae132 100644 --- a/Source/Editor/Surface/AnimationGraphFunctionSurface.cs +++ b/Source/Editor/Surface/AnimationGraphFunctionSurface.cs @@ -35,7 +35,7 @@ namespace FlaxEditor.Surface } /// - public override bool CanUseNodeType(NodeArchetype nodeArchetype) + public override bool CanUseNodeType(GroupArchetype groupArchetype, NodeArchetype nodeArchetype) { if (nodeArchetype.Title == "Function Input") return true; @@ -44,7 +44,7 @@ namespace FlaxEditor.Surface if (Context == RootContext && nodeArchetype.Title == "Function Output") return true; - return base.CanUseNodeType(nodeArchetype); + return base.CanUseNodeType(groupArchetype, nodeArchetype); } /// diff --git a/Source/Editor/Surface/ContextMenu/VisjectCM.cs b/Source/Editor/Surface/ContextMenu/VisjectCM.cs index bae62556e..d293d82f3 100644 --- a/Source/Editor/Surface/ContextMenu/VisjectCM.cs +++ b/Source/Editor/Surface/ContextMenu/VisjectCM.cs @@ -29,9 +29,10 @@ namespace FlaxEditor.Surface.ContextMenu /// /// Visject Surface node archetype spawn ability checking delegate. /// + /// The nodes group archetype to check. /// The node archetype to check. /// True if can use this node to spawn it on a surface, otherwise false.. - public delegate bool NodeSpawnCheckDelegate(NodeArchetype arch); + public delegate bool NodeSpawnCheckDelegate(GroupArchetype groupArch, NodeArchetype arch); /// /// Visject Surface parameters getter delegate. @@ -184,7 +185,7 @@ namespace FlaxEditor.Surface.ContextMenu nodes.Clear(); foreach (var nodeArchetype in groupArchetype.Archetypes) { - if ((nodeArchetype.Flags & NodeFlags.NoSpawnViaGUI) == 0 && info.CanSpawnNode(nodeArchetype)) + if ((nodeArchetype.Flags & NodeFlags.NoSpawnViaGUI) == 0 && info.CanSpawnNode(groupArchetype, nodeArchetype)) { nodes.Add(nodeArchetype); } diff --git a/Source/Editor/Surface/MaterialFunctionSurface.cs b/Source/Editor/Surface/MaterialFunctionSurface.cs index 1f820d3a7..000ff16fd 100644 --- a/Source/Editor/Surface/MaterialFunctionSurface.cs +++ b/Source/Editor/Surface/MaterialFunctionSurface.cs @@ -36,13 +36,13 @@ namespace FlaxEditor.Surface } /// - public override bool CanUseNodeType(NodeArchetype nodeArchetype) + public override bool CanUseNodeType(GroupArchetype groupArchetype, NodeArchetype nodeArchetype) { if (nodeArchetype.Title == "Function Input" || nodeArchetype.Title == "Function Output") return true; - return base.CanUseNodeType(nodeArchetype); + return base.CanUseNodeType(groupArchetype, nodeArchetype); } /// diff --git a/Source/Editor/Surface/MaterialSurface.cs b/Source/Editor/Surface/MaterialSurface.cs index 2fa44f6c6..08e1161d9 100644 --- a/Source/Editor/Surface/MaterialSurface.cs +++ b/Source/Editor/Surface/MaterialSurface.cs @@ -33,9 +33,9 @@ namespace FlaxEditor.Surface } /// - public override bool CanUseNodeType(NodeArchetype nodeArchetype) + public override bool CanUseNodeType(GroupArchetype groupArchetype, NodeArchetype nodeArchetype) { - return (nodeArchetype.Flags & NodeFlags.MaterialGraph) != 0 && base.CanUseNodeType(nodeArchetype); + return (nodeArchetype.Flags & NodeFlags.MaterialGraph) != 0 && base.CanUseNodeType(groupArchetype, nodeArchetype); } /// diff --git a/Source/Editor/Surface/ParticleEmitterFunctionSurface.cs b/Source/Editor/Surface/ParticleEmitterFunctionSurface.cs index a1880c3a8..452905409 100644 --- a/Source/Editor/Surface/ParticleEmitterFunctionSurface.cs +++ b/Source/Editor/Surface/ParticleEmitterFunctionSurface.cs @@ -35,13 +35,13 @@ namespace FlaxEditor.Surface } /// - public override bool CanUseNodeType(NodeArchetype nodeArchetype) + public override bool CanUseNodeType(GroupArchetype groupArchetype, NodeArchetype nodeArchetype) { if (nodeArchetype.Title == "Function Input" || nodeArchetype.Title == "Function Output") return true; - return base.CanUseNodeType(nodeArchetype); + return base.CanUseNodeType(groupArchetype, nodeArchetype); } /// diff --git a/Source/Editor/Surface/ParticleEmitterSurface.cs b/Source/Editor/Surface/ParticleEmitterSurface.cs index 99ed61f8e..76f96f06c 100644 --- a/Source/Editor/Surface/ParticleEmitterSurface.cs +++ b/Source/Editor/Surface/ParticleEmitterSurface.cs @@ -87,9 +87,9 @@ namespace FlaxEditor.Surface } /// - public override bool CanUseNodeType(NodeArchetype nodeArchetype) + public override bool CanUseNodeType(GroupArchetype groupArchetype, NodeArchetype nodeArchetype) { - return (nodeArchetype.Flags & NodeFlags.ParticleEmitterGraph) != 0 && base.CanUseNodeType(nodeArchetype); + return (nodeArchetype.Flags & NodeFlags.ParticleEmitterGraph) != 0 && base.CanUseNodeType(groupArchetype, nodeArchetype); } /// diff --git a/Source/Editor/Surface/VisjectSurface.CopyPaste.cs b/Source/Editor/Surface/VisjectSurface.CopyPaste.cs index 3a5be4857..f9e37dc20 100644 --- a/Source/Editor/Surface/VisjectSurface.CopyPaste.cs +++ b/Source/Editor/Surface/VisjectSurface.CopyPaste.cs @@ -254,7 +254,7 @@ namespace FlaxEditor.Surface throw new InvalidOperationException("Unknown node type."); // Validate given node type - if (!CanUseNodeType(nodeArchetype)) + if (!CanUseNodeType(groupArchetype, nodeArchetype)) continue; // Create diff --git a/Source/Editor/Surface/VisjectSurface.cs b/Source/Editor/Surface/VisjectSurface.cs index 22aba4855..03e32cb29 100644 --- a/Source/Editor/Surface/VisjectSurface.cs +++ b/Source/Editor/Surface/VisjectSurface.cs @@ -520,9 +520,10 @@ namespace FlaxEditor.Surface /// /// Determines whether the specified node archetype can be used in the surface. /// + /// The nodes group archetype. /// The node archetype. /// True if can use this node archetype, otherwise false. - public virtual bool CanUseNodeType(NodeArchetype nodeArchetype) + public virtual bool CanUseNodeType(GroupArchetype groupArchetype, NodeArchetype nodeArchetype) { return (nodeArchetype.Flags & NodeFlags.NoSpawnViaPaste) == 0; } diff --git a/Source/Editor/Surface/VisjectSurfaceContext.cs b/Source/Editor/Surface/VisjectSurfaceContext.cs index 8393d6162..0a4b59412 100644 --- a/Source/Editor/Surface/VisjectSurfaceContext.cs +++ b/Source/Editor/Surface/VisjectSurfaceContext.cs @@ -361,7 +361,7 @@ namespace FlaxEditor.Surface var flags = nodeArchetype.Flags; nodeArchetype.Flags &= ~NodeFlags.NoSpawnViaGUI; nodeArchetype.Flags &= ~NodeFlags.NoSpawnViaPaste; - if (_surface != null && !_surface.CanUseNodeType(nodeArchetype)) + if (_surface != null && !_surface.CanUseNodeType(groupArchetype, nodeArchetype)) { nodeArchetype.Flags = flags; Editor.LogWarning("Cannot spawn given node type. Title: " + nodeArchetype.Title); diff --git a/Source/Editor/Surface/VisualScriptSurface.cs b/Source/Editor/Surface/VisualScriptSurface.cs index e961f686d..2cb82b351 100644 --- a/Source/Editor/Surface/VisualScriptSurface.cs +++ b/Source/Editor/Surface/VisualScriptSurface.cs @@ -532,9 +532,9 @@ namespace FlaxEditor.Surface public override bool CanSetParameters => true; /// - public override bool CanUseNodeType(NodeArchetype nodeArchetype) + public override bool CanUseNodeType(GroupArchetype groupArchetype, NodeArchetype nodeArchetype) { - return (nodeArchetype.Flags & NodeFlags.VisualScriptGraph) != 0 && base.CanUseNodeType(nodeArchetype); + return (nodeArchetype.Flags & NodeFlags.VisualScriptGraph) != 0 && base.CanUseNodeType(groupArchetype, nodeArchetype); } ///