using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HG.GeneralSerializer;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using R2API.AutoVersionGen;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("R2API.StringSerializerExtensions")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("R2API.StringSerializerExtensions")]
[assembly: AssemblyTitle("R2API.StringSerializerExtensions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class IsReadOnlyAttribute : Attribute
{
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class AllowNullAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class DisallowNullAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class DoesNotReturnAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class DoesNotReturnIfAttribute : Attribute
{
public bool ParameterValue { get; }
public DoesNotReturnIfAttribute(bool parameterValue)
{
ParameterValue = parameterValue;
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class MaybeNullAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class MaybeNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public MaybeNullWhenAttribute(bool returnValue)
{
ReturnValue = returnValue;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class NotNullAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class NotNullIfNotNullAttribute : Attribute
{
public string ParameterName { get; }
public NotNullIfNotNullAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class NotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public NotNullWhenAttribute(bool returnValue)
{
ReturnValue = returnValue;
}
}
}
namespace R2API
{
[AutoVersion]
public static class StringSerializerExtensions
{
private struct EnumJSONIntermediate
{
public string assemblyQualifiedName;
public string values;
public static Enum ToEnum(in EnumJSONIntermediate intermediate)
{
return (Enum)Enum.Parse(Type.GetType(intermediate.assemblyQualifiedName), intermediate.values);
}
public static EnumJSONIntermediate ToJSON(Enum @enum)
{
EnumJSONIntermediate result = default(EnumJSONIntermediate);
result.assemblyQualifiedName = @enum.GetType().AssemblyQualifiedName;
result.values = @enum.ToString();
return result;
}
}
internal const string PluginGUID = "com.bepis.r2api.extendedStringSerializer";
internal const string PluginName = "R2API.ExtendedStringSerializer";
private static readonly SerializationHandler _enumTypeHandler;
private static Hook _canSerializeTypeHook;
private static Hook _deserializeHook;
private static Hook _serializeHook;
public const string PluginVersion = "1.0.0";
private static CultureInfo Invariant => CultureInfo.InvariantCulture;
private static bool AllowEnumSerialization(Func<Type, bool> orig, Type type)
{
if (!orig(type))
{
return type.IsEnum;
}
return true;
}
private static object HandleEnumDeserialization(Func<Type, string, object> orig, Type type, string str)
{
object obj = orig(type, str);
if (obj == null)
{
if (!type.IsEnum)
{
return null;
}
obj = _enumTypeHandler.deserializer.Invoke(str);
}
return obj;
}
private static string HandleEnumSerialization(Func<Type, object, string> orig, Type type, object value)
{
string text = orig(type, value);
if (text == null)
{
if (!type.IsEnum)
{
return null;
}
text = _enumTypeHandler.serializer.Invoke(value);
}
return text;
}
internal static void ApplyHooks()
{
_canSerializeTypeHook.Apply();
_deserializeHook.Apply();
_serializeHook.Apply();
}
internal static void UndoHooks()
{
_canSerializeTypeHook.Undo();
_deserializeHook.Undo();
_serializeHook.Undo();
}
internal static void FreeHooks()
{
_canSerializeTypeHook.Free();
_deserializeHook.Free();
_serializeHook.Free();
}
static StringSerializerExtensions()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Expected O, but got Unknown
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Expected O, but got Unknown
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Expected O, but got Unknown
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Expected O, but got Unknown
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Expected O, but got Unknown
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Expected O, but got Unknown
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Expected O, but got Unknown
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Expected O, but got Unknown
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Expected O, but got Unknown
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Expected O, but got Unknown
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Expected O, but got Unknown
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Expected O, but got Unknown
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Expected O, but got Unknown
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Expected O, but got Unknown
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Expected O, but got Unknown
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0394: Expected O, but got Unknown
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
//IL_03c0: Expected O, but got Unknown
StringSerializer.serializationHandlers.Add(typeof(LayerMask), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
LayerMask val15 = (LayerMask)obj;
return ((LayerMask)(ref val15)).value.ToString(Invariant);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
LayerMask val14 = default(LayerMask);
((LayerMask)(ref val14)).value = int.Parse(str, Invariant);
return val14;
}
});
StringSerializer.serializationHandlers.Add(typeof(Vector4), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Vector4 val13 = (Vector4)obj;
return val13.x.ToString(Invariant) + " " + val13.y.ToString(Invariant) + " " + val13.z.ToString(Invariant) + " " + val13.w.ToString(Invariant);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
string[] array9 = StringSerializer.SplitToComponents(str, typeof(Vector4), 4);
return (object)new Vector4(float.Parse(array9[0], Invariant), float.Parse(array9[1], Invariant), float.Parse(array9[2], Invariant), float.Parse(array9[3], Invariant));
}
});
StringSerializer.serializationHandlers.Add(typeof(Rect), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Rect val12 = (Rect)obj;
return ((Rect)(ref val12)).x.ToString(Invariant) + " " + ((Rect)(ref val12)).y.ToString(Invariant) + " " + ((Rect)(ref val12)).width.ToString(Invariant) + " " + ((Rect)(ref val12)).height.ToString(Invariant);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
string[] array8 = StringSerializer.SplitToComponents(str, typeof(Rect), 4);
return (object)new Rect(float.Parse(array8[0], Invariant), float.Parse(array8[1], Invariant), float.Parse(array8[2], Invariant), float.Parse(array8[3], Invariant));
}
});
StringSerializer.serializationHandlers.Add(typeof(RectInt), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
RectInt val11 = (RectInt)obj;
return ((RectInt)(ref val11)).x.ToString(Invariant) + " " + ((RectInt)(ref val11)).y.ToString(Invariant) + " " + ((RectInt)(ref val11)).width.ToString(Invariant) + " " + ((RectInt)(ref val11)).height.ToString(Invariant);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
string[] array7 = StringSerializer.SplitToComponents(str, typeof(RectInt), 4);
return (object)new RectInt(int.Parse(array7[0], Invariant), int.Parse(array7[1], Invariant), int.Parse(array7[2], Invariant), int.Parse(array7[3], Invariant));
}
});
StringSerializer.serializationHandlers.Add(typeof(char), new SerializationHandler
{
serializer = (SerializerDelegate)((object obj) => ((char)obj).ToString(Invariant)),
deserializer = (DeserializerDelegate)((string str) => char.Parse(str))
});
StringSerializer.serializationHandlers.Add(typeof(Bounds), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
Bounds val10 = (Bounds)obj;
return ((Bounds)(ref val10)).center.x.ToString(Invariant) + " " + ((Bounds)(ref val10)).center.y.ToString(Invariant) + " " + ((Bounds)(ref val10)).center.z.ToString(Invariant) + " " + ((Bounds)(ref val10)).size.x.ToString(Invariant) + " " + ((Bounds)(ref val10)).size.y.ToString(Invariant) + " " + ((Bounds)(ref val10)).size.z.ToString(Invariant);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
string[] array6 = StringSerializer.SplitToComponents(str, typeof(Bounds), 6);
Vector3 val8 = new Vector3(float.Parse(array6[0], Invariant), float.Parse(array6[1], Invariant), float.Parse(array6[2], Invariant));
Vector3 val9 = default(Vector3);
((Vector3)(ref val9))..ctor(float.Parse(array6[3], Invariant), float.Parse(array6[4], Invariant), float.Parse(array6[5], Invariant));
return (object)new Bounds(val8, val9);
}
});
StringSerializer.serializationHandlers.Add(typeof(BoundsInt), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
BoundsInt val6 = (BoundsInt)obj;
string[] array5 = new string[11];
Vector3Int val7 = ((BoundsInt)(ref val6)).position;
array5[0] = ((Vector3Int)(ref val7)).x.ToString(Invariant);
array5[1] = " ";
val7 = ((BoundsInt)(ref val6)).position;
array5[2] = ((Vector3Int)(ref val7)).y.ToString(Invariant);
array5[3] = " ";
val7 = ((BoundsInt)(ref val6)).position;
array5[4] = ((Vector3Int)(ref val7)).z.ToString(Invariant);
array5[5] = " ";
val7 = ((BoundsInt)(ref val6)).size;
array5[6] = ((Vector3Int)(ref val7)).x.ToString(Invariant);
array5[7] = " ";
val7 = ((BoundsInt)(ref val6)).size;
array5[8] = ((Vector3Int)(ref val7)).y.ToString(Invariant);
array5[9] = " ";
val7 = ((BoundsInt)(ref val6)).size;
array5[10] = ((Vector3Int)(ref val7)).z.ToString(Invariant);
return string.Concat(array5);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
string[] array4 = StringSerializer.SplitToComponents(str, typeof(BoundsInt), 6);
Vector3Int position = default(Vector3Int);
((Vector3Int)(ref position))..ctor(int.Parse(array4[0], Invariant), int.Parse(array4[1], Invariant), int.Parse(array4[2], Invariant));
Vector3Int size = default(Vector3Int);
((Vector3Int)(ref size))..ctor(int.Parse(array4[3], Invariant), int.Parse(array4[4], Invariant), int.Parse(array4[5], Invariant));
BoundsInt val5 = default(BoundsInt);
((BoundsInt)(ref val5)).position = position;
((BoundsInt)(ref val5)).size = size;
return val5;
}
});
StringSerializer.serializationHandlers.Add(typeof(Quaternion), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Quaternion val4 = (Quaternion)obj;
return val4.x.ToString(Invariant) + " " + val4.y.ToString(Invariant) + " " + val4.z.ToString(Invariant) + " " + val4.w.ToString(Invariant);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
string[] array3 = StringSerializer.SplitToComponents(str, typeof(Quaternion), 4);
return (object)new Quaternion(float.Parse(array3[0], Invariant), float.Parse(array3[1], Invariant), float.Parse(array3[2], Invariant), float.Parse(array3[3], Invariant));
}
});
StringSerializer.serializationHandlers.Add(typeof(Vector2Int), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Vector2Int val3 = (Vector2Int)obj;
return ((Vector2Int)(ref val3)).x.ToString(Invariant) + " " + ((Vector2Int)(ref val3)).y.ToString(Invariant);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
string[] array2 = StringSerializer.SplitToComponents(str, typeof(Vector2Int), 2);
return (object)new Vector2Int(int.Parse(array2[0], Invariant), int.Parse(array2[1], Invariant));
}
});
StringSerializer.serializationHandlers.Add(typeof(Vector3Int), new SerializationHandler
{
serializer = (SerializerDelegate)delegate(object obj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Vector3Int val2 = (Vector3Int)obj;
return ((Vector3Int)(ref val2)).x.ToString(Invariant) + " " + ((Vector3Int)(ref val2)).y.ToString(Invariant) + " " + ((Vector3Int)(ref val2)).z.ToString(Invariant);
},
deserializer = (DeserializerDelegate)delegate(string str)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
string[] array = StringSerializer.SplitToComponents(str, typeof(Vector3Int), 3);
return (object)new Vector3Int(int.Parse(array[0], Invariant), int.Parse(array[1], Invariant), int.Parse(array[2], Invariant));
}
});
_enumTypeHandler = new SerializationHandler
{
serializer = (SerializerDelegate)((object obj) => JsonUtility.ToJson((object)EnumJSONIntermediate.ToJSON((Enum)obj))),
deserializer = (DeserializerDelegate)delegate(string str)
{
if (string.IsNullOrEmpty(str))
{
return null;
}
EnumJSONIntermediate intermediate = JsonUtility.FromJson<EnumJSONIntermediate>(str);
return EnumJSONIntermediate.ToEnum(in intermediate);
}
};
HookConfig val = new HookConfig
{
ManualApply = true
};
_canSerializeTypeHook = new Hook((MethodBase)typeof(StringSerializer).GetMethod("CanSerializeType", (BindingFlags)(-1)), (Delegate)new Func<Func<Type, bool>, Type, bool>(AllowEnumSerialization), val);
_deserializeHook = new Hook((MethodBase)typeof(StringSerializer).GetMethod("Deserialize", (BindingFlags)(-1)), (Delegate)new Func<Func<Type, string, object>, Type, string, object>(HandleEnumDeserialization), val);
_serializeHook = new Hook((MethodBase)typeof(StringSerializer).GetMethod("Serialize", (BindingFlags)(-1)), (Delegate)new Func<Func<Type, object, string>, Type, object, string>(HandleEnumSerialization), val);
}
}
[BepInPlugin("com.bepis.r2api.extendedStringSerializer", "R2API.ExtendedStringSerializer", "1.0.0")]
internal sealed class StringSerializerExtensionsPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
}
private void OnEnable()
{
StringSerializerExtensions.ApplyHooks();
}
private void OnDisable()
{
StringSerializerExtensions.UndoHooks();
}
private void OnDestroy()
{
StringSerializerExtensions.FreeHooks();
}
}
}
namespace R2API.AutoVersionGen
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal class AutoVersionAttribute : Attribute
{
}
}