Decompiled source of InterprocessLib v2.0.1

plugins/InterprocessLib.BepisLoader/InterprocessLib.FrooxEngine.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using Elements.Core;
using FrooxEngine;
using Renderite.Shared;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("Nytra")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1+659a967631415d299bfd5408909e1d7a3d01d3d6")]
[assembly: AssemblyProduct("InterprocessLib.FrooxEngine")]
[assembly: AssemblyTitle("InterprocessLib.FrooxEngine")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Nytra/ResoniteInterprocessLib")]
[assembly: AssemblyVersion("2.0.1.0")]
[module: RefSafetyRules(11)]
namespace InterprocessLib
{
	internal static class FrooxEngineInit
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__InitLoop;

			public static RenderCommandHandler <1>__CommandHandler;
		}

		[StructLayout(3)]
		[CompilerGenerated]
		private struct <InitLoop>d__2 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncVoidMethodBuilder <>t__builder;

			private TaskAwaiter <>u__1;

			private void MoveNext()
			{
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Expected O, but got Unknown
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Expected O, but got Unknown
				int num = <>1__state;
				try
				{
					TaskAwaiter awaiter;
					if (num == 0)
					{
						awaiter = <>u__1;
						<>u__1 = default(TaskAwaiter);
						num = (<>1__state = -1);
						goto IL_0084;
					}
					if (num != 1)
					{
						Engine current = Engine.Current;
						object obj;
						if (current == null)
						{
							obj = null;
						}
						else
						{
							RenderSystem renderSystem = current.RenderSystem;
							obj = ((renderSystem != null) ? renderSystem.Engine : null);
						}
						if (obj == null)
						{
							awaiter = global::System.Threading.Tasks.Task.Delay(1).GetAwaiter();
							if (!((TaskAwaiter)(ref awaiter)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter;
								((AsyncVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<TaskAwaiter, <InitLoop>d__2>(ref awaiter, ref this);
								return;
							}
							goto IL_0084;
						}
						awaiter = global::System.Threading.Tasks.Task.Delay(100).GetAwaiter();
						if (!((TaskAwaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 1);
							<>u__1 = awaiter;
							((AsyncVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<TaskAwaiter, <InitLoop>d__2>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(TaskAwaiter);
						num = (<>1__state = -1);
					}
					((TaskAwaiter)(ref awaiter)).GetResult();
					RenderiteMessagingHost val = (RenderiteMessagingHost)typeof(RenderSystem).GetField("_messagingHost", (BindingFlags)36).GetValue((object)Engine.Current.RenderSystem);
					if (val == null)
					{
						throw new InvalidOperationException("Engine is not configured to use a renderer!");
					}
					Messenger.OnWarning = delegate(string msg)
					{
						UniLog.Warning("[InterprocessLib] [WARN] " + msg, false);
					};
					Messenger.OnFailure = delegate(global::System.Exception ex)
					{
						UniLog.Error($"[InterprocessLib] [ERROR] Error in InterprocessLib Messaging Host!\n{ex}", true);
					};
					Messenger.IsAuthority = true;
					bool isAuthority = Messenger.IsAuthority;
					string queueName = val.QueueName;
					long queueCapacity = val.QueueCapacity;
					object obj2 = <>O.<1>__CommandHandler;
					if (obj2 == null)
					{
						RenderCommandHandler val2 = CommandHandler;
						<>O.<1>__CommandHandler = val2;
						obj2 = (object)val2;
					}
					Messenger.Host = new MessagingHost(isAuthority, queueName, queueCapacity, (IMemoryPackerEntityPool)(object)val, (RenderCommandHandler?)obj2, Messenger.OnFailure, Messenger.OnWarning, Messenger.OnDebug);
					Messenger.FinishInitialization();
					goto end_IL_0007;
					IL_0084:
					((TaskAwaiter)(ref awaiter)).GetResult();
					InitLoop();
					end_IL_0007:;
				}
				catch (global::System.Exception exception)
				{
					<>1__state = -2;
					((AsyncVoidMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncVoidMethodBuilder)(ref <>t__builder)).SetResult();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}
		}

		private static void CommandHandler(RendererCommand command, int messageSize)
		{
		}

		public static void Init()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if (Messenger.Host != null)
			{
				throw new InvalidOperationException("Messenger has already been initialized!");
			}
			object obj = <>O.<0>__InitLoop;
			if (obj == null)
			{
				Action val = InitLoop;
				<>O.<0>__InitLoop = val;
				obj = (object)val;
			}
			global::System.Threading.Tasks.Task.Run((Action)obj);
		}

		[AsyncStateMachine(typeof(<InitLoop>d__2))]
		private static void InitLoop()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			<InitLoop>d__2 <InitLoop>d__ = default(<InitLoop>d__2);
			<InitLoop>d__.<>t__builder = AsyncVoidMethodBuilder.Create();
			<InitLoop>d__.<>1__state = -1;
			((AsyncVoidMethodBuilder)(ref <InitLoop>d__.<>t__builder)).Start<<InitLoop>d__2>(ref <InitLoop>d__);
		}
	}
	internal abstract class IdentifiableCommand : RendererCommand
	{
		internal string Owner = "";

		public string Id = "";

		public static void InitNewTypes(List<global::System.Type> types)
		{
			PolymorphicMemoryPackableEntity<RendererCommand>.InitTypes(types);
		}

		public override void Pack(ref MemoryPacker packer)
		{
			((MemoryPacker)(ref packer)).Write(Owner);
			((MemoryPacker)(ref packer)).Write(Id);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			((MemoryUnpacker)(ref unpacker)).Read(ref Owner);
			((MemoryUnpacker)(ref unpacker)).Read(ref Id);
		}

		public override string ToString()
		{
			return "IdentifiableCommand:" + Owner + ":" + Id;
		}
	}
	internal abstract class CollectionCommand : IdentifiableCommand
	{
		public abstract global::System.Collections.IEnumerable? UntypedCollection { get; }

		public abstract global::System.Type InnerDataType { get; }

		public abstract global::System.Type CollectionType { get; }

		public override string ToString()
		{
			return $"CollectionCommand:{((MemberInfo)CollectionType).Name}<{((MemberInfo)InnerDataType).Name}>:{Owner}:{Id}:{((object)UntypedCollection)?.ToString() ?? "NULL"}";
		}
	}
	internal abstract class ValueCommand : IdentifiableCommand
	{
		public abstract object UntypedValue { get; }

		public abstract global::System.Type ValueType { get; }

		public override string ToString()
		{
			return $"ValueCommand<{((MemberInfo)ValueType).Name}>:{Owner}:{Id}:{UntypedValue}";
		}
	}
	internal abstract class ObjectCommand : IdentifiableCommand
	{
		public abstract object? UntypedObject { get; }

		public abstract global::System.Type ObjectType { get; }

		public override string ToString()
		{
			return $"ObjectCommand<{((MemberInfo)ObjectType).Name}>:{Owner}:{Id}:{UntypedObject?.ToString() ?? "NULL"}";
		}
	}
	internal sealed class EmptyCommand : IdentifiableCommand
	{
		public override string ToString()
		{
			return "EmptyCommand:" + Owner + ":" + Id;
		}
	}
	internal sealed class ValueCollectionCommand<C, T> : CollectionCommand where C : global::System.Collections.Generic.ICollection<T>, new() where T : unmanaged
	{
		public C? Values;

		public override global::System.Collections.IEnumerable? UntypedCollection => (global::System.Collections.IEnumerable?)(object)Values;

		public override global::System.Type InnerDataType => typeof(T);

		public override global::System.Type CollectionType => typeof(C);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).WriteValueList<C, T>(Values);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).ReadValueList<C, T>(ref Values);
		}
	}
	internal sealed class StringListCommand : CollectionCommand
	{
		public List<string>? Values;

		public override global::System.Collections.IEnumerable? UntypedCollection => (global::System.Collections.IEnumerable?)Values;

		public override global::System.Type InnerDataType => typeof(string);

		public override global::System.Type CollectionType => typeof(List<string>);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).WriteStringList(Values);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).ReadStringList(ref Values);
		}
	}
	internal sealed class ObjectListCommand<T> : CollectionCommand where T : class, IMemoryPackable, new()
	{
		public List<T>? Values;

		public override global::System.Collections.IEnumerable? UntypedCollection => (global::System.Collections.IEnumerable?)Values;

		public override global::System.Type InnerDataType => typeof(T);

		public override global::System.Type CollectionType => typeof(List<T>);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).WriteObjectList<T>(Values);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).ReadObjectList<T>(ref Values);
		}
	}
	internal sealed class ObjectCommand<T> : ObjectCommand where T : class, IMemoryPackable, new()
	{
		public T? Object;

		public override object? UntypedObject => Object;

		public override global::System.Type ObjectType => typeof(T);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).WriteObject<T>(Object);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).ReadObject<T>(ref Object);
		}
	}
	internal sealed class ValueCommand<T> : ValueCommand where T : unmanaged
	{
		public T Value;

		public override object UntypedValue => Value;

		public override global::System.Type ValueType => typeof(T);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).Write<T>(Value);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).Read<T>(ref Value);
		}
	}
	internal sealed class StringCommand : IdentifiableCommand
	{
		public string? String;

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).Write(String);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).Read(ref String);
		}

		public override string ToString()
		{
			return $"StringCommand:{Owner}:{Id}:{String ?? "NULL"}";
		}
	}
	internal sealed class MessengerReadyCommand : RendererCommand
	{
		public override void Pack(ref MemoryPacker packer)
		{
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
		}

		public override string ToString()
		{
			return "MessengerReadyCommand";
		}
	}
	internal class MessagingHost
	{
		private struct OwnerData
		{
			public readonly Dictionary<string, object?> ValueCallbacks;

			public readonly Dictionary<string, Action<string?>?> StringCallbacks;

			public readonly Dictionary<string, Action?> EmptyCallbacks;

			public readonly Dictionary<string, object?> ObjectCallbacks;

			public readonly Dictionary<string, object?> ValueCollectionCallbacks;

			public readonly Dictionary<string, Action<List<string>?>?> StringListCallbacks;

			public readonly Dictionary<string, object?> ObjectListCallbacks;

			public OwnerData()
			{
				ValueCallbacks = new Dictionary<string, object>();
				StringCallbacks = new Dictionary<string, Action<string>>();
				EmptyCallbacks = new Dictionary<string, Action>();
				ObjectCallbacks = new Dictionary<string, object>();
				ValueCollectionCallbacks = new Dictionary<string, object>();
				StringListCallbacks = new Dictionary<string, Action<List<string>>>();
				ObjectListCallbacks = new Dictionary<string, object>();
			}
		}

		private MessagingManager _primary;

		private static MethodInfo? _handleValueCommandMethod;

		private static MethodInfo? _handleValueCollectionCommandMethod;

		private static MethodInfo? _handleObjectCommandMethod;

		private static MethodInfo? _handleObjectListCommandMethod;

		private Dictionary<string, OwnerData> _ownerData = new Dictionary<string, OwnerData>();

		[field: CompilerGenerated]
		public bool IsAuthority
		{
			[CompilerGenerated]
			get;
		}

		[field: CompilerGenerated]
		public string QueueName
		{
			[CompilerGenerated]
			get;
		}

		[field: CompilerGenerated]
		public long QueueCapacity
		{
			[CompilerGenerated]
			get;
		}

		[field: CompilerGenerated]
		private RenderCommandHandler? OnCommandReceived
		{
			[CompilerGenerated]
			get;
		}

		[field: CompilerGenerated]
		private Action<string>? OnWarning
		{
			[CompilerGenerated]
			get;
		}

		[field: CompilerGenerated]
		private Action<string>? OnDebug
		{
			[CompilerGenerated]
			get;
		}

		[field: CompilerGenerated]
		private Action<global::System.Exception>? OnFailure
		{
			[CompilerGenerated]
			get;
		}

		public void RegisterOwner(string ownerName)
		{
			OwnerData ownerData = new OwnerData();
			_ownerData.Add(ownerName, ownerData);
		}

		public void RegisterValueCallback<T>(string owner, string id, Action<T> callback) where T : unmanaged
		{
			_ownerData[owner].ValueCallbacks[id] = callback;
		}

		public void RegisterValueCollectionCallback<C, T>(string owner, string id, Action<C> callback) where C : global::System.Collections.Generic.ICollection<T>, new() where T : unmanaged
		{
			_ownerData[owner].ValueCollectionCallbacks[id] = callback;
		}

		public void RegisterStringCallback(string owner, string id, Action<string?> callback)
		{
			_ownerData[owner].StringCallbacks[id] = callback;
		}

		public void RegisterStringListCallback(string owner, string id, Action<List<string>?>? callback)
		{
			_ownerData[owner].StringListCallbacks[id] = callback;
		}

		public void RegisterEmptyCallback(string owner, string id, Action callback)
		{
			_ownerData[owner].EmptyCallbacks[id] = callback;
		}

		public void RegisterObjectCallback<T>(string owner, string id, Action<T> callback) where T : class, IMemoryPackable, new()
		{
			_ownerData[owner].ObjectCallbacks[id] = callback;
		}

		public void RegisterObjectListCallback<T>(string owner, string id, Action<List<T>> callback) where T : class, IMemoryPackable, new()
		{
			_ownerData[owner].ObjectListCallbacks[id] = callback;
		}

		static MessagingHost()
		{
			_handleValueCommandMethod = typeof(MessagingHost).GetMethod("HandleValueCommand", (BindingFlags)36);
			_handleValueCollectionCommandMethod = typeof(MessagingHost).GetMethod("HandleValueCollectionCommand", (BindingFlags)36);
			_handleObjectCommandMethod = typeof(MessagingHost).GetMethod("HandleObjectCommand", (BindingFlags)36);
			_handleObjectListCommandMethod = typeof(MessagingHost).GetMethod("HandleObjectListCommand", (BindingFlags)36);
			TypeManager.InitializeCoreTypes();
		}

		public MessagingHost(bool isAuthority, string queueName, long queueCapacity, IMemoryPackerEntityPool pool, RenderCommandHandler? commandHandler, Action<global::System.Exception>? failhandler, Action<string>? warnHandler, Action<string>? debugHandler)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			IsAuthority = isAuthority;
			QueueName = queueName + "InterprocessLib";
			QueueCapacity = queueCapacity;
			OnDebug = debugHandler;
			OnWarning = warnHandler;
			OnFailure = failhandler;
			OnCommandReceived = commandHandler;
			_primary = new MessagingManager(pool);
			_primary.CommandHandler = new RenderCommandHandler(CommandHandler);
			_primary.FailureHandler = [CompilerGenerated] (global::System.Exception ex) =>
			{
				OnFailure?.Invoke(ex);
			};
			_primary.WarningHandler = [CompilerGenerated] (string msg) =>
			{
				OnWarning?.Invoke(msg);
			};
			_primary.Connect(queueName, isAuthority, queueCapacity);
		}

		private void HandleValueCommand<T>(ValueCommand<T> command) where T : unmanaged
		{
			object obj = default(object);
			if (_ownerData[command.Owner].ValueCallbacks.TryGetValue(command.Id, ref obj))
			{
				if (obj != null)
				{
					((Action<T>)obj).Invoke(command.Value);
				}
				return;
			}
			OnWarning?.Invoke($"ValueCommand<{((MemberInfo)typeof(T)).Name}> with Id \"{command.Id}\" is not registered to receive a callback!");
		}

		private void HandleValueCollectionCommand<C, T>(ValueCollectionCommand<C, T> command) where C : global::System.Collections.Generic.ICollection<T>, new() where T : unmanaged
		{
			object obj = default(object);
			if (_ownerData[command.Owner].ValueCollectionCallbacks.TryGetValue(command.Id, ref obj))
			{
				if (obj != null)
				{
					((Action<C>)obj).Invoke(command.Values);
				}
				return;
			}
			OnWarning?.Invoke($"ValueCollectionCommand<{((MemberInfo)typeof(C)).Name}, {((MemberInfo)typeof(T)).Name}> with Id \"{command.Id}\" is not registered to receive a callback!");
		}

		private void HandleStringCommand(StringCommand command)
		{
			Action<string> val = default(Action<string>);
			if (_ownerData[command.Owner].StringCallbacks.TryGetValue(command.Id, ref val))
			{
				val?.Invoke(command.String);
			}
			else
			{
				OnWarning?.Invoke("StringCommand with Id \"" + command.Id + "\" is not registered to receive a callback!");
			}
		}

		private void HandleStringListCommand(StringListCommand command)
		{
			Action<List<string>> val = default(Action<List<string>>);
			if (_ownerData[command.Owner].StringListCallbacks.TryGetValue(command.Id, ref val))
			{
				val?.Invoke(command.Values);
			}
			else
			{
				OnWarning?.Invoke("StringListCommand with Id \"" + command.Id + "\" is not registered to receive a callback!");
			}
		}

		private void HandleEmptyCommand(EmptyCommand command)
		{
			Action val = default(Action);
			if (_ownerData[command.Owner].EmptyCallbacks.TryGetValue(command.Id, ref val))
			{
				if (val != null)
				{
					val.Invoke();
				}
			}
			else
			{
				OnWarning?.Invoke("EmptyCommand with Id \"" + command.Id + "\" is not registered to receive a callback!");
			}
		}

		private void HandleObjectCommand<T>(ObjectCommand<T> command) where T : class, IMemoryPackable, new()
		{
			object obj = default(object);
			if (_ownerData[command.Owner].ObjectCallbacks.TryGetValue(command.Id, ref obj))
			{
				if (obj != null)
				{
					((Action<T>)obj).Invoke((T)command.UntypedObject);
				}
				return;
			}
			OnWarning?.Invoke($"ObjectCommand<{((MemberInfo)command.ObjectType).Name}> with Id \"{command.Id}\" is not registered to receive a callback!");
		}

		private void HandleObjectListCommand<T>(ObjectListCommand<T> command) where T : class, IMemoryPackable, new()
		{
			object obj = default(object);
			if (_ownerData[command.Owner].ObjectListCallbacks.TryGetValue(command.Id, ref obj))
			{
				if (obj != null)
				{
					((Action<List<T>>)obj).Invoke(command.Values);
				}
				return;
			}
			OnWarning?.Invoke($"ObjectListCommand<{((MemberInfo)typeof(T)).Name}> with Id \"{command.Id}\" is not registered to receive a callback!");
		}

		private void CommandHandler(RendererCommand command, int messageSize)
		{
			OnDebug?.Invoke($"Received {command}");
			RenderCommandHandler? onCommandReceived = OnCommandReceived;
			if (onCommandReceived != null)
			{
				onCommandReceived.Invoke(command, messageSize);
			}
			OwnerData ownerData = default(OwnerData);
			if (command is IdentifiableCommand identifiableCommand && !_ownerData.TryGetValue(identifiableCommand.Owner, ref ownerData))
			{
				OnWarning?.Invoke("Owner \"" + identifiableCommand.Owner + "\" is not registered!");
			}
			else if (command is ValueCommand valueCommand)
			{
				global::System.Type valueType = valueCommand.ValueType;
				((MethodBase)_handleValueCommandMethod.MakeGenericMethod(new global::System.Type[1] { valueType })).Invoke((object)this, new object[1] { command });
			}
			else if (command is CollectionCommand collectionCommand)
			{
				global::System.Type innerDataType = collectionCommand.InnerDataType;
				if (innerDataType == typeof(string))
				{
					HandleStringListCommand((StringListCommand)collectionCommand);
				}
				else if (innerDataType.IsValueType)
				{
					global::System.Type collectionType = collectionCommand.CollectionType;
					((MethodBase)_handleValueCollectionCommandMethod.MakeGenericMethod(new global::System.Type[2] { collectionType, innerDataType })).Invoke((object)this, new object[1] { command });
				}
				else
				{
					((MethodBase)_handleObjectListCommandMethod.MakeGenericMethod(new global::System.Type[1] { innerDataType })).Invoke((object)this, new object[1] { command });
				}
			}
			else if (command is ObjectCommand objectCommand)
			{
				global::System.Type objectType = objectCommand.ObjectType;
				((MethodBase)_handleObjectCommandMethod.MakeGenericMethod(new global::System.Type[1] { objectType })).Invoke((object)this, new object[1] { command });
			}
			else if (!(command is StringCommand))
			{
				if (!(command is EmptyCommand))
				{
					if (command is IdentifiableCommand identifiableCommand2)
					{
						OnWarning?.Invoke($"Received unrecognized IdentifiableCommand of type {((MemberInfo)((object)command).GetType()).Name}: {identifiableCommand2.Owner}:{identifiableCommand2.Id}");
					}
				}
				else
				{
					HandleEmptyCommand((EmptyCommand)(object)command);
				}
			}
			else
			{
				HandleStringCommand((StringCommand)(object)command);
			}
		}

		public void SendCommand(RendererCommand command)
		{
			OnDebug?.Invoke($"Sending {command}");
			_primary.SendCommand(command);
		}
	}
	public class Messenger
	{
		internal static MessagingHost? Host;

		internal static bool InitStarted = false;

		internal static Action<global::System.Exception>? OnFailure;

		internal static Action<string>? OnWarning;

		internal static Action<string>? OnDebug;

		private static List<Action>? _postInitActions = new List<Action>();

		private string _ownerId;

		private static HashSet<string> _registeredOwnerIds = new HashSet<string>();

		private List<global::System.Type>? _additionalObjectTypes;

		private List<global::System.Type>? _additionalValueTypes;

		public static bool IsInitialized
		{
			get
			{
				if (Host != null)
				{
					return _postInitActions == null;
				}
				return false;
			}
		}

		[field: CompilerGenerated]
		public static bool IsAuthority
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			internal set;
		}

		public Messenger(string ownerId, List<global::System.Type>? additionalObjectTypes = null, List<global::System.Type>? additionalValueTypes = null)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			if (ownerId == null)
			{
				throw new ArgumentNullException("ownerId");
			}
			_ownerId = ownerId;
			_additionalObjectTypes = additionalObjectTypes;
			_additionalValueTypes = additionalValueTypes;
			if (_additionalObjectTypes != null)
			{
				TypeManager.InitObjectTypeList(Enumerable.ToList<global::System.Type>(Enumerable.Where<global::System.Type>((global::System.Collections.Generic.IEnumerable<global::System.Type>)_additionalObjectTypes, (Func<global::System.Type, bool>)((global::System.Type t) => !TypeManager.IsObjectTypeInitialized(t)))));
			}
			if (_additionalValueTypes != null)
			{
				TypeManager.InitValueTypeList(Enumerable.ToList<global::System.Type>(Enumerable.Where<global::System.Type>((global::System.Collections.Generic.IEnumerable<global::System.Type>)_additionalValueTypes, (Func<global::System.Type, bool>)((global::System.Type t) => !TypeManager.IsValueTypeInitialized(t)))));
			}
			if (!_registeredOwnerIds.Contains(ownerId))
			{
				_registeredOwnerIds.Add(ownerId);
				if (IsInitialized)
				{
					Register();
				}
				else
				{
					RunPostInit(new Action(Register));
				}
			}
			else
			{
				OnWarning?.Invoke("A messenger with id " + ownerId + " has already been created in this process!");
			}
			if (Host != null || InitStarted)
			{
				return;
			}
			InitStarted = true;
			global::System.Type type = global::System.Type.GetType("InterprocessLib.FrooxEngineInit");
			if (type != null)
			{
				((MethodBase)type.GetMethod("Init", (BindingFlags)24)).Invoke((object)null, (object[])null);
				return;
			}
			global::System.Type type2 = global::System.Type.GetType("InterprocessLib.UnityInit");
			if (type2 != null)
			{
				((MethodBase)type2.GetMethod("Init", (BindingFlags)24)).Invoke((object)null, (object[])null);
				return;
			}
			throw new EntryPointNotFoundException("Could not find InterprocessLib initialization type!");
		}

		private void Register()
		{
			Host.RegisterOwner(_ownerId);
		}

		internal static void FinishInitialization()
		{
			if (IsAuthority)
			{
				Host.SendCommand((RendererCommand)(object)new MessengerReadyCommand());
			}
			Action[] array = _postInitActions.ToArray();
			_postInitActions = null;
			Action[] array2 = array;
			foreach (Action val in array2)
			{
				try
				{
					val.Invoke();
				}
				catch (global::System.Exception ex)
				{
					OnWarning?.Invoke($"Exception running post-init action:\n{ex}");
				}
			}
		}

		private static void RunPostInit(Action act)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (!IsInitialized)
			{
				_postInitActions.Add(act);
				return;
			}
			throw new InvalidOperationException("Already initialized!");
		}

		public void SendValue<T>(string id, T value) where T : unmanaged
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					SendValue(id2, value);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)((object)value).GetType()).Name + " needs to be registered first!");
			}
			ValueCommand<T> valueCommand = new ValueCommand<T>();
			valueCommand.Owner = _ownerId;
			valueCommand.Id = id2;
			valueCommand.Value = value;
			Host.SendCommand((RendererCommand)(object)valueCommand);
		}

		public void SendValueList<T>(string id, List<T> list) where T : unmanaged
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			List<T> list2 = list;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					SendValueList<T>(id2, list2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			ValueCollectionCommand<List<T>, T> valueCollectionCommand = new ValueCollectionCommand<List<T>, T>();
			valueCollectionCommand.Owner = _ownerId;
			valueCollectionCommand.Id = id2;
			valueCollectionCommand.Values = list2;
			Host.SendCommand((RendererCommand)(object)valueCollectionCommand);
		}

		public void SendValueHashSet<T>(string id, HashSet<T> hashSet) where T : unmanaged
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			HashSet<T> hashSet2 = hashSet;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					SendValueHashSet<T>(id2, hashSet2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			ValueCollectionCommand<HashSet<T>, T> valueCollectionCommand = new ValueCollectionCommand<HashSet<T>, T>();
			valueCollectionCommand.Owner = _ownerId;
			valueCollectionCommand.Id = id2;
			valueCollectionCommand.Values = hashSet2;
			Host.SendCommand((RendererCommand)(object)valueCollectionCommand);
		}

		public void SendString(string id, string str)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			string id2 = id;
			string str2 = str;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					SendString(id2, str2);
				});
				return;
			}
			StringCommand stringCommand = new StringCommand();
			stringCommand.Owner = _ownerId;
			stringCommand.Id = id2;
			stringCommand.String = str2;
			Host.SendCommand((RendererCommand)(object)stringCommand);
		}

		public void SendStringList(string id, List<string> list)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			string id2 = id;
			List<string> list2 = list;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					SendStringList(id2, list2);
				});
				return;
			}
			StringListCommand stringListCommand = new StringListCommand();
			stringListCommand.Owner = _ownerId;
			stringListCommand.Id = id2;
			stringListCommand.Values = list2;
			Host.SendCommand((RendererCommand)(object)stringListCommand);
		}

		public void SendEmptyCommand(string id)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			string id2 = id;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					SendEmptyCommand(id2);
				});
				return;
			}
			EmptyCommand emptyCommand = new EmptyCommand();
			emptyCommand.Owner = _ownerId;
			emptyCommand.Id = id2;
			Host.SendCommand((RendererCommand)(object)emptyCommand);
		}

		public void SendObject<T>(string id, T? obj) where T : class, IMemoryPackable, new()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			T obj2 = obj;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					SendObject(id2, obj2);
				});
				return;
			}
			if (!TypeManager.IsObjectTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			ObjectCommand<T> objectCommand = new ObjectCommand<T>();
			objectCommand.Object = obj2;
			objectCommand.Owner = _ownerId;
			objectCommand.Id = id2;
			Host.SendCommand((RendererCommand)(object)objectCommand);
		}

		public void SendObjectList<T>(string id, List<T> list) where T : class, IMemoryPackable, new()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			List<T> list2 = list;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					SendObjectList<T>(id2, list2);
				});
				return;
			}
			if (!TypeManager.IsObjectTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			ObjectListCommand<T> objectListCommand = new ObjectListCommand<T>();
			objectListCommand.Owner = _ownerId;
			objectListCommand.Id = id2;
			objectListCommand.Values = list2;
			Host.SendCommand((RendererCommand)(object)objectListCommand);
		}

		public void ReceiveValue<T>(string id, Action<T> callback) where T : unmanaged
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			Action<T> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					ReceiveValue<T>(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			Host.RegisterValueCallback<T>(_ownerId, id2, callback2);
		}

		public void ReceiveValueList<T>(string id, Action<List<T>> callback) where T : unmanaged
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			Action<List<T>> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					ReceiveValueList<T>(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			Host.RegisterValueCollectionCallback<List<T>, T>(_ownerId, id2, callback2);
		}

		public void ReceiveValueHashSet<T>(string id, Action<HashSet<T>> callback) where T : unmanaged
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			Action<HashSet<T>> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					ReceiveValueHashSet<T>(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			Host.RegisterValueCollectionCallback<HashSet<T>, T>(_ownerId, id2, callback2);
		}

		public void ReceiveString(string id, Action<string?> callback)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			string id2 = id;
			Action<string?> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					ReceiveString(id2, callback2);
				});
			}
			else
			{
				Host.RegisterStringCallback(_ownerId, id2, callback2);
			}
		}

		public void ReceiveStringList(string id, Action<List<string>?>? callback)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			string id2 = id;
			Action<List<string>?> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					ReceiveStringList(id2, callback2);
				});
			}
			else
			{
				Host.RegisterStringListCallback(_ownerId, id2, callback2);
			}
		}

		public void ReceiveEmptyCommand(string id, Action callback)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			string id2 = id;
			Action callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					ReceiveEmptyCommand(id2, callback2);
				});
			}
			else
			{
				Host.RegisterEmptyCallback(_ownerId, id2, callback2);
			}
		}

		public void ReceiveObject<T>(string id, Action<T> callback) where T : class, IMemoryPackable, new()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			Action<T> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					ReceiveObject<T>(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsObjectTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			Host.RegisterObjectCallback<T>(_ownerId, id2, callback2);
		}

		public void ReceiveObjectList<T>(string id, Action<List<T>> callback) where T : class, IMemoryPackable, new()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			string id2 = id;
			Action<List<T>> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit((Action)delegate
				{
					ReceiveObjectList<T>(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsObjectTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeof(T)).Name + " needs to be registered first!");
			}
			Host.RegisterObjectListCallback<T>(_ownerId, id2, callback2);
		}
	}
	internal static class TypeManager
	{
		private static readonly HashSet<global::System.Type> _registeredObjectTypes = new HashSet<global::System.Type>();

		private static readonly HashSet<global::System.Type> _registeredValueTypes = new HashSet<global::System.Type>();

		private static bool _initializedCoreTypes = false;

		internal static MethodInfo? RegisterValueTypeMethod = typeof(TypeManager).GetMethod("RegisterAdditionalValueType", (BindingFlags)40);

		internal static MethodInfo? RegisterObjectTypeMethod = typeof(TypeManager).GetMethod("RegisterAdditionalObjectType", (BindingFlags)40);

		internal static List<global::System.Type> NewTypes = new List<global::System.Type>();

		private static global::System.Type[] _valueTypes = new global::System.Type[15]
		{
			typeof(bool),
			typeof(byte),
			typeof(ushort),
			typeof(uint),
			typeof(ulong),
			typeof(sbyte),
			typeof(short),
			typeof(int),
			typeof(long),
			typeof(float),
			typeof(double),
			typeof(decimal),
			typeof(char),
			typeof(global::System.DateTime),
			typeof(TimeSpan)
		};

		private static List<global::System.Type> RegisteredTypesList => (List<global::System.Type>)typeof(PolymorphicMemoryPackableEntity<RendererCommand>).GetField("types", (BindingFlags)40).GetValue((object)null);

		internal static void InitializeCoreTypes()
		{
			if (_initializedCoreTypes)
			{
				return;
			}
			TypeManager.RegisterAdditionalObjectType<MessengerReadyCommand>();
			TypeManager.RegisterAdditionalObjectType<EmptyCommand>();
			TypeManager.RegisterAdditionalObjectType<StringCommand>();
			TypeManager.RegisterAdditionalObjectType<StringListCommand>();
			global::System.Type[] valueTypes = _valueTypes;
			foreach (global::System.Type type in valueTypes)
			{
				try
				{
					((MethodBase)RegisterValueTypeMethod.MakeGenericMethod(new global::System.Type[1] { type })).Invoke((object)null, (object[])null);
				}
				catch (global::System.Exception ex)
				{
					Messenger.OnWarning?.Invoke($"Could not register additional value type {((MemberInfo)type).Name}!\n{ex}");
				}
			}
			_initializedCoreTypes = true;
		}

		private static void PushNewTypes()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			new EmptyCommand();
			List<global::System.Type> val = new List<global::System.Type>();
			val.AddRange((global::System.Collections.Generic.IEnumerable<global::System.Type>)RegisteredTypesList);
			Enumerator<global::System.Type> enumerator = NewTypes.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					global::System.Type current = enumerator.Current;
					if (!val.Contains(current))
					{
						val.Add(current);
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator).Dispose();
			}
			IdentifiableCommand.InitNewTypes(val);
		}

		internal static void InitValueTypeList(List<global::System.Type> types)
		{
			//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)
			Enumerator<global::System.Type> enumerator = types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					global::System.Type current = enumerator.Current;
					((MethodBase)RegisterValueTypeMethod.MakeGenericMethod(new global::System.Type[1] { current })).Invoke((object)null, (object[])null);
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator).Dispose();
			}
		}

		internal static void InitObjectTypeList(List<global::System.Type> types)
		{
			//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)
			Enumerator<global::System.Type> enumerator = types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					global::System.Type current = enumerator.Current;
					((MethodBase)RegisterObjectTypeMethod.MakeGenericMethod(new global::System.Type[1] { current })).Invoke((object)null, (object[])null);
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator).Dispose();
			}
		}

		internal static bool IsValueTypeInitialized<T>() where T : unmanaged
		{
			return _registeredValueTypes.Contains(typeof(T));
		}

		internal static bool IsValueTypeInitialized(global::System.Type t)
		{
			return _registeredValueTypes.Contains(t);
		}

		internal static bool IsObjectTypeInitialized<T>() where T : class, IMemoryPackable, new()
		{
			return _registeredObjectTypes.Contains(typeof(T));
		}

		internal static bool IsObjectTypeInitialized(global::System.Type t)
		{
			return _registeredObjectTypes.Contains(t);
		}

		internal static void RegisterAdditionalValueType<T>() where T : unmanaged
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			global::System.Type typeFromHandle = typeof(T);
			if (_registeredValueTypes.Contains(typeFromHandle))
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeFromHandle).Name + " is already registered!");
			}
			if (typeFromHandle.ContainsGenericParameters)
			{
				throw new ArgumentException("Type must be a concrete type!");
			}
			global::System.Type type = typeof(ValueCommand<>).MakeGenericType(new global::System.Type[1] { typeFromHandle });
			global::System.Type type2 = typeof(ValueCollectionCommand<, >).MakeGenericType(new global::System.Type[2]
			{
				typeof(List<T>),
				typeFromHandle
			});
			global::System.Type type3 = typeof(ValueCollectionCommand<, >).MakeGenericType(new global::System.Type[2]
			{
				typeof(HashSet<T>),
				typeFromHandle
			});
			NewTypes.AddRange((global::System.Collections.Generic.IEnumerable<global::System.Type>)new <>z__ReadOnlyArray<global::System.Type>(new global::System.Type[3] { type, type2, type3 }));
			_registeredValueTypes.Add(typeFromHandle);
			PushNewTypes();
		}

		internal static void RegisterAdditionalObjectType<T>() where T : class, IMemoryPackable, new()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			global::System.Type typeFromHandle = typeof(T);
			if (_registeredObjectTypes.Contains(typeFromHandle))
			{
				throw new InvalidOperationException("Type " + ((MemberInfo)typeFromHandle).Name + " is already registered!");
			}
			if (typeFromHandle.ContainsGenericParameters)
			{
				throw new ArgumentException("Type must be a concrete type!");
			}
			if (typeFromHandle.IsSubclassOf(typeof(PolymorphicMemoryPackableEntity<RendererCommand>)))
			{
				NewTypes.Add(typeFromHandle);
			}
			global::System.Type type = typeof(ObjectCommand<>).MakeGenericType(new global::System.Type[1] { typeFromHandle });
			global::System.Type type2 = typeof(ObjectListCommand<>).MakeGenericType(new global::System.Type[1] { typeFromHandle });
			NewTypes.AddRange((global::System.Collections.Generic.IEnumerable<global::System.Type>)new <>z__ReadOnlyArray<global::System.Type>(new global::System.Type[2] { type, type2 }));
			_registeredObjectTypes.Add(typeFromHandle);
			PushNewTypes();
		}
	}
}
namespace InterprocessLib.Tests
{
	public static class Tests
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<HapticPointState> <>9__4_0;

