Slime Stuff & DB Prep
Put the finishing touches on the microfauna Prepared the repository for database extraction
This commit is contained in:
parent
ad499a09ac
commit
48759380c5
773 changed files with 5278 additions and 805 deletions
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.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<float2?>() },
|
||||
{ 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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue