mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 05:48:07 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
45 lines
1.5 KiB
C#
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 );
|
|
}
|