			public static Action<ShadowType> <>9__5_0;

			public static Action<Chirality> <>9__6_0;

			public static Action<string?> <>9__9_0;

			public static Action <>9__10_0;

			public static Action<string?> <>9__11_0;

			public static Action<int> <>9__12_0;

			public static Action<TestNestedPackable> <>9__13_0;

			public static Action<TestCommand> <>9__14_0;

			public static Action<TestPackable> <>9__15_0;

			public static Action<TestStruct> <>9__16_0;

			public static Action<TestNestedStruct> <>9__17_0;

			public static Action<UnregisteredCommand> <>9__18_0;

			public static Action<UnregisteredPackable> <>9__19_0;

			public static Action<UnregisteredStruct> <>9__20_0;

			public static Action<List<float>> <>9__21_0;

			public static Action<HashSet<float>> <>9__22_0;

			public static Action<List<TestPackable>> <>9__23_0;

			public static Func<string, string> <>9__24_1;

			public static Action<List<string>?> <>9__24_0;

			public static Action<RendererInitData> <>9__25_0;

			public static Action<QualityConfig> <>9__26_0;

			internal void <TestVanillaStruct>b__4_0(HapticPointState val)
			{
				//IL_001d: 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_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestVanillaStruct: {val.force} {val.temperature} {val.pain} {val.vibration}");
			}

