mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-02 19:38:24 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
36 lines
787 B
C#
36 lines
787 B
C#
using System.Text.Json;
|
|
using System.Text.Json.Nodes;
|
|
|
|
namespace Sandbox;
|
|
|
|
public partial class Decal
|
|
{
|
|
public override int ComponentVersion => 3;
|
|
|
|
[Expose, JsonUpgrader( typeof( Decal ), 2 )]
|
|
public static void Upgrader_v2( JsonObject json )
|
|
{
|
|
if ( !json.ContainsKey( "ColorTint" ) ) return;
|
|
|
|
try
|
|
{
|
|
var color32 = json["ColorTint"].Deserialize<Color32>();
|
|
json["ColorTint"] = JsonSerializer.SerializeToNode( color32.ToColor() );
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
[Expose, JsonUpgrader( typeof( Decal ), 3 )]
|
|
public static void Upgrader_v3( JsonObject json )
|
|
{
|
|
if ( !json.ContainsKey( "ColorTint" ) ) return;
|
|
|
|
try
|
|
{
|
|
var color = json["ColorTint"].Deserialize<Color>();
|
|
json["ColorTint"] = JsonSerializer.SerializeToNode( (ParticleGradient)color );
|
|
}
|
|
catch { }
|
|
}
|
|
}
|