Files
sbox-public/game/addons/tools/Code/ShaderGraph/NodeInput.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

45 lines
1.5 KiB
C#

using System.ComponentModel;
using System.Text.Json.Serialization;
namespace Editor.ShaderGraph;
public struct NodeInput : IValid
{
[Hide, Browsable( false )]
public string Identifier { get; set; }
[Hide, Browsable( false )]
public string Output { get; set; }
[Hide, Browsable( false )]
[JsonIgnore]
public string Subgraph { get; set; }
[Hide, Browsable( false )]
[JsonIgnore]
public string SubgraphNode { get; set; }
[Browsable( false )]
[JsonIgnore, Hide]
public readonly bool IsValid => !string.IsNullOrWhiteSpace( Identifier ) && !string.IsNullOrWhiteSpace( Output );
public override readonly string ToString()
{
var subgraph = (Subgraph is not null) ? ("." + Subgraph) : "";
var subgraphNode = (SubgraphNode is not null) ? ("." + SubgraphNode) : "";
return IsValid ? $"{Identifier}.{Output}{subgraph}{subgraphNode}" : "null";
}
public NodeInput()
{
Identifier = "";
Output = "";
Subgraph = null;
}
public static bool operator ==( NodeInput a, NodeInput b ) => a.Identifier == b.Identifier && a.Output == b.Output && a.Subgraph == b.Subgraph && a.SubgraphNode == b.SubgraphNode;
public static bool operator !=( NodeInput a, NodeInput b ) => a.Identifier != b.Identifier || a.Output != b.Output || a.Subgraph != b.Subgraph || a.SubgraphNode != b.SubgraphNode;
public override bool Equals( object obj ) => obj is NodeInput input && this == input;
public override int GetHashCode() => System.HashCode.Combine( Identifier, Output, Subgraph, SubgraphNode );
}