			internal void <TestVanillaEnum>b__5_0(ShadowType val)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestVanillaEnum: {val}");
			}

			internal void <TestUnregisteredVanillaValue>b__6_0(Chirality val)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestUnregisteredVanillaValue: {val}");
			}

			internal void <TestNullString>b__9_0(string? str)
			{
				_logCallback.Invoke("NullStr: " + str);
			}

			internal void <TestEmptyCommand>b__10_0()
			{
				_logCallback.Invoke("TestEmptyCommand");
			}

			internal void <TestString>b__11_0(string? str)
			{
				_logCallback.Invoke("TestString: " + (str ?? "NULL"));
			}

			internal void <TestValue>b__12_0(int val)
			{
				_logCallback.Invoke($"TestValue: {val}");
			}

			internal void <TestNestedPackable>b__13_0(TestNestedPackable recvNestedPackable)
			{
				_logCallback.Invoke($"TestNestedPackable: {recvNestedPackable?.Value}, {((object)recvNestedPackable?.Obj)?.ToString() ?? "NULL"}, {recvNestedPackable?.Obj?.Value}, {recvNestedPackable?.Obj?.Text}, {recvNestedPackable?.Obj?.Time}");
			}

			internal void <TestCustomRendererCommand>b__14_0(TestCommand recvCmd)
			{
				_logCallback.Invoke($"TestCustomRendererCommand: {recvCmd?.Value}, {recvCmd?.Text}, {recvCmd?.Time}");
			}

			internal void <TestPackable>b__15_0(TestPackable recvObj)
			{
				_logCallback.Invoke($"TestPackable: {recvObj?.Value}");
			}

			internal void <TestStruct>b__16_0(TestStruct recvStruct)
			{
				_logCallback.Invoke($"TestStruct: {recvStruct.Value}");
			}

			internal void <TestNestedStruct>b__17_0(TestNestedStruct recvNestedStruct)
			{
				_logCallback.Invoke($"TestNestedStruct: {recvNestedStruct.Nested.Value}");
			}

			internal void <TestUnregisteredCommand>b__18_0(UnregisteredCommand recv)
			{
				_logCallback.Invoke("UnregisteredCommand");
			}

			internal void <TestUnregisteredPackable>b__19_0(UnregisteredPackable recv)
			{
				_logCallback.Invoke("UnregisteredPackable");
			}

			internal void <TestUnregisteredStruct>b__20_0(UnregisteredStruct recv)
			{
				_logCallback.Invoke("UnregisteredStruct");
			}

			internal void <TestValueList>b__21_0(List<float> list)
			{
				_logCallback.Invoke("TestValueList: " + string.Join<float>(",", (global::System.Collections.Generic.IEnumerable<float>)list));
			}

			internal void <TestValueHashSet>b__22_0(HashSet<float> list)
			{
				_logCallback.Invoke("TestValueHashSet: " + string.Join<float>(",", (global::System.Collections.Generic.IEnumerable<float>)list));
			}

			internal void <TestObjectList>b__23_0(List<TestPackable> list)
			{
				_logCallback.Invoke("TestObjectList: " + string.Join<TestPackable>(",", (global::System.Collections.Generic.IEnumerable<TestPackable>)list));
			}

			internal void <TestStringList>b__24_0(List<string>? list)
			{
				_logCallback.Invoke("TestStringList: " + string.Join(",", Enumerable.Select<string, string>((global::System.Collections.Generic.IEnumerable<string>)list, (Func<string, string>)((string s) => s ?? "NULL"))));
			}

			internal string <TestStringList>b__24_1(string s)
			{
				return s ?? "NULL";
			}

			internal void <TestVanillaObject>b__25_0(RendererInitData recv)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestVanillaObject: {recv.sharedMemoryPrefix} {recv.uniqueSessionId} {recv.mainProcessId} {recv.debugFramePacing} {recv.outputDevice} {recv.setWindowIcon} {recv.splashScreenOverride}");
			}

			internal void <TestUnregisteredVanillaObject>b__26_0(QualityConfig recv)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestUnregisteredVanillaObject: {recv.perPixelLights} {recv.shadowCascades} {recv.shadowResolution} {recv.shadowDistance} {recv.skinWeightMode}");
			}
		}

		private static Messenger? _messenger;

		private static Messenger? _unknownMessenger;

		private static Action<string>? _logCallback;

		public static void RunTests(Messenger messenger, Messenger unknownMessenger, Action<string> logCallback)
		{
			_messenger = messenger;
			_unknownMessenger = unknownMessenger;
			_logCallback = logCallback;
			TestUnknownMessenger();
			TestUnknownCommandId();
			TestNullString();
			TestEmptyCommand();
			TestString();
			TestValue();
			TestNestedPackable();
			TestCustomRendererCommand();
			TestPackable();
			TestStruct();
			TestNestedStruct();
			TestValueList();
			TestValueHashSet();
			TestStringList();
			TestObjectList();
			TestVanillaObject();
			TestVanillaStruct();
			TestVanillaEnum();
			try
			{
				TestUnregisteredCommand();
			}
			catch (global::System.Exception ex)
			{
				logCallback.Invoke("TestUnregisteredCommand threw an exception: " + ex.Message);
			}
			try
			{
				TestUnregisteredPackable();
			}
			catch (global::System.Exception ex2)
			{
				logCallback.Invoke("TestUnregisteredPackable threw an exception: " + ex2.Message);
			}
			try
			{
				TestUnregisteredStruct();
			}
			catch (global::System.Exception ex3)
			{
				logCallback.Invoke("TestUnregisteredStruct threw an exception: " + ex3.Message);
			}
			try
			{
				TestUnregisteredVanillaObject();
			}
			catch (global::System.Exception ex4)
			{
				logCallback.Invoke("TestUnregisteredVanillaObject threw an exception: " + ex4.Message);
			}
			try
			{
				TestUnregisteredVanillaValue();
			}
			catch (global::System.Exception ex5)
			{
				logCallback.Invoke("TestUnregisteredVanillaValue threw an exception: " + ex5.Message);
			}
		}

		private static void TestVanillaStruct()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			_messenger.ReceiveValue<HapticPointState>("TestVanillaStruct", (Action<HapticPointState>)delegate(HapticPointState val)
			{
				//IL_001d: 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_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestVanillaStruct: {val.force} {val.temperature} {val.pain} {val.vibration}");
			});
			HapticPointState value = default(HapticPointState);
			value.force = 8f;
			value.temperature = 4f;
			value.pain = 25f;
			value.vibration = 12f;
			_messenger.SendValue<HapticPointState>("TestVanillaStruct", value);
		}

		private static void TestVanillaEnum()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			_messenger.ReceiveValue<ShadowType>("TestVanillaEnum", (Action<ShadowType>)delegate(ShadowType val)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestVanillaEnum: {val}");
			});
			ShadowType value = (ShadowType)2;
			_messenger.SendValue<ShadowType>("TestVanillaEnum", value);
		}

		private static void TestUnregisteredVanillaValue()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			_messenger.ReceiveValue<Chirality>("TestUnregisteredVanillaValue", (Action<Chirality>)delegate(Chirality val)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestUnregisteredVanillaValue: {val}");
			});
			Chirality value = (Chirality)1;
			_messenger.SendValue<Chirality>("TestUnregisteredVanillaValue", value);
		}

		private static void TestUnknownMessenger()
		{
			_unknownMessenger.SendEmptyCommand("UnknownMessengerTest");
		}

		private static void TestUnknownCommandId()
		{
			_messenger.SendEmptyCommand("UnknownIdTest");
		}

		private static void TestNullString()
		{
			_messenger.ReceiveString("NullStr", delegate(string? str)
			{
				_logCallback.Invoke("NullStr: " + str);
			});
			_messenger.SendString("NullStr", null);
		}

		private static void TestEmptyCommand()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			Messenger? messenger = _messenger;
			object obj = <>c.<>9__10_0;
			if (obj == null)
			{
				Action val = delegate
				{
					_logCallback.Invoke("TestEmptyCommand");
				};
				<>c.<>9__10_0 = val;
				obj = (object)val;
			}
			messenger.ReceiveEmptyCommand("TestEmptyCommand", (Action)obj);
			_messenger.SendEmptyCommand("TestEmptyCommand");
		}

		private static void TestString()
		{
			_messenger.ReceiveString("TestString", delegate(string? str)
			{
				_logCallback.Invoke("TestString: " + (str ?? "NULL"));
			});
			_messenger.SendString("TestString", "I am a test string wow");
		}

		private static void TestValue()
		{
			_messenger.ReceiveValue<int>("TestValue", (Action<int>)delegate(int val)
			{
				_logCallback.Invoke($"TestValue: {val}");
			});
			_messenger.SendValue<int>("TestValue", 637);
		}

		private static void TestNestedPackable()
		{
			_messenger.ReceiveObject<TestNestedPackable>("TestNestedPackable", delegate(TestNestedPackable recvNestedPackable)
			{
				_logCallback.Invoke($"TestNestedPackable: {recvNestedPackable?.Value}, {((object)recvNestedPackable?.Obj)?.ToString() ?? "NULL"}, {recvNestedPackable?.Obj?.Value}, {recvNestedPackable?.Obj?.Text}, {recvNestedPackable?.Obj?.Time}");
			});
			TestCommand testCommand = new TestCommand();
			testCommand.Value = 9999uL;
			testCommand.Text = "I am a nested command!";
			testCommand.Time = global::System.DateTime.MinValue;
			TestNestedPackable testNestedPackable = new TestNestedPackable();
			testNestedPackable.Value = 248;
			testNestedPackable.Obj = testCommand;
			_messenger.SendObject("TestNestedPackable", testNestedPackable);
		}

		private static void TestCustomRendererCommand()
		{
			_messenger.ReceiveObject<TestCommand>("TestCustomRendererCommand", (Action<TestCommand>)delegate(TestCommand recvCmd)
			{
				_logCallback.Invoke($"TestCustomRendererCommand: {recvCmd?.Value}, {recvCmd?.Text}, {recvCmd?.Time}");
			});
			TestCommand testCommand = new TestCommand();
			testCommand.Value = 2932uL;
			testCommand.Text = "Hello world";
			testCommand.Time = global::System.DateTime.Now;
			_messenger.SendObject<TestCommand>("TestCustomRendererCommand", testCommand);
		}

		private static void TestPackable()
		{
			_messenger.ReceiveObject<TestPackable>("TestPackable", delegate(TestPackable recvObj)
			{
				_logCallback.Invoke($"TestPackable: {recvObj?.Value}");
			});
			TestPackable testPackable = new TestPackable();
			testPackable.Value = 72u;
			_messenger.SendObject("TestPackable", testPackable);
		}

		private static void TestStruct()
		{
			_messenger.ReceiveValue<TestStruct>("TestStruct", delegate(TestStruct recvStruct)
			{
				_logCallback.Invoke($"TestStruct: {recvStruct.Value}");
			});
			TestStruct value = default(TestStruct);
			value.Value = 4;
			_messenger.SendValue("TestStruct", value);
		}

		private static void TestNestedStruct()
		{
			_messenger.ReceiveValue<TestNestedStruct>("TestNestedStruct", delegate(TestNestedStruct recvNestedStruct)
			{
				_logCallback.Invoke($"TestNestedStruct: {recvNestedStruct.Nested.Value}");
			});
			TestStruct nested = default(TestStruct);
			TestNestedStruct value = default(TestNestedStruct);
			value.Nested = nested;
			_messenger.SendValue("TestNestedStruct", value);
		}

		private static void TestUnregisteredCommand()
		{
			_messenger.ReceiveObject<UnregisteredCommand>("UnregisteredCommand", (Action<UnregisteredCommand>)delegate
			{
				_logCallback.Invoke("UnregisteredCommand");
			});
			UnregisteredCommand obj = new UnregisteredCommand();
			_messenger.SendObject<UnregisteredCommand>("UnregisteredCommand", obj);
		}

		private static void TestUnregisteredPackable()
		{
			_messenger.ReceiveValue<UnregisteredPackable>("UnregisteredPackable", delegate
			{
				_logCallback.Invoke("UnregisteredPackable");
			});
			_messenger.SendValue("UnregisteredPackable", default(UnregisteredPackable));
		}

		private static void TestUnregisteredStruct()
		{
			_messenger.ReceiveValue<UnregisteredStruct>("UnregisteredStruct", delegate
			{
				_logCallback.Invoke("UnregisteredStruct");
			});
			_messenger.SendValue("UnregisteredStruct", default(UnregisteredStruct));
		}

		private static void TestValueList()
		{
			_messenger.ReceiveValueList<float>("TestValueList", (Action<List<float>>)delegate(List<float> list)
			{
				_logCallback.Invoke("TestValueList: " + string.Join<float>(",", (global::System.Collections.Generic.IEnumerable<float>)list));
			});
			List<float> val = new List<float>();
			val.Add(2f);
			val.Add(7f);
			val.Add(21f);
			_messenger.SendValueList<float>("TestValueList", val);
		}

		private static void TestValueHashSet()
		{
			_messenger.ReceiveValueHashSet<float>("TestValueHashSet", (Action<HashSet<float>>)delegate(HashSet<float> list)
			{
				_logCallback.Invoke("TestValueHashSet: " + string.Join<float>(",", (global::System.Collections.Generic.IEnumerable<float>)list));
			});
			HashSet<float> val = new HashSet<float>();
			val.Add(99.92f);
			val.Add(127.2f);
			val.Add(-4.32f);
			_messenger.SendValueHashSet<float>("TestValueHashSet", val);
		}

		private static void TestObjectList()
		{
			_messenger.ReceiveObjectList<TestPackable>("TestObjectList", delegate(List<TestPackable> list)
			{
				_logCallback.Invoke("TestObjectList: " + string.Join<TestPackable>(",", (global::System.Collections.Generic.IEnumerable<TestPackable>)list));
			});
			List<TestPackable> val = new List<TestPackable>();
			val.Add(new TestPackable
			{
				Value = 7u
			});
			val.Add(new TestPackable
			{
				Value = 15u
			});
			val.Add(new TestPackable
			{
				Value = 83u
			});
			_messenger.SendObjectList<TestPackable>("TestObjectList", val);
		}

		private static void TestStringList()
		{
			_messenger.ReceiveStringList("TestStringList", delegate(List<string>? list)
			{
				_logCallback.Invoke("TestStringList: " + string.Join(",", Enumerable.Select<string, string>((global::System.Collections.Generic.IEnumerable<string>)list, (Func<string, string>)((string s) => s ?? "NULL"))));
			});
			List<string> val = new List<string>();
			val.Add("Hello");
			val.Add("World");
			val.Add("owo");
			val.Add((string)null);
			val.Add("x3");
			_messenger.SendStringList("TestStringList", val);
		}

		private static void TestVanillaObject()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			_messenger.ReceiveObject<RendererInitData>("TestVanillaObject", (Action<RendererInitData>)delegate(RendererInitData recv)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestVanillaObject: {recv.sharedMemoryPrefix} {recv.uniqueSessionId} {recv.mainProcessId} {recv.debugFramePacing} {recv.outputDevice} {recv.setWindowIcon} {recv.splashScreenOverride}");
			});
			RendererInitData obj = new RendererInitData();
			_messenger.SendObject<RendererInitData>("TestVanillaObject", obj);
		}

		private static void TestUnregisteredVanillaObject()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			_messenger.ReceiveObject<QualityConfig>("TestUnregisteredVanillaObject", (Action<QualityConfig>)delegate(QualityConfig recv)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				_logCallback.Invoke($"TestUnregisteredVanillaObject: {recv.perPixelLights} {recv.shadowCascades} {recv.shadowResolution} {recv.shadowDistance} {recv.skinWeightMode}");
			});
			QualityConfig obj = new QualityConfig();
			_messenger.SendObject<QualityConfig>("TestUnregisteredVanillaObject", obj);
		}
	}
	public class TestCommand : RendererCommand
	{
		public ulong Value;

		public string Text = "";

		public global::System.DateTime Time;

		public override void Pack(ref MemoryPacker packer)
		{
			((MemoryPacker)(ref packer)).Write<ulong>(Value);
			((MemoryPacker)(ref packer)).Write(Text);
			((MemoryPacker)(ref packer)).Write<global::System.DateTime>(Time);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			((MemoryUnpacker)(ref unpacker)).Read<ulong>(ref Value);
			((MemoryUnpacker)(ref unpacker)).Read(ref Text);
			((MemoryUnpacker)(ref unpacker)).Read<global::System.DateTime>(ref Time);
		}
	}
	public class TestNestedPackable : IMemoryPackable
	{
		public byte Value;

		public TestCommand? Obj;

		public void Pack(ref MemoryPacker packer)
		{
			((MemoryPacker)(ref packer)).Write<byte>(Value);
			((MemoryPacker)(ref packer)).WriteObject<TestCommand>(Obj);
		}

		public void Unpack(ref MemoryUnpacker unpacker)
		{
			((MemoryUnpacker)(ref unpacker)).Read<byte>(ref Value);
			((MemoryUnpacker)(ref unpacker)).ReadObject<TestCommand>(ref Obj);
		}
	}
	public class TestPackable : IMemoryPackable
	{
		public uint Value;

		public void Pack(ref MemoryPacker packer)
		{
			((MemoryPacker)(ref packer)).Write<uint>(Value);
		}

		public void Unpack(ref MemoryUnpacker unpacker)
		{
			((MemoryUnpacker)(ref unpacker)).Read<uint>(ref Value);
		}

		public override string ToString()
		{
			return $"TestPackable: {Value}";
		}
	}
	public struct TestStruct
	{
		public int Value;
	}
	public struct TestNestedStruct
	{
		public TestStruct Nested;
	}
	public class InvalidType
	{
		public global::System.Exception? Exception;
	}
	public struct StructWithObject
	{
		public Assembly Assembly;
	}
	[StructLayout(0, Size = 1)]
	public struct UnregisteredPackable : IMemoryPackable
	{
		public void Pack(ref MemoryPacker packer)
		{
		}

		public void Unpack(ref MemoryUnpacker unpacker)
		{
		}
	}
	public class UnregisteredCommand : RendererCommand
	{
		public override void Pack(ref MemoryPacker packer)
		{
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
		}
	}
	public struct UnregisteredStruct
	{
		public byte Value;
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : global::System.Collections.IEnumerable, global::System.Collections.ICollection, global::System.Collections.IList, global::System.Collections.Generic.IEnumerable<T>, global::System.Collections.Generic.IReadOnlyCollection<T>, global::System.Collections.Generic.IReadOnlyList<T>, global::System.Collections.Generic.ICollection<T>, global::System.Collections.Generic.IList<T>
{
	int global::System.Collections.ICollection.Count => _items.Length;

	bool global::System.Collections.ICollection.IsSynchronized => false;

	object global::System.Collections.ICollection.SyncRoot => this;

	object global::System.Collections.IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			throw new NotSupportedException();
		}
	}

	bool global::System.Collections.IList.IsFixedSize => true;

	bool global::System.Collections.IList.IsReadOnly => true;

	int global::System.Collections.Generic.IReadOnlyCollection<T>.Count => _items.Length;

	T global::System.Collections.Generic.IReadOnlyList<T>.this[int index] => _items[index];

	int global::System.Collections.Generic.ICollection<T>.Count => _items.Length;

	bool global::System.Collections.Generic.ICollection<T>.IsReadOnly => true;

	T global::System.Collections.Generic.IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
	{
		return ((global::System.Collections.IEnumerable)(object)_items).GetEnumerator();
	}

	void global::System.Collections.ICollection.CopyTo(global::System.Array array, int index)
	{
		((global::System.Collections.ICollection)(object)_items).CopyTo(array, index);
	}

	int global::System.Collections.IList.Add(object? value)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.IList.Clear()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	bool global::System.Collections.IList.Contains(object? value)
	{
		return ((global::System.Collections.IList)(object)_items).Contains(value);
	}

	int global::System.Collections.IList.IndexOf(object? value)
	{
		return ((global::System.Collections.IList)(object)_items).IndexOf(value);
	}

	void global::System.Collections.IList.Insert(int index, object? value)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.IList.Remove(object? value)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.IList.RemoveAt(int index)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	global::System.Collections.Generic.IEnumerator<T> global::System.Collections.Generic.IEnumerable<T>.GetEnumerator()
	{
		return ((global::System.Collections.Generic.IEnumerable<T>)_items).GetEnumerator();
	}

	void global::System.Collections.Generic.ICollection<T>.Add(T item)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.Generic.ICollection<T>.Clear()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	bool global::System.Collections.Generic.ICollection<T>.Contains(T item)
	{
		return ((global::System.Collections.Generic.ICollection<T>)_items).Contains(item);
	}

	void global::System.Collections.Generic.ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((global::System.Collections.Generic.ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool global::System.Collections.Generic.ICollection<T>.Remove(T item)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	int global::System.Collections.Generic.IList<T>.IndexOf(T item)
	{
		return ((global::System.Collections.Generic.IList<T>)_items).IndexOf(item);
	}

	void global::System.Collections.Generic.IList<T>.Insert(int index, T item)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.Generic.IList<T>.RemoveAt(int index)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}
}

plugins/InterprocessLib.BepisLoader/InterprocessLib.BepisLoader_Extensions.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx.Configuration;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("Nytra")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+659a967631415d299bfd5408909e1d7a3d01d3d6")]
[assembly: AssemblyProduct("InterprocessLib.BepisLoader_Extensions")]
[assembly: AssemblyTitle("InterprocessLib.BepisLoader_Extensions")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Nytra/ResoniteInterprocessLib")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace InterprocessLib;

public static class BepInExExtensions
{
	private static Dictionary<ConfigEntryBase, bool> _syncStates = new Dictionary<ConfigEntryBase, bool>();

	public static void SyncConfigEntry<T>(this Messenger messenger, ConfigEntry<T> configEntry) where T : unmanaged
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		ConfigEntry<T> configEntry2 = configEntry;
		Messenger messenger2 = messenger;
		_syncStates[(ConfigEntryBase)(object)configEntry2] = true;
		if (Messenger.IsAuthority)
		{
			messenger2.SendConfigEntry<T>(configEntry2);
		}
		configEntry2.SettingChanged += (EventHandler)delegate
		{
			bool flag = default(bool);
			if (_syncStates.TryGetValue((ConfigEntryBase)(object)configEntry2, ref flag) && flag)
			{
				messenger2.SendConfigEntry<T>(configEntry2);
			}
		};
		messenger2.ReceiveConfigEntry<T>(configEntry2);
	}

	public static void SyncConfigEntry(this Messenger messenger, ConfigEntry<string> configEntry)
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		ConfigEntry<string> configEntry2 = configEntry;
		Messenger messenger2 = messenger;
		_syncStates[(ConfigEntryBase)(object)configEntry2] = true;
		if (Messenger.IsAuthority)
		{
			messenger2.SendConfigEntry(configEntry2);
		}
		configEntry2.SettingChanged += (EventHandler)delegate
		{
			bool flag = default(bool);
			if (_syncStates.TryGetValue((ConfigEntryBase)(object)configEntry2, ref flag) && flag)
			{
				messenger2.SendConfigEntry(configEntry2);
			}
		};
		messenger2.ReceiveConfigEntry(configEntry2);
	}

	public static void SendConfigEntry<T>(this Messenger messenger, ConfigEntry<T> configEntry) where T : unmanaged
	{
		messenger.SendValue<T>(((ConfigEntryBase)configEntry).Definition.Key, configEntry.Value);
	}

	public static void SendConfigEntry(this Messenger messenger, ConfigEntry<string> configEntry)
	{
		messenger.SendString(((ConfigEntryBase)configEntry).Definition.Key, configEntry.Value);
	}

	public static void ReceiveConfigEntry<T>(this Messenger messenger, ConfigEntry<T> configEntry) where T : unmanaged
	{
		ConfigEntry<T> configEntry2 = configEntry;
		messenger.ReceiveValue<T>(((ConfigEntryBase)configEntry2).Definition.Key, (Action<T>)delegate(T val)
		{
			_syncStates[(ConfigEntryBase)(object)configEntry2] = false;
			configEntry2.Value = val;
			_syncStates[(ConfigEntryBase)(object)configEntry2] = true;
		});
	}

	public static void ReceiveConfigEntry(this Messenger messenger, ConfigEntry<string> configEntry)
	{
		ConfigEntry<string> configEntry2 = configEntry;
		messenger.ReceiveString(((ConfigEntryBase)configEntry2).Definition.Key, (Action<string>)delegate(string? str)
		{
			_syncStates[(ConfigEntryBase)(object)configEntry2] = false;
			configEntry2.Value = str;
			_syncStates[(ConfigEntryBase)(object)configEntry2] = true;
		});
	}
}

Renderer/BepInEx/plugins/InterprocessLib.BepInEx/InterprocessLib.Unity.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Renderite.Shared;
using Renderite.Unity;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Nytra")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1+659a967631415d299bfd5408909e1d7a3d01d3d6")]
[assembly: AssemblyProduct("InterprocessLib.Unity")]
[assembly: AssemblyTitle("InterprocessLib.Unity")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Nytra/ResoniteInterprocessLib")]
[assembly: AssemblyVersion("2.0.1.0")]
[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 IsUnmanagedAttribute : 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 InterprocessLib
{
	internal static class UnityInit
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__InitLoop;

			public static RenderCommandHandler <1>__CommandHandler;
		}

		private static void CommandHandler(RendererCommand command, int messageSize)
		{
			if (!Messenger.IsInitialized && command is MessengerReadyCommand)
			{
				Messenger.FinishInitialization();
			}
		}

		public static void Init()
		{
			if (Messenger.Host != null)
			{
				throw new InvalidOperationException("Messenger has already been initialized!");
			}
			Task.Run((Action)InitLoop);
		}

		private static async void InitLoop()
		{
			if (RenderingManager.Instance == null)
			{
				await Task.Delay(1);
				InitLoop();
				return;
			}
			MethodInfo method = typeof(RenderingManager).GetMethod("GetConnectionParameters", BindingFlags.Instance | BindingFlags.NonPublic);
			object[] array = new object[2] { "", 0L };
			if (!(bool)method.Invoke(RenderingManager.Instance, array))
			{
				throw new ArgumentException("Could not get connection parameters from RenderingManager!");
			}
			Messenger.OnWarning = delegate(string msg)
			{
				Debug.LogWarning((object)("[InterprocessLib] [WARN] " + msg));
			};
			Messenger.OnFailure = delegate(Exception ex)
			{
				Debug.LogError((object)$"[InterprocessLib] [ERROR] Error in InterprocessLib Messaging Host!\n{ex}");
			};
			Messenger.IsAuthority = false;
			bool isAuthority = Messenger.IsAuthority;
			string queueName = (string)array[0];
			long queueCapacity = (long)array[1];
			PackerMemoryPool instance = PackerMemoryPool.Instance;
			object obj = <>O.<1>__CommandHandler;
			if (obj == null)
			{
				RenderCommandHandler val = CommandHandler;
				<>O.<1>__CommandHandler = val;
				obj = (object)val;
			}
			Messenger.Host = new MessagingHost(isAuthority, queueName, queueCapacity, (IMemoryPackerEntityPool)(object)instance, (RenderCommandHandler?)obj, Messenger.OnFailure, Messenger.OnWarning, Messenger.OnDebug);
		}
	}
	internal abstract class IdentifiableCommand : RendererCommand
	{
		internal string Owner = "";

		public string Id = "";

		public static void InitNewTypes(List<Type> types)
		{
			PolymorphicMemoryPackableEntity<RendererCommand>.InitTypes(types);
		}

		public override void Pack(ref MemoryPacker packer)
		{
			((MemoryPacker)(ref packer)).Write(Owner);
			((MemoryPacker)(ref packer)).Write(Id);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			((MemoryUnpacker)(ref unpacker)).Read(ref Owner);
			((MemoryUnpacker)(ref unpacker)).Read(ref Id);
		}

		public override string ToString()
		{
			return "IdentifiableCommand:" + Owner + ":" + Id;
		}
	}
	internal abstract class CollectionCommand : IdentifiableCommand
	{
		public abstract IEnumerable? UntypedCollection { get; }

		public abstract Type InnerDataType { get; }

		public abstract Type CollectionType { get; }

		public override string ToString()
		{
			return "CollectionCommand:" + CollectionType.Name + "<" + InnerDataType.Name + ">:" + Owner + ":" + Id + ":" + (UntypedCollection?.ToString() ?? "NULL");
		}
	}
	internal abstract class ValueCommand : IdentifiableCommand
	{
		public abstract object UntypedValue { get; }

		public abstract Type ValueType { get; }

		public override string ToString()
		{
			return $"ValueCommand<{ValueType.Name}>:{Owner}:{Id}:{UntypedValue}";
		}
	}
	internal abstract class ObjectCommand : IdentifiableCommand
	{
		public abstract object? UntypedObject { get; }

		public abstract Type ObjectType { get; }

		public override string ToString()
		{
			return "ObjectCommand<" + ObjectType.Name + ">:" + Owner + ":" + Id + ":" + (UntypedObject?.ToString() ?? "NULL");
		}
	}
	internal sealed class EmptyCommand : IdentifiableCommand
	{
		public override string ToString()
		{
			return "EmptyCommand:" + Owner + ":" + Id;
		}
	}
	internal sealed class ValueCollectionCommand<C, T> : CollectionCommand where C : ICollection<T>, new() where T : unmanaged
	{
		public C? Values;

		public override IEnumerable? UntypedCollection => Values;

		public override Type InnerDataType => typeof(T);

		public override Type CollectionType => typeof(C);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).WriteValueList<C, T>(Values);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).ReadValueList<C, T>(ref Values);
		}
	}
	internal sealed class StringListCommand : CollectionCommand
	{
		public List<string>? Values;

		public override IEnumerable? UntypedCollection => Values;

		public override Type InnerDataType => typeof(string);

		public override Type CollectionType => typeof(List<string>);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).WriteStringList(Values);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).ReadStringList(ref Values);
		}
	}
	internal sealed class ObjectListCommand<T> : CollectionCommand where T : class, IMemoryPackable, new()
	{
		public List<T>? Values;

		public override IEnumerable? UntypedCollection => Values;

		public override Type InnerDataType => typeof(T);

		public override Type CollectionType => typeof(List<T>);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).WriteObjectList<T>(Values);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).ReadObjectList<T>(ref Values);
		}
	}
	internal sealed class ObjectCommand<T> : ObjectCommand where T : class, IMemoryPackable, new()
	{
		public T? Object;

		public override object? UntypedObject => Object;

		public override Type ObjectType => typeof(T);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).WriteObject<T>(Object);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).ReadObject<T>(ref Object);
		}
	}
	internal sealed class ValueCommand<T> : ValueCommand where T : unmanaged
	{
		public T Value;

		public override object UntypedValue => Value;

		public override Type ValueType => typeof(T);

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).Write<T>(Value);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).Read<T>(ref Value);
		}
	}
	internal sealed class StringCommand : IdentifiableCommand
	{
		public string? String;

		public override void Pack(ref MemoryPacker packer)
		{
			base.Pack(ref packer);
			((MemoryPacker)(ref packer)).Write(String);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			base.Unpack(ref unpacker);
			((MemoryUnpacker)(ref unpacker)).Read(ref String);
		}

		public override string ToString()
		{
			return "StringCommand:" + Owner + ":" + Id + ":" + (String ?? "NULL");
		}
	}
	internal sealed class MessengerReadyCommand : RendererCommand
	{
		public override void Pack(ref MemoryPacker packer)
		{
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
		}

		public override string ToString()
		{
			return "MessengerReadyCommand";
		}
	}
	internal class MessagingHost
	{
		private struct OwnerData
		{
			public readonly Dictionary<string, object?> ValueCallbacks;

			public readonly Dictionary<string, Action<string?>?> StringCallbacks;

			public readonly Dictionary<string, Action?> EmptyCallbacks;

			public readonly Dictionary<string, object?> ObjectCallbacks;

			public readonly Dictionary<string, object?> ValueCollectionCallbacks;

			public readonly Dictionary<string, Action<List<string>?>?> StringListCallbacks;

			public readonly Dictionary<string, object?> ObjectListCallbacks;

			public OwnerData()
			{
				ValueCallbacks = new Dictionary<string, object>();
				StringCallbacks = new Dictionary<string, Action<string>>();
				EmptyCallbacks = new Dictionary<string, Action>();
				ObjectCallbacks = new Dictionary<string, object>();
				ValueCollectionCallbacks = new Dictionary<string, object>();
				StringListCallbacks = new Dictionary<string, Action<List<string>>>();
				ObjectListCallbacks = new Dictionary<string, object>();
			}
		}

		private MessagingManager _primary;

		private static MethodInfo? _handleValueCommandMethod;

		private static MethodInfo? _handleValueCollectionCommandMethod;

		private static MethodInfo? _handleObjectCommandMethod;

		private static MethodInfo? _handleObjectListCommandMethod;

		private Dictionary<string, OwnerData> _ownerData = new Dictionary<string, OwnerData>();

		public bool IsAuthority { get; }

		public string QueueName { get; }

		public long QueueCapacity { get; }

		private RenderCommandHandler? OnCommandReceived { get; }

		private Action<string>? OnWarning { get; }

		private Action<string>? OnDebug { get; }

		private Action<Exception>? OnFailure { get; }

		public void RegisterOwner(string ownerName)
		{
			OwnerData value = new OwnerData();
			_ownerData.Add(ownerName, value);
		}

		public void RegisterValueCallback<T>(string owner, string id, Action<T> callback) where T : unmanaged
		{
			_ownerData[owner].ValueCallbacks[id] = callback;
		}

		public void RegisterValueCollectionCallback<C, T>(string owner, string id, Action<C> callback) where C : ICollection<T>, new() where T : unmanaged
		{
			_ownerData[owner].ValueCollectionCallbacks[id] = callback;
		}

		public void RegisterStringCallback(string owner, string id, Action<string?> callback)
		{
			_ownerData[owner].StringCallbacks[id] = callback;
		}

		public void RegisterStringListCallback(string owner, string id, Action<List<string>?>? callback)
		{
			_ownerData[owner].StringListCallbacks[id] = callback;
		}

		public void RegisterEmptyCallback(string owner, string id, Action callback)
		{
			_ownerData[owner].EmptyCallbacks[id] = callback;
		}

		public void RegisterObjectCallback<T>(string owner, string id, Action<T> callback) where T : class, IMemoryPackable, new()
		{
			_ownerData[owner].ObjectCallbacks[id] = callback;
		}

		public void RegisterObjectListCallback<T>(string owner, string id, Action<List<T>> callback) where T : class, IMemoryPackable, new()
		{
			_ownerData[owner].ObjectListCallbacks[id] = callback;
		}

		static MessagingHost()
		{
			_handleValueCommandMethod = typeof(MessagingHost).GetMethod("HandleValueCommand", BindingFlags.Instance | BindingFlags.NonPublic);
			_handleValueCollectionCommandMethod = typeof(MessagingHost).GetMethod("HandleValueCollectionCommand", BindingFlags.Instance | BindingFlags.NonPublic);
			_handleObjectCommandMethod = typeof(MessagingHost).GetMethod("HandleObjectCommand", BindingFlags.Instance | BindingFlags.NonPublic);
			_handleObjectListCommandMethod = typeof(MessagingHost).GetMethod("HandleObjectListCommand", BindingFlags.Instance | BindingFlags.NonPublic);
			TypeManager.InitializeCoreTypes();
		}

		public MessagingHost(bool isAuthority, string queueName, long queueCapacity, IMemoryPackerEntityPool pool, RenderCommandHandler? commandHandler, Action<Exception>? failhandler, Action<string>? warnHandler, Action<string>? debugHandler)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			IsAuthority = isAuthority;
			QueueName = queueName + "InterprocessLib";
			QueueCapacity = queueCapacity;
			OnDebug = debugHandler;
			OnWarning = warnHandler;
			OnFailure = failhandler;
			OnCommandReceived = commandHandler;
			_primary = new MessagingManager(pool);
			_primary.CommandHandler = new RenderCommandHandler(CommandHandler);
			_primary.FailureHandler = delegate(Exception ex)
			{
				OnFailure?.Invoke(ex);
			};
			_primary.WarningHandler = delegate(string msg)
			{
				OnWarning?.Invoke(msg);
			};
			_primary.Connect(queueName, isAuthority, queueCapacity);
		}

		private void HandleValueCommand<T>(ValueCommand<T> command) where T : unmanaged
		{
			if (_ownerData[command.Owner].ValueCallbacks.TryGetValue(command.Id, out object value))
			{
				if (value != null)
				{
					((Action<T>)value)(command.Value);
				}
				return;
			}
			OnWarning?.Invoke("ValueCommand<" + typeof(T).Name + "> with Id \"" + command.Id + "\" is not registered to receive a callback!");
		}

		private void HandleValueCollectionCommand<C, T>(ValueCollectionCommand<C, T> command) where C : ICollection<T>, new() where T : unmanaged
		{
			if (_ownerData[command.Owner].ValueCollectionCallbacks.TryGetValue(command.Id, out object value))
			{
				if (value != null)
				{
					((Action<C>)value)(command.Values);
				}
				return;
			}
			OnWarning?.Invoke("ValueCollectionCommand<" + typeof(C).Name + ", " + typeof(T).Name + "> with Id \"" + command.Id + "\" is not registered to receive a callback!");
		}

		private void HandleStringCommand(StringCommand command)
		{
			if (_ownerData[command.Owner].StringCallbacks.TryGetValue(command.Id, out Action<string> value))
			{
				value?.Invoke(command.String);
			}
			else
			{
				OnWarning?.Invoke("StringCommand with Id \"" + command.Id + "\" is not registered to receive a callback!");
			}
		}

		private void HandleStringListCommand(StringListCommand command)
		{
			if (_ownerData[command.Owner].StringListCallbacks.TryGetValue(command.Id, out Action<List<string>> value))
			{
				value?.Invoke(command.Values);
			}
			else
			{
				OnWarning?.Invoke("StringListCommand with Id \"" + command.Id + "\" is not registered to receive a callback!");
			}
		}

		private void HandleEmptyCommand(EmptyCommand command)
		{
			if (_ownerData[command.Owner].EmptyCallbacks.TryGetValue(command.Id, out Action value))
			{
				value?.Invoke();
			}
			else
			{
				OnWarning?.Invoke("EmptyCommand with Id \"" + command.Id + "\" is not registered to receive a callback!");
			}
		}

		private void HandleObjectCommand<T>(ObjectCommand<T> command) where T : class, IMemoryPackable, new()
		{
			if (_ownerData[command.Owner].ObjectCallbacks.TryGetValue(command.Id, out object value))
			{
				if (value != null)
				{
					((Action<T>)value)((T)command.UntypedObject);
				}
				return;
			}
			OnWarning?.Invoke("ObjectCommand<" + command.ObjectType.Name + "> with Id \"" + command.Id + "\" is not registered to receive a callback!");
		}

		private void HandleObjectListCommand<T>(ObjectListCommand<T> command) where T : class, IMemoryPackable, new()
		{
			if (_ownerData[command.Owner].ObjectListCallbacks.TryGetValue(command.Id, out object value))
			{
				if (value != null)
				{
					((Action<List<T>>)value)(command.Values);
				}
				return;
			}
			OnWarning?.Invoke("ObjectListCommand<" + typeof(T).Name + "> with Id \"" + command.Id + "\" is not registered to receive a callback!");
		}

		private void CommandHandler(RendererCommand command, int messageSize)
		{
			OnDebug?.Invoke($"Received {command}");
			RenderCommandHandler? onCommandReceived = OnCommandReceived;
			if (onCommandReceived != null)
			{
				onCommandReceived.Invoke(command, messageSize);
			}
			if (command is IdentifiableCommand identifiableCommand && !_ownerData.TryGetValue(identifiableCommand.Owner, out var _))
			{
				OnWarning?.Invoke("Owner \"" + identifiableCommand.Owner + "\" is not registered!");
			}
			else if (command is ValueCommand valueCommand)
			{
				Type valueType = valueCommand.ValueType;
				_handleValueCommandMethod.MakeGenericMethod(valueType).Invoke(this, new object[1] { command });
			}
			else if (command is CollectionCommand collectionCommand)
			{
				Type innerDataType = collectionCommand.InnerDataType;
				if (innerDataType == typeof(string))
				{
					HandleStringListCommand((StringListCommand)collectionCommand);
				}
				else if (innerDataType.IsValueType)
				{
					Type collectionType = collectionCommand.CollectionType;
					_handleValueCollectionCommandMethod.MakeGenericMethod(collectionType, innerDataType).Invoke(this, new object[1] { command });
				}
				else
				{
					_handleObjectListCommandMethod.MakeGenericMethod(innerDataType).Invoke(this, new object[1] { command });
				}
			}
			else if (command is ObjectCommand objectCommand)
			{
				Type objectType = objectCommand.ObjectType;
				_handleObjectCommandMethod.MakeGenericMethod(objectType).Invoke(this, new object[1] { command });
			}
			else if (!(command is StringCommand))
			{
				if (!(command is EmptyCommand))
				{
					if (command is IdentifiableCommand identifiableCommand2)
					{
						OnWarning?.Invoke("Received unrecognized IdentifiableCommand of type " + ((object)command).GetType().Name + ": " + identifiableCommand2.Owner + ":" + identifiableCommand2.Id);
					}
				}
				else
				{
					HandleEmptyCommand((EmptyCommand)(object)command);
				}
			}
			else
			{
				HandleStringCommand((StringCommand)(object)command);
			}
		}

		public void SendCommand(RendererCommand command)
		{
			OnDebug?.Invoke($"Sending {command}");
			_primary.SendCommand(command);
		}
	}
	public class Messenger
	{
		internal static MessagingHost? Host;

		internal static bool InitStarted = false;

		internal static Action<Exception>? OnFailure;

		internal static Action<string>? OnWarning;

		internal static Action<string>? OnDebug;

		private static List<Action>? _postInitActions = new List<Action>();

		private string _ownerId;

		private static HashSet<string> _registeredOwnerIds = new HashSet<string>();

		private List<Type>? _additionalObjectTypes;

		private List<Type>? _additionalValueTypes;

		public static bool IsInitialized
		{
			get
			{
				if (Host != null)
				{
					return _postInitActions == null;
				}
				return false;
			}
		}

		public static bool IsAuthority { get; internal set; }

		public Messenger(string ownerId, List<Type>? additionalObjectTypes = null, List<Type>? additionalValueTypes = null)
		{
			if (ownerId == null)
			{
				throw new ArgumentNullException("ownerId");
			}
			_ownerId = ownerId;
			_additionalObjectTypes = additionalObjectTypes;
			_additionalValueTypes = additionalValueTypes;
			if (_additionalObjectTypes != null)
			{
				TypeManager.InitObjectTypeList(_additionalObjectTypes.Where((Type t) => !TypeManager.IsObjectTypeInitialized(t)).ToList());
			}
			if (_additionalValueTypes != null)
			{
				TypeManager.InitValueTypeList(_additionalValueTypes.Where((Type t) => !TypeManager.IsValueTypeInitialized(t)).ToList());
			}
			if (!_registeredOwnerIds.Contains(ownerId))
			{
				_registeredOwnerIds.Add(ownerId);
				if (IsInitialized)
				{
					Register();
				}
				else
				{
					RunPostInit(Register);
				}
			}
			else
			{
				OnWarning?.Invoke("A messenger with id " + ownerId + " has already been created in this process!");
			}
			if (Host != null || InitStarted)
			{
				return;
			}
			InitStarted = true;
			Type type = Type.GetType("InterprocessLib.FrooxEngineInit");
			if ((object)type != null)
			{
				type.GetMethod("Init", BindingFlags.Static | BindingFlags.Public).Invoke(null, null);
				return;
			}
			Type type2 = Type.GetType("InterprocessLib.UnityInit");
			if ((object)type2 != null)
			{
				type2.GetMethod("Init", BindingFlags.Static | BindingFlags.Public).Invoke(null, null);
				return;
			}
			throw new EntryPointNotFoundException("Could not find InterprocessLib initialization type!");
		}

		private void Register()
		{
			Host.RegisterOwner(_ownerId);
		}

		internal static void FinishInitialization()
		{
			if (IsAuthority)
			{
				Host.SendCommand((RendererCommand)(object)new MessengerReadyCommand());
			}
			Action[] array = _postInitActions.ToArray();
			_postInitActions = null;
			Action[] array2 = array;
			foreach (Action action in array2)
			{
				try
				{
					action();
				}
				catch (Exception arg)
				{
					OnWarning?.Invoke($"Exception running post-init action:\n{arg}");
				}
			}
		}

		private static void RunPostInit(Action act)
		{
			if (!IsInitialized)
			{
				_postInitActions.Add(act);
				return;
			}
			throw new InvalidOperationException("Already initialized!");
		}

		public void SendValue<T>(string id, T value) where T : unmanaged
		{
			string id2 = id;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					SendValue(id2, value);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + value.GetType().Name + " needs to be registered first!");
			}
			ValueCommand<T> valueCommand = new ValueCommand<T>();
			valueCommand.Owner = _ownerId;
			valueCommand.Id = id2;
			valueCommand.Value = value;
			Host.SendCommand((RendererCommand)(object)valueCommand);
		}

		public void SendValueList<T>(string id, List<T> list) where T : unmanaged
		{
			string id2 = id;
			List<T> list2 = list;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					SendValueList(id2, list2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			ValueCollectionCommand<List<T>, T> valueCollectionCommand = new ValueCollectionCommand<List<T>, T>();
			valueCollectionCommand.Owner = _ownerId;
			valueCollectionCommand.Id = id2;
			valueCollectionCommand.Values = list2;
			Host.SendCommand((RendererCommand)(object)valueCollectionCommand);
		}

		public void SendValueHashSet<T>(string id, HashSet<T> hashSet) where T : unmanaged
		{
			string id2 = id;
			HashSet<T> hashSet2 = hashSet;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					SendValueHashSet(id2, hashSet2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			ValueCollectionCommand<HashSet<T>, T> valueCollectionCommand = new ValueCollectionCommand<HashSet<T>, T>();
			valueCollectionCommand.Owner = _ownerId;
			valueCollectionCommand.Id = id2;
			valueCollectionCommand.Values = hashSet2;
			Host.SendCommand((RendererCommand)(object)valueCollectionCommand);
		}

		public void SendString(string id, string str)
		{
			string id2 = id;
			string str2 = str;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					SendString(id2, str2);
				});
				return;
			}
			StringCommand stringCommand = new StringCommand();
			stringCommand.Owner = _ownerId;
			stringCommand.Id = id2;
			stringCommand.String = str2;
			Host.SendCommand((RendererCommand)(object)stringCommand);
		}

		public void SendStringList(string id, List<string> list)
		{
			string id2 = id;
			List<string> list2 = list;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					SendStringList(id2, list2);
				});
				return;
			}
			StringListCommand stringListCommand = new StringListCommand();
			stringListCommand.Owner = _ownerId;
			stringListCommand.Id = id2;
			stringListCommand.Values = list2;
			Host.SendCommand((RendererCommand)(object)stringListCommand);
		}

		public void SendEmptyCommand(string id)
		{
			string id2 = id;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					SendEmptyCommand(id2);
				});
				return;
			}
			EmptyCommand emptyCommand = new EmptyCommand();
			emptyCommand.Owner = _ownerId;
			emptyCommand.Id = id2;
			Host.SendCommand((RendererCommand)(object)emptyCommand);
		}

		public void SendObject<T>(string id, T? obj) where T : class, IMemoryPackable, new()
		{
			string id2 = id;
			T obj2 = obj;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					SendObject(id2, obj2);
				});
				return;
			}
			if (!TypeManager.IsObjectTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			ObjectCommand<T> objectCommand = new ObjectCommand<T>();
			objectCommand.Object = obj2;
			objectCommand.Owner = _ownerId;
			objectCommand.Id = id2;
			Host.SendCommand((RendererCommand)(object)objectCommand);
		}

		public void SendObjectList<T>(string id, List<T> list) where T : class, IMemoryPackable, new()
		{
			string id2 = id;
			List<T> list2 = list;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					SendObjectList(id2, list2);
				});
				return;
			}
			if (!TypeManager.IsObjectTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			ObjectListCommand<T> objectListCommand = new ObjectListCommand<T>();
			objectListCommand.Owner = _ownerId;
			objectListCommand.Id = id2;
			objectListCommand.Values = list2;
			Host.SendCommand((RendererCommand)(object)objectListCommand);
		}

		public void ReceiveValue<T>(string id, Action<T> callback) where T : unmanaged
		{
			string id2 = id;
			Action<T> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					ReceiveValue(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			Host.RegisterValueCallback(_ownerId, id2, callback2);
		}

		public void ReceiveValueList<T>(string id, Action<List<T>> callback) where T : unmanaged
		{
			string id2 = id;
			Action<List<T>> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					ReceiveValueList(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			Host.RegisterValueCollectionCallback<List<T>, T>(_ownerId, id2, callback2);
		}

		public void ReceiveValueHashSet<T>(string id, Action<HashSet<T>> callback) where T : unmanaged
		{
			string id2 = id;
			Action<HashSet<T>> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					ReceiveValueHashSet(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsValueTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			Host.RegisterValueCollectionCallback<HashSet<T>, T>(_ownerId, id2, callback2);
		}

		public void ReceiveString(string id, Action<string?> callback)
		{
			string id2 = id;
			Action<string?> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					ReceiveString(id2, callback2);
				});
			}
			else
			{
				Host.RegisterStringCallback(_ownerId, id2, callback2);
			}
		}

		public void ReceiveStringList(string id, Action<List<string>?>? callback)
		{
			string id2 = id;
			Action<List<string>?> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					ReceiveStringList(id2, callback2);
				});
			}
			else
			{
				Host.RegisterStringListCallback(_ownerId, id2, callback2);
			}
		}

		public void ReceiveEmptyCommand(string id, Action callback)
		{
			string id2 = id;
			Action callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					ReceiveEmptyCommand(id2, callback2);
				});
			}
			else
			{
				Host.RegisterEmptyCallback(_ownerId, id2, callback2);
			}
		}

		public void ReceiveObject<T>(string id, Action<T> callback) where T : class, IMemoryPackable, new()
		{
			string id2 = id;
			Action<T> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					ReceiveObject(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsObjectTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			Host.RegisterObjectCallback(_ownerId, id2, callback2);
		}

		public void ReceiveObjectList<T>(string id, Action<List<T>> callback) where T : class, IMemoryPackable, new()
		{
			string id2 = id;
			Action<List<T>> callback2 = callback;
			if (id2 == null)
			{
				throw new ArgumentNullException("id");
			}
			if (!IsInitialized)
			{
				RunPostInit(delegate
				{
					ReceiveObjectList(id2, callback2);
				});
				return;
			}
			if (!TypeManager.IsObjectTypeInitialized<T>())
			{
				throw new InvalidOperationException("Type " + typeof(T).Name + " needs to be registered first!");
			}
			Host.RegisterObjectListCallback(_ownerId, id2, callback2);
		}
	}
	internal static class TypeManager
	{
		private static readonly HashSet<Type> _registeredObjectTypes = new HashSet<Type>();

		private static readonly HashSet<Type> _registeredValueTypes = new HashSet<Type>();

		private static bool _initializedCoreTypes = false;

		internal static MethodInfo? RegisterValueTypeMethod = typeof(TypeManager).GetMethod("RegisterAdditionalValueType", BindingFlags.Static | BindingFlags.NonPublic);

		internal static MethodInfo? RegisterObjectTypeMethod = typeof(TypeManager).GetMethod("RegisterAdditionalObjectType", BindingFlags.Static | BindingFlags.NonPublic);

		internal static List<Type> NewTypes = new List<Type>();

		private static Type[] _valueTypes = new Type[15]
		{
			typeof(bool),
			typeof(byte),
			typeof(ushort),
			typeof(uint),
			typeof(ulong),
			typeof(sbyte),
			typeof(short),
			typeof(int),
			typeof(long),
			typeof(float),
			typeof(double),
			typeof(decimal),
			typeof(char),
			typeof(DateTime),
			typeof(TimeSpan)
		};

		private static List<Type> RegisteredTypesList => (List<Type>)typeof(PolymorphicMemoryPackableEntity<RendererCommand>).GetField("types", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);

		internal static void InitializeCoreTypes()
		{
			if (_initializedCoreTypes)
			{
				return;
			}
			TypeManager.RegisterAdditionalObjectType<MessengerReadyCommand>();
			TypeManager.RegisterAdditionalObjectType<EmptyCommand>();
			TypeManager.RegisterAdditionalObjectType<StringCommand>();
			TypeManager.RegisterAdditionalObjectType<StringListCommand>();
			Type[] valueTypes = _valueTypes;
			foreach (Type type in valueTypes)
			{
				try
				{
					RegisterValueTypeMethod.MakeGenericMethod(type).Invoke(null, null);
				}
				catch (Exception arg)
				{
					Messenger.OnWarning?.Invoke($"Could not register additional value type {type.Name}!\n{arg}");
				}
			}
			_initializedCoreTypes = true;
		}

		private static void PushNewTypes()
		{
			new EmptyCommand();
			List<Type> list = new List<Type>();
			list.AddRange(RegisteredTypesList);
			foreach (Type newType in NewTypes)
			{
				if (!list.Contains(newType))
				{
					list.Add(newType);
				}
			}
			IdentifiableCommand.InitNewTypes(list);
		}

		internal static void InitValueTypeList(List<Type> types)
		{
			foreach (Type type in types)
			{
				RegisterValueTypeMethod.MakeGenericMethod(type).Invoke(null, null);
			}
		}

		internal static void InitObjectTypeList(List<Type> types)
		{
			foreach (Type type in types)
			{
				RegisterObjectTypeMethod.MakeGenericMethod(type).Invoke(null, null);
			}
		}

		internal static bool IsValueTypeInitialized<T>() where T : unmanaged
		{
			return _registeredValueTypes.Contains(typeof(T));
		}

		internal static bool IsValueTypeInitialized(Type t)
		{
			return _registeredValueTypes.Contains(t);
		}

		internal static bool IsObjectTypeInitialized<T>() where T : class, IMemoryPackable, new()
		{
			return _registeredObjectTypes.Contains(typeof(T));
		}

		internal static bool IsObjectTypeInitialized(Type t)
		{
			return _registeredObjectTypes.Contains(t);
		}

		internal static void RegisterAdditionalValueType<T>() where T : unmanaged
		{
			Type typeFromHandle = typeof(T);
			if (_registeredValueTypes.Contains(typeFromHandle))
			{
				throw new InvalidOperationException("Type " + typeFromHandle.Name + " is already registered!");
			}
			if (typeFromHandle.ContainsGenericParameters)
			{
				throw new ArgumentException("Type must be a concrete type!");
			}
			Type type = typeof(ValueCommand<>).MakeGenericType(typeFromHandle);
			Type type2 = typeof(ValueCollectionCommand<, >).MakeGenericType(typeof(List<T>), typeFromHandle);
			Type type3 = typeof(ValueCollectionCommand<, >).MakeGenericType(typeof(HashSet<T>), typeFromHandle);
			NewTypes.AddRange(new <>z__ReadOnlyArray<Type>(new Type[3] { type, type2, type3 }));
			_registeredValueTypes.Add(typeFromHandle);
			PushNewTypes();
		}

		internal static void RegisterAdditionalObjectType<T>() where T : class, IMemoryPackable, new()
		{
			Type typeFromHandle = typeof(T);
			if (_registeredObjectTypes.Contains(typeFromHandle))
			{
				throw new InvalidOperationException("Type " + typeFromHandle.Name + " is already registered!");
			}
			if (typeFromHandle.ContainsGenericParameters)
			{
				throw new ArgumentException("Type must be a concrete type!");
			}
			if (typeFromHandle.IsSubclassOf(typeof(PolymorphicMemoryPackableEntity<RendererCommand>)))
			{
				NewTypes.Add(typeFromHandle);
			}
			Type type = typeof(ObjectCommand<>).MakeGenericType(typeFromHandle);
			Type type2 = typeof(ObjectListCommand<>).MakeGenericType(typeFromHandle);
			NewTypes.AddRange(new <>z__ReadOnlyArray<Type>(new Type[2] { type, type2 }));
			_registeredObjectTypes.Add(typeFromHandle);
			PushNewTypes();
		}
	}
}
namespace InterprocessLib.Tests
{
	public static class Tests
	{
		private static Messenger? _messenger;

