Delete the in-tree cache, JsonKnownTypes and vendored MessagePack

Cut 8b, deletes first. The old authorities are removed, not demoted:
- ServerShared/CultCache: CultCache.cs, DatabaseEntry.cs (root [Union],
  DatabaseLink, INamedEntry), RegisterResolver.cs, TypeFormatterResolver.cs,
  JsonConverters.cs, JsonKnownTypes/**.
- Assets/Plugins/MessagePack/** and System.Runtime.CompilerServices.Unsafe.dll
  (org.gamecult.cultlib ships both).
- GalaxyMapLayerData, PlayerData, GlobalSettingsAttribute.
- The inspector attributes CultLib already carries or nothing reads.

Kept and moved: MathFormatters.cs and MathResolver.cs to
ServerShared/Serialization; GetAllChildClasses, SplitCamelCase,
FormatTypeName, MaxBy and MinBy to Extensions.cs; Inspectable,
PreferredInspectorAttribute and the five Aetheria drawer attributes to
ServerShared/Attributes.cs. Aetheria.Shared.csproj drops the vendored
MessagePack include and the Unsafe package; the asmdef drops MessagePack.

Does not build: the data model moves onto CultLib in the next commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-14 18:42:09 +02:00
commit b4c06b50cb
266 changed files with 67 additions and 33150 deletions

View file

@ -0,0 +1,226 @@
using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using CultMath;
using static CultMath.math;
public class Float2Formatter : MessagePack.Formatters.IMessagePackFormatter<float2>
{
public void Serialize(ref MessagePackWriter writer, float2 value, MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(2);
writer.Write(value.x);
writer.Write(value.y);
}
public float2 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
if (reader.IsNil)
{
throw new InvalidOperationException("typecode is null, struct not supported");
}
var length = reader.ReadArrayHeader();
var x = default(float);
var y = default(float);
for (int i = 0; i < length; i++)
{
var key = i;
switch (key)
{
case 0:
x = reader.ReadSingle();
break;
case 1:
y = reader.ReadSingle();
break;
default:
reader.Skip();
break;
}
}
var result = float2(x, y);
return result;
}
}
public class Int2Formatter : MessagePack.Formatters.IMessagePackFormatter<int2>
{
public void Serialize(ref MessagePackWriter writer, int2 value, MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(2);
writer.Write(value.x);
writer.Write(value.y);
}
public int2 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
if (reader.IsNil)
{
throw new InvalidOperationException("typecode is null, struct not supported");
}
var length = reader.ReadArrayHeader();
var x = default(int);
var y = default(int);
for (int i = 0; i < length; i++)
{
var key = i;
switch (key)
{
case 0:
x = reader.ReadInt32();
break;
case 1:
y = reader.ReadInt32();
break;
default:
reader.Skip();
break;
}
}
var result = int2(x, y);
return result;
}
}
public class Bool2Formatter : MessagePack.Formatters.IMessagePackFormatter<bool2>
{
public void Serialize(ref MessagePackWriter writer, bool2 value, MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(2);
writer.Write(value.x);
writer.Write(value.y);
}
public bool2 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
if (reader.IsNil)
{
throw new InvalidOperationException("typecode is null, struct not supported");
}
var length = reader.ReadArrayHeader();
var x = default(bool);
var y = default(bool);
for (int i = 0; i < length; i++)
{
var key = i;
switch (key)
{
case 0:
x = reader.ReadBoolean();
break;
case 1:
y = reader.ReadBoolean();
break;
default:
reader.Skip();
break;
}
}
var result = bool2(x, y);
return result;
}
}
public class Float3Formatter : MessagePack.Formatters.IMessagePackFormatter<float3>
{
public void Serialize(ref MessagePackWriter writer, float3 value, MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(3);
writer.Write(value.x);
writer.Write(value.y);
writer.Write(value.z);
}
public float3 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
if (reader.IsNil)
{
throw new InvalidOperationException("typecode is null, struct not supported");
}
var length = reader.ReadArrayHeader();
var x = default(float);
var y = default(float);
var z = default(float);
for (int i = 0; i < length; i++)
{
var key = i;
switch (key)
{
case 0:
x = reader.ReadSingle();
break;
case 1:
y = reader.ReadSingle();
break;
case 2:
z = reader.ReadSingle();
break;
default:
reader.Skip();
break;
}
}
var result = float3(x, y, z);
return result;
}
}
public class Float4Formatter : MessagePack.Formatters.IMessagePackFormatter<float4>
{
public void Serialize(ref MessagePackWriter writer, float4 value, MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(4);
writer.Write(value.x);
writer.Write(value.y);
writer.Write(value.z);
writer.Write(value.w);
}
public float4 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
if (reader.IsNil)
{
throw new InvalidOperationException("typecode is null, struct not supported");
}
var length = reader.ReadArrayHeader();
var x = default(float);
var y = default(float);
var z = default(float);
var w = default(float);
for (int i = 0; i < length; i++)
{
var key = i;
switch (key)
{
case 0:
x = reader.ReadSingle();
break;
case 1:
y = reader.ReadSingle();
break;
case 2:
z = reader.ReadSingle();
break;
case 3:
w = reader.ReadSingle();
break;
default:
reader.Skip();
break;
}
}
var result = float4(x, y, z, w);
return result;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 02bc8e83a7f1cf54d94ebebcd3272a0d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,80 @@
using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using MessagePack.Formatters;
using CultMath;
using static CultMath.math;
public class MathResolver : IFormatterResolver
{
public static readonly MathResolver Instance = new MathResolver();
private MathResolver()
{
}
public IMessagePackFormatter<T> GetFormatter<T>()
{
return FormatterCache<T>.Formatter;
}
private static class FormatterCache<T>
{
public static readonly IMessagePackFormatter<T> Formatter;
static FormatterCache()
{
Formatter = (IMessagePackFormatter<T>)MathResolverResolverGetFormatterHelper.GetFormatter(typeof(T));
}
}
}
internal static class MathResolverResolverGetFormatterHelper
{
private static readonly Dictionary<Type, object> FormatterMap = new Dictionary<Type, object>()
{
// standard
{ typeof(float2), new Float2Formatter() },
{ typeof(int2), new Int2Formatter() },
{ typeof(bool2), new Bool2Formatter() },
{ typeof(float3), new Float3Formatter() },
{ typeof(float4), new Float4Formatter() },
{ typeof(float2?), new StaticNullableFormatter<float2>(new Float2Formatter()) },
{ typeof(int2?), new StaticNullableFormatter<int2>(new Int2Formatter()) },
{ typeof(float3?), new StaticNullableFormatter<float3>(new Float3Formatter()) },
{ typeof(float4?), new StaticNullableFormatter<float4>(new Float4Formatter()) },
// standard + array
{ typeof(float2[]), new ArrayFormatter<float2>() },
{ typeof(int2[]), new ArrayFormatter<int2>() },
{ typeof(float3[]), new ArrayFormatter<float3>() },
{ typeof(float4[]), new ArrayFormatter<float4>() },
{ typeof(float2?[]), new ArrayFormatter<float2?>() },
{ typeof(int2?[]), new ArrayFormatter<int2?>() },
{ typeof(float3?[]), new ArrayFormatter<float3?>() },
{ typeof(float4?[]), new ArrayFormatter<float4?>() },
// standard + list
{ typeof(List<float2>), new ListFormatter<float2>() },
{ typeof(List<int2>), new ListFormatter<int2>() },
{ typeof(List<float3>), new ListFormatter<float3>() },
{ typeof(List<float4>), new ListFormatter<float4>() },
{ typeof(List<float2?>), new ListFormatter<float2?>() },
{ typeof(List<int2?>), new ListFormatter<int2?>() },
{ typeof(List<float3?>), new ListFormatter<float3?>() },
{ typeof(List<float4?>), new ListFormatter<float4?>() },
};
internal static object GetFormatter(Type t)
{
object formatter;
if (FormatterMap.TryGetValue(t, out formatter))
{
return formatter;
}
return null;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 80366c67f842eaf4dba339ed553e447c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: