first commit

This commit is contained in:
2025-07-06 00:23:46 +02:00
commit 38f50c8819
1788 changed files with 112878 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Serialization;
namespace NitroxServer.Serialization.Json;
public class AttributeContractResolver : DefaultContractResolver
{
//IDictionary to JsonArray
protected override JsonContract CreateContract(Type objectType)
{
if (objectType.GetInterfaces().Any(i => i == typeof(IDictionary) || i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IDictionary<,>)))
{
return base.CreateArrayContract(objectType);
}
return base.CreateContract(objectType);
}
}

View File

@@ -0,0 +1,19 @@
using System;
using Newtonsoft.Json;
using NitroxModel.DataStructures;
namespace NitroxServer.Serialization.Json
{
public class NitroxIdConverter : JsonConverter<NitroxId>
{
public override void WriteJson(JsonWriter writer, NitroxId value, JsonSerializer serializer)
{
writer.WriteValue(value.ToString());
}
public override NitroxId ReadJson(JsonReader reader, Type objectType, NitroxId existingValue, bool hasExistingValue, JsonSerializer serializer)
{
return reader.Value == null ? null : new NitroxId((string)reader.Value);
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Newtonsoft.Json;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxServer.Serialization.Json
{
public class TechTypeConverter : JsonConverter<NitroxTechType>
{
public override void WriteJson(JsonWriter writer, NitroxTechType value, JsonSerializer serializer)
{
writer.WriteValue(value.Name);
}
public override NitroxTechType ReadJson(JsonReader reader, Type objectType, NitroxTechType existingValue, bool hasExistingValue, JsonSerializer serializer)
{
return reader.Value == null ? null : new NitroxTechType((string)reader.Value);
}
}
}