		private static Messenger? _unknownMessenger;

		private static Action<string>? _logCallback;

		public static void RunTests(Messenger messenger, Messenger unknownMessenger, Action<string> logCallback)
		{
			_messenger = messenger;
			_unknownMessenger = unknownMessenger;
			_logCallback = logCallback;
			TestUnknownMessenger();
			TestUnknownCommandId();
			TestNullString();
			TestEmptyCommand();
			TestString();
			TestValue();
			TestNestedPackable();
			TestCustomRendererCommand();
			TestPackable();
			TestStruct();
			TestNestedStruct();
			TestValueList();
			TestValueHashSet();
			TestStringList();
			TestObjectList();
			TestVanillaObject();
			TestVanillaStruct();
			TestVanillaEnum();
			try
			{
				TestUnregisteredCommand();
			}
			catch (Exception ex)
			{
				logCallback("TestUnregisteredCommand threw an exception: " + ex.Message);
			}
			try
			{
				TestUnregisteredPackable();
			}
			catch (Exception ex2)
			{
				logCallback("TestUnregisteredPackable threw an exception: " + ex2.Message);
			}
			try
			{
				TestUnregisteredStruct();
			}
			catch (Exception ex3)
			{
				logCallback("TestUnregisteredStruct threw an exception: " + ex3.Message);
			}
			try
			{
				TestUnregisteredVanillaObject();
			}
			catch (Exception ex4)
			{
				logCallback("TestUnregisteredVanillaObject threw an exception: " + ex4.Message);
			}
			try
			{
				TestUnregisteredVanillaValue();
			}
			catch (Exception ex5)
			{
				logCallback("TestUnregisteredVanillaValue threw an exception: " + ex5.Message);
			}
		}

