move used checks to interface

This commit is contained in:
xxSeys1
2024-10-24 23:24:28 +02:00
parent 6b4b85b113
commit 57b4e9f295
3 changed files with 38 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ using FlaxEditor.Scripting;
using FlaxEditor.Surface.Elements;
using FlaxEngine;
using FlaxEngine.Utilities;
using System.Linq;
namespace FlaxEditor.Surface.Archetypes
{
@@ -425,6 +426,20 @@ namespace FlaxEditor.Surface.Archetypes
UpdateCombo();
}
/// <inheritdoc />
public bool IsParameterReferenced(SurfaceParameter param, VisjectSurface surface)
{
for (int i = 0; i < surface.Nodes.Count; i++)
{
if (surface.Nodes[i] is IParametersDependantNode node)
{
return (Guid)surface.Nodes[i].Values[0] == param.ID && surface.Nodes[i].GetBoxes().Any(b => b.Connections.Count > 0);
}
}
return false;
}
/// <inheritdoc />
public override void OnLoaded(SurfaceNodeActions action)
{
@@ -942,6 +957,20 @@ namespace FlaxEditor.Surface.Archetypes
UpdateCombo();
}
/// <inheritdoc />
public bool IsParameterReferenced(SurfaceParameter param, VisjectSurface surface)
{
for (int i = 0; i < surface.Nodes.Count; i++)
{
if (surface.Nodes[i] is IParametersDependantNode node)
{
return (Guid)surface.Nodes[i].Values[0] == param.ID && surface.Nodes[i].GetBoxes().Any(b => b.Connections.Count > 0);
}
}
return false;
}
/// <inheritdoc />
public override void OnLoaded(SurfaceNodeActions action)
{

View File

@@ -33,5 +33,13 @@ namespace FlaxEditor.Surface
/// </summary>
/// <param name="param">The parameter.</param>
void OnParamDeleted(SurfaceParameter param);
/// <summary>
/// Get if the parameter is referenced in a graph. Referenced in this case means in a graph and at least one node in-/output connected to another node.
/// </summary>
/// <param name="param">The parameter.</param>
/// /// <param name="surface">The visject surface.</param>
/// <returns>How often the parameter is referenced.</returns>
bool IsParameterReferenced(SurfaceParameter param, VisjectSurface surface);
}
}

View File

@@ -788,7 +788,7 @@ namespace FlaxEditor.Surface
{
if (nodes[i] is IParametersDependantNode node)
{
if (displayWarning && (Guid)nodes[i].Values[0] == param.ID && nodes[i].GetBoxes().Any(b => b.Connections.Count > 0))
if (displayWarning && node.IsParameterReferenced(param, window.VisjectSurface))
connectedParameterNodeCount++;
}
}