// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
namespace FlaxEditor.Surface
{
public partial class VisjectSurface
{
///
/// The collection of the surface parameters.
///
/// From the root context only.
public List Parameters => RootContext.Parameters;
///
/// Gets the parameter by the given ID.
///
/// From the root context only.
/// The identifier.
/// Found parameter instance or null if missing.
public SurfaceParameter GetParameter(Guid id)
{
return RootContext.GetParameter(id);
}
///
/// Gets the parameter by the given name.
///
/// From the root context only.
/// The name.
/// Found parameter instance or null if missing.
public SurfaceParameter GetParameter(string name)
{
return RootContext.GetParameter(name);
}
///
public void OnParamReordered()
{
MarkAsEdited();
}
///
public void OnParamCreated(SurfaceParameter param)
{
for (int i = 0; i < Nodes.Count; i++)
{
if (Nodes[i] is IParametersDependantNode node)
node.OnParamCreated(param);
}
MarkAsEdited();
}
///
public void OnParamRenamed(SurfaceParameter param)
{
for (int i = 0; i < Nodes.Count; i++)
{
if (Nodes[i] is IParametersDependantNode node)
node.OnParamRenamed(param);
}
MarkAsEdited();
}
///
public void OnParamEdited(SurfaceParameter param)
{
for (int i = 0; i < Nodes.Count; i++)
{
if (Nodes[i] is IParametersDependantNode node)
node.OnParamEdited(param);
}
MarkAsEdited();
}
///
public void OnParamDeleted(SurfaceParameter param)
{
for (int i = 0; i < Nodes.Count; i++)
{
if (Nodes[i] is IParametersDependantNode node)
node.OnParamDeleted(param);
}
MarkAsEdited();
}
///
public bool IsParamUsed(SurfaceParameter param)
{
for (int i = 0; i < Nodes.Count; i++)
{
if (Nodes[i] is IParametersDependantNode node && node.IsParamUsed(param))
return true;
}
return false;
}
}
}