		private static void TestVanillaStruct()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			_messenger.ReceiveValue<HapticPointState>("TestVanillaStruct", (Action<HapticPointState>)delegate(HapticPointState val)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				_logCallback($"TestVanillaStruct: {val.force} {val.temperature} {val.pain} {val.vibration}");
			});
			HapticPointState value = default(HapticPointState);
			value.force = 8f;
			value.temperature = 4f;
			value.pain = 25f;
			value.vibration = 12f;
			_messenger.SendValue<HapticPointState>("TestVanillaStruct", value);
		}

		private static void TestVanillaEnum()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			_messenger.ReceiveValue<ShadowType>("TestVanillaEnum", (Action<ShadowType>)delegate(ShadowType val)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				_logCallback($"TestVanillaEnum: {val}");
			});
			ShadowType value = (ShadowType)2;
			_messenger.SendValue<ShadowType>("TestVanillaEnum", value);
		}

		private static void TestUnregisteredVanillaValue()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			_messenger.ReceiveValue<Chirality>("TestUnregisteredVanillaValue", (Action<Chirality>)delegate(Chirality val)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				_logCallback($"TestUnregisteredVanillaValue: {val}");
			});
			Chirality value = (Chirality)1;
			_messenger.SendValue<Chirality>("TestUnregisteredVanillaValue", value);
		}

		private static void TestUnknownMessenger()
		{
			_unknownMessenger.SendEmptyCommand("UnknownMessengerTest");
		}

		private static void TestUnknownCommandId()
		{
			_messenger.SendEmptyCommand("UnknownIdTest");
		}

		private static void TestNullString()
		{
			_messenger.ReceiveString("NullStr", delegate(string? str)
			{
				_logCallback("NullStr: " + str);
			});
			_messenger.SendString("NullStr", null);
		}

		private static void TestEmptyCommand()
		{
			_messenger.ReceiveEmptyCommand("TestEmptyCommand", delegate
			{
				_logCallback("TestEmptyCommand");
			});
			_messenger.SendEmptyCommand("TestEmptyCommand");
		}

		private static void TestString()
		{
			_messenger.ReceiveString("TestString", delegate(string? str)
			{
				_logCallback("TestString: " + (str ?? "NULL"));
			});
			_messenger.SendString("TestString", "I am a test string wow");
		}

		private static void TestValue()
		{
			_messenger.ReceiveValue("TestValue", delegate(int val)
			{
				_logCallback($"TestValue: {val}");
			});
			_messenger.SendValue("TestValue", 637);
		}

		private static void TestNestedPackable()
		{
			_messenger.ReceiveObject("TestNestedPackable", delegate(TestNestedPackable recvNestedPackable)
			{
				_logCallback(string.Format("TestNestedPackable: {0}, {1}, {2}, {3}, {4}", recvNestedPackable?.Value, ((object)recvNestedPackable?.Obj)?.ToString() ?? "NULL", recvNestedPackable?.Obj?.Value, recvNestedPackable?.Obj?.Text, recvNestedPackable?.Obj?.Time));
			});
			TestCommand testCommand = new TestCommand();
			testCommand.Value = 9999uL;
			testCommand.Text = "I am a nested command!";
			testCommand.Time = DateTime.MinValue;
			TestNestedPackable testNestedPackable = new TestNestedPackable();
			testNestedPackable.Value = 248;
			testNestedPackable.Obj = testCommand;
			_messenger.SendObject("TestNestedPackable", testNestedPackable);
		}

		private static void TestCustomRendererCommand()
		{
			_messenger.ReceiveObject<TestCommand>("TestCustomRendererCommand", (Action<TestCommand>)delegate(TestCommand recvCmd)
			{
				_logCallback($"TestCustomRendererCommand: {recvCmd?.Value}, {recvCmd?.Text}, {recvCmd?.Time}");
			});
			TestCommand testCommand = new TestCommand();
			testCommand.Value = 2932uL;
			testCommand.Text = "Hello world";
			testCommand.Time = DateTime.Now;
			_messenger.SendObject<TestCommand>("TestCustomRendererCommand", testCommand);
		}

		private static void TestPackable()
		{
			_messenger.ReceiveObject("TestPackable", delegate(TestPackable recvObj)
			{
				_logCallback($"TestPackable: {recvObj?.Value}");
			});
			TestPackable testPackable = new TestPackable();
			testPackable.Value = 72u;
			_messenger.SendObject("TestPackable", testPackable);
		}

		private static void TestStruct()
		{
			_messenger.ReceiveValue("TestStruct", delegate(TestStruct recvStruct)
			{
				_logCallback($"TestStruct: {recvStruct.Value}");
			});
			TestStruct value = default(TestStruct);
			value.Value = 4;
			_messenger.SendValue("TestStruct", value);
		}

		private static void TestNestedStruct()
		{
			_messenger.ReceiveValue("TestNestedStruct", delegate(TestNestedStruct recvNestedStruct)
			{
				_logCallback($"TestNestedStruct: {recvNestedStruct.Nested.Value}");
			});
			TestStruct nested = default(TestStruct);
			TestNestedStruct value = default(TestNestedStruct);
			value.Nested = nested;
			_messenger.SendValue("TestNestedStruct", value);
		}

		private static void TestUnregisteredCommand()
		{
			_messenger.ReceiveObject<UnregisteredCommand>("UnregisteredCommand", (Action<UnregisteredCommand>)delegate
			{
				_logCallback("UnregisteredCommand");
			});
			UnregisteredCommand obj = new UnregisteredCommand();
			_messenger.SendObject<UnregisteredCommand>("UnregisteredCommand", obj);
		}

		private static void TestUnregisteredPackable()
		{
			_messenger.ReceiveValue<UnregisteredPackable>("UnregisteredPackable", delegate
			{
				_logCallback("UnregisteredPackable");
			});
			_messenger.SendValue("UnregisteredPackable", default(UnregisteredPackable));
		}

		private static void TestUnregisteredStruct()
		{
			_messenger.ReceiveValue<UnregisteredStruct>("UnregisteredStruct", delegate
			{
				_logCallback("UnregisteredStruct");
			});
			_messenger.SendValue("UnregisteredStruct", default(UnregisteredStruct));
		}

		private static void TestValueList()
		{
			_messenger.ReceiveValueList("TestValueList", delegate(List<float> list)
			{
				_logCallback("TestValueList: " + string.Join(",", list));
			});
			List<float> list2 = new List<float>();
			list2.Add(2f);
			list2.Add(7f);
			list2.Add(21f);
			_messenger.SendValueList("TestValueList", list2);
		}

		private static void TestValueHashSet()
		{
			_messenger.ReceiveValueHashSet("TestValueHashSet", delegate(HashSet<float> list)
			{
				_logCallback("TestValueHashSet: " + string.Join(",", list));
			});
			HashSet<float> hashSet = new HashSet<float>();
			hashSet.Add(99.92f);
			hashSet.Add(127.2f);
			hashSet.Add(-4.32f);
			_messenger.SendValueHashSet("TestValueHashSet", hashSet);
		}

		private static void TestObjectList()
		{
			_messenger.ReceiveObjectList("TestObjectList", delegate(List<TestPackable> list)
			{
				_logCallback("TestObjectList: " + string.Join(",", list));
			});
			List<TestPackable> list2 = new List<TestPackable>();
			list2.Add(new TestPackable
			{
				Value = 7u
			});
			list2.Add(new TestPackable
			{
				Value = 15u
			});
			list2.Add(new TestPackable
			{
				Value = 83u
			});
			_messenger.SendObjectList("TestObjectList", list2);
		}

		private static void TestStringList()
		{
			_messenger.ReceiveStringList("TestStringList", delegate(List<string>? list)
			{
				_logCallback("TestStringList: " + string.Join(",", list.Select((string s) => s ?? "NULL")));
			});
			List<string> list2 = new List<string>();
			list2.Add("Hello");
			list2.Add("World");
			list2.Add("owo");
			list2.Add(null);
			list2.Add("x3");
			_messenger.SendStringList("TestStringList", list2);
		}

		private static void TestVanillaObject()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			_messenger.ReceiveObject<RendererInitData>("TestVanillaObject", (Action<RendererInitData>)delegate(RendererInitData recv)
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				_logCallback($"TestVanillaObject: {recv.sharedMemoryPrefix} {recv.uniqueSessionId} {recv.mainProcessId} {recv.debugFramePacing} {recv.outputDevice} {recv.setWindowIcon} {recv.splashScreenOverride}");
			});
			RendererInitData obj = new RendererInitData();
			_messenger.SendObject<RendererInitData>("TestVanillaObject", obj);
		}

		private static void TestUnregisteredVanillaObject()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			_messenger.ReceiveObject<QualityConfig>("TestUnregisteredVanillaObject", (Action<QualityConfig>)delegate(QualityConfig recv)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				_logCallback($"TestUnregisteredVanillaObject: {recv.perPixelLights} {recv.shadowCascades} {recv.shadowResolution} {recv.shadowDistance} {recv.skinWeightMode}");
			});
			QualityConfig obj = new QualityConfig();
			_messenger.SendObject<QualityConfig>("TestUnregisteredVanillaObject", obj);
		}
	}
	public class TestCommand : RendererCommand
	{
		public ulong Value;

		public string Text = "";

		public DateTime Time;

		public override void Pack(ref MemoryPacker packer)
		{
			((MemoryPacker)(ref packer)).Write<ulong>(Value);
			((MemoryPacker)(ref packer)).Write(Text);
			((MemoryPacker)(ref packer)).Write<DateTime>(Time);
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
			((MemoryUnpacker)(ref unpacker)).Read<ulong>(ref Value);
			((MemoryUnpacker)(ref unpacker)).Read(ref Text);
			((MemoryUnpacker)(ref unpacker)).Read<DateTime>(ref Time);
		}
	}
	public class TestNestedPackable : IMemoryPackable
	{
		public byte Value;

		public TestCommand? Obj;

		public void Pack(ref MemoryPacker packer)
		{
			((MemoryPacker)(ref packer)).Write<byte>(Value);
			((MemoryPacker)(ref packer)).WriteObject<TestCommand>(Obj);
		}

		public void Unpack(ref MemoryUnpacker unpacker)
		{
			((MemoryUnpacker)(ref unpacker)).Read<byte>(ref Value);
			((MemoryUnpacker)(ref unpacker)).ReadObject<TestCommand>(ref Obj);
		}
	}
	public class TestPackable : IMemoryPackable
	{
		public uint Value;

		public void Pack(ref MemoryPacker packer)
		{
			((MemoryPacker)(ref packer)).Write<uint>(Value);
		}

		public void Unpack(ref MemoryUnpacker unpacker)
		{
			((MemoryUnpacker)(ref unpacker)).Read<uint>(ref Value);
		}

		public override string ToString()
		{
			return $"TestPackable: {Value}";
		}
	}
	public struct TestStruct
	{
		public int Value;
	}
	public struct TestNestedStruct
	{
		public TestStruct Nested;
	}
	public class InvalidType
	{
		public Exception? Exception;
	}
	public struct StructWithObject
	{
		public Assembly Assembly;
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct UnregisteredPackable : IMemoryPackable
	{
		public void Pack(ref MemoryPacker packer)
		{
		}

		public void Unpack(ref MemoryUnpacker unpacker)
		{
		}
	}
	public class UnregisteredCommand : RendererCommand
	{
		public override void Pack(ref MemoryPacker packer)
		{
		}

		public override void Unpack(ref MemoryUnpacker unpacker)
		{
		}
	}
	public struct UnregisteredStruct
	{
		public byte Value;
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}

Renderer/BepInEx/plugins/InterprocessLib.BepInEx/InterprocessLib.BepInEx_Extensions.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Nytra")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+659a967631415d299bfd5408909e1d7a3d01d3d6")]
[assembly: AssemblyProduct("InterprocessLib.BepInEx_Extensions")]
[assembly: AssemblyTitle("InterprocessLib.BepInEx_Extensions")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Nytra/ResoniteInterprocessLib")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 IsUnmanagedAttribute : 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 InterprocessLib
{
	public static class BepInExExtensions
	{
		private static Dictionary<ConfigEntryBase, bool> _syncStates = new Dictionary<ConfigEntryBase, bool>();

		public static void SyncConfigEntry<T>(this Messenger messenger, ConfigEntry<T> configEntry) where T : unmanaged
		{
			ConfigEntry<T> configEntry2 = configEntry;
			Messenger messenger2 = messenger;
			_syncStates[(ConfigEntryBase)(object)configEntry2] = true;
			if (Messenger.IsAuthority)
			{
				messenger2.SendConfigEntry<T>(configEntry2);
			}
			configEntry2.SettingChanged += delegate
			{
				if (_syncStates.TryGetValue((ConfigEntryBase)(object)configEntry2, out var value) && value)
				{
					messenger2.SendConfigEntry<T>(configEntry2);
				}
			};
			messenger2.ReceiveConfigEntry<T>(configEntry2);
		}

		public static void SyncConfigEntry(this Messenger messenger, ConfigEntry<string> configEntry)
		{
			ConfigEntry<string> configEntry2 = configEntry;
			Messenger messenger2 = messenger;
			_syncStates[(ConfigEntryBase)(object)configEntry2] = true;
			if (Messenger.IsAuthority)
			{
				messenger2.SendConfigEntry(configEntry2);
			}
			configEntry2.SettingChanged += delegate
			{
				if (_syncStates.TryGetValue((ConfigEntryBase)(object)configEntry2, out var value) && value)
				{
					messenger2.SendConfigEntry(configEntry2);
				}
			};
			messenger2.ReceiveConfigEntry(configEntry2);
		}

		public static void SendConfigEntry<T>(this Messenger messenger, ConfigEntry<T> configEntry) where T : unmanaged
		{
			messenger.SendValue<T>(((ConfigEntryBase)configEntry).Definition.Key, configEntry.Value);
		}

		public static void SendConfigEntry(this Messenger messenger, ConfigEntry<string> configEntry)
		{
			messenger.SendString(((ConfigEntryBase)configEntry).Definition.Key, configEntry.Value);
		}

		public static void ReceiveConfigEntry<T>(this Messenger messenger, ConfigEntry<T> configEntry) where T : unmanaged
		{
			ConfigEntry<T> configEntry2 = configEntry;
			messenger.ReceiveValue<T>(((ConfigEntryBase)configEntry2).Definition.Key, (Action<T>)delegate(T val)
			{
				_syncStates[(ConfigEntryBase)(object)configEntry2] = false;
				configEntry2.Value = val;
				_syncStates[(ConfigEntryBase)(object)configEntry2] = true;
			});
		}

		public static void ReceiveConfigEntry(this Messenger messenger, ConfigEntry<string> configEntry)
		{
			ConfigEntry<string> configEntry2 = configEntry;
			messenger.ReceiveString(((ConfigEntryBase)configEntry2).Definition.Key, (Action<string>)delegate(string? str)
			{
				_syncStates[(ConfigEntryBase)(object)configEntry2] = false;
				configEntry2.Value = str;
				_syncStates[(ConfigEntryBase)(object)configEntry2] = true;
			});
		}
	}
}