Decompiled source of AdditionalNetworking Experimental v2.3.4

BepInEx/patchers/AdditionalNetworking.Preloader.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using AdditionalNetworking.Preloader.Utils;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("mattymatty")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.3.3")]
[assembly: AssemblyInformationalVersion("2.3.3+5406240115193c16c96629e8177960f1d8c7ad2f")]
[assembly: AssemblyProduct("AdditionalNetworking")]
[assembly: AssemblyTitle("Preloader For AdditionalNetworking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[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 AdditionalNetworking.Preloader
{
	internal class AdditionalNetworking
	{
		public static class PluginConfig
		{
			internal static ConfigEntry<bool> Enabled;

			internal static ConfigEntry<string> OutputPath;

			internal static ConfigEntry<string> OutputExtension;

			public static void Init()
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				ConfigFile val = new ConfigFile(Utility.CombinePaths(new string[2] { MainDir, "AdditionalNetworking.Development.cfg" }), true);
				Enabled = val.Bind<bool>("DevelOptions", "Enabled", false, "Enable development dll output");
				OutputPath = val.Bind<string>("DevelOptions", "OutputPath", MainDir, "Folder where to write the modified dlls");
				OutputExtension = val.Bind<string>("DevelOptions", "OutputExtension", ".pdll", "Extension to use for the modified dlls\n( Do not use .dll if outputting inside the BepInEx folders )");
				PropertyInfo property = ((object)val).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
				Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(val, null);
				dictionary.Clear();
				val.Save();
			}
		}

		public const string GUID = "mattymatty.AdditionalNetworking";

		public const string NAME = "AdditionalNetworking";

		public const string VERSION = "2.3.3";

		internal static readonly BepInPlugin Plugin = new BepInPlugin("mattymatty.AdditionalNetworking", "AdditionalNetworking", "2.3.3");

		private static readonly string MainDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		private static readonly Dictionary<string, Dictionary<string, List<TypeDefinition>>> Interfaces = new Dictionary<string, Dictionary<string, List<TypeDefinition>>>();

		internal static ManualLogSource Log { get; } = Logger.CreateLogSource("AdditionalNetworking");


		public static IEnumerable<string> TargetDLLs { get; } = new <>z__ReadOnlySingleElementList<string>("Assembly-CSharp.dll");


		public static void Patch(AssemblyDefinition assembly)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			Action<bool, string> logCallback = delegate(bool fail, string message)
			{
				if (fail)
				{
					Log.LogWarning((object)message);
				}
				else
				{
					Log.LogDebug((object)message);
				}
			};
			if (Interfaces.TryGetValue(((AssemblyNameReference)assembly.Name).Name, out var value))
			{
				Log.LogWarning((object)("Patching " + ((AssemblyNameReference)assembly.Name).Name));
				Enumerator<TypeDefinition> enumerator = assembly.MainModule.Types.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						TypeDefinition current = enumerator.Current;
						if (!value.TryGetValue(((MemberReference)current).Name, out var value2))
						{
							continue;
						}
						foreach (TypeDefinition item in value2)
						{
							if (!current.ImplementInterface((TypeReference)(object)item, logCallback))
							{
								break;
							}
						}
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
			}
			if (PluginConfig.Enabled.Value)
			{
				string text = PluginConfig.OutputPath.Value + "/" + ((AssemblyNameReference)assembly.Name).Name + PluginConfig.OutputExtension.Value;
				Log.LogWarning((object)("Saving modified Assembly to " + text));
				assembly.Write(text);
			}
		}

		public static void Initialize()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			Log.LogInfo((object)"AdditionalNetworking Prepatcher Started");
			PluginConfig.Init();
			string text = Directory.EnumerateDirectories(Paths.PluginPath).FirstOrDefault((string d) => d.Contains("AdditionalNetworking"));
			if (text == null)
			{
				Log.LogFatal((object)"Could not find Interfaces dll!");
				return;
			}
			string text2 = Path.Combine(text, "AdditionalNetworking.Interfaces.dll");
			if (!File.Exists(text2))
			{
				Log.LogFatal((object)"Could not find Interfaces dll!");
				return;
			}
			AssemblyDefinition val = AssemblyDefinition.ReadAssembly(text2);
			string attributeName = typeof(InjectInterfaceAttribute).FullName;
			Enumerator<TypeDefinition> enumerator = val.MainModule.Types.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TypeDefinition current = enumerator.Current;
					if (!current.IsInterface)
					{
						continue;
					}
					IEnumerable<CustomAttribute> enumerable = ((IEnumerable<CustomAttribute>)current.CustomAttributes).Where((CustomAttribute at) => ((MemberReference)at.AttributeType).FullName == attributeName);
					foreach (CustomAttribute item in enumerable)
					{
						InjectInterfaceAttribute attributeInstance = item.GetAttributeInstance<InjectInterfaceAttribute>();
						if (!Interfaces.TryGetValue(attributeInstance.AssemblyName, out var value))
						{
							value = (Interfaces[attributeInstance.AssemblyName] = new Dictionary<string, List<TypeDefinition>>());
						}
						if (!value.TryGetValue(attributeInstance.TypeName, out var value2))
						{
							value2 = (value[attributeInstance.TypeName] = new List<TypeDefinition>());
						}
						value2.Add(current);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public static void Finish()
		{
			Log.LogInfo((object)"AdditionalNetworking Prepatcher Finished");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "mattymatty.AdditionalNetworking";

		public const string PLUGIN_NAME = "AdditionalNetworking";

		public const string PLUGIN_VERSION = "2.3.3";
	}
}
namespace AdditionalNetworking.Preloader.Utils
{
	internal static class CecilHelpers
	{
		private static class Interfaces
		{
			internal static bool ImplementProperties(in TypeDefinition type, TypeDefinition @interface, in HashSet<IMemberDefinition> blacklist, out List<PropertyDefinition> properties, Action<bool, string> logCallback = null)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				properties = new List<PropertyDefinition>();
				Enumerator<PropertyDefinition> enumerator = @interface.Properties.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						PropertyDefinition current = enumerator.Current;
						if (!ImplementProperty(in type, current, in blacklist, out var implementation, logCallback))
						{
							return false;
						}
						properties.Add(implementation);
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				return true;
			}

			internal static bool ImplementEvents(in TypeDefinition type, TypeDefinition @interface, in HashSet<IMemberDefinition> blacklist, out List<EventDefinition> events, Action<bool, string> logCallback = null)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				events = new List<EventDefinition>();
				Enumerator<EventDefinition> enumerator = @interface.Events.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						EventDefinition current = enumerator.Current;
						if (!ImplementEvent(in type, current, in blacklist, out var implementation, logCallback))
						{
							return false;
						}
						events.Add(implementation);
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				return true;
			}

			internal static bool ImplementMethods(in TypeDefinition type, TypeDefinition @interface, in HashSet<IMemberDefinition> blacklist, out List<MethodDefinition> methods, Action<bool, string> logCallback = null)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				methods = new List<MethodDefinition>();
				Enumerator<MethodDefinition> enumerator = @interface.Methods.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						MethodDefinition current = enumerator.Current;
						if (!ImplementMethod(in type, current, in blacklist, out var implementation, logCallback))
						{
							return false;
						}
						methods.Add(implementation);
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				return true;
			}

			private static bool ImplementProperty(in TypeDefinition type, PropertyDefinition property, in HashSet<IMemberDefinition> blacklist, out PropertyDefinition implementation, Action<bool, string> logCallback = null)
			{
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ae: Expected O, but got Unknown
				//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0325: Unknown result type (might be due to invalid IL or missing references)
				//IL_032c: Expected O, but got Unknown
				//IL_0344: Unknown result type (might be due to invalid IL or missing references)
				//IL_034e: Expected O, but got Unknown
				//IL_035e: Unknown result type (might be due to invalid IL or missing references)
				//IL_036a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0376: Unknown result type (might be due to invalid IL or missing references)
				//IL_0388: Unknown result type (might be due to invalid IL or missing references)
				implementation = property;
				FieldDefinition backingField = null;
				bool hasImplementation = false;
				if (!blacklist.Add((IMemberDefinition)(object)property))
				{
					return true;
				}
				logCallback?.Invoke(arg1: false, "Adding Property '" + ((MemberReference)property).Name + "' to " + ((MemberReference)type).FullName + "'");
				MethodDefinition getMethod = property.GetMethod;
				if (getMethod != null && getMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)property.GetMethod))
				{
					if (!Init(in type, out implementation))
					{
						return false;
					}
					logCallback?.Invoke(arg1: false, "Adding getter of '" + ((MemberReference)property).Name + "' to " + ((MemberReference)type).FullName + "'");
					if (Extensions.FindMethod(type, "get_" + ((MemberReference)property).Name, true) != null)
					{
						logCallback?.Invoke(arg1: true, "Method 'get_" + ((MemberReference)property).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'");
						return false;
					}
					MethodDefinition val = new MethodDefinition("get_" + ((MemberReference)property).Name, (MethodAttributes)2534, ((PropertyReference)property).PropertyType);
					ILProcessor iLProcessor = val.Body.GetILProcessor();
					iLProcessor.Emit(OpCodes.Ldarg_0);
					iLProcessor.Emit(OpCodes.Ldfld, (FieldReference)(object)backingField);
					iLProcessor.Emit(OpCodes.Ret);
					type.Methods.Add(val);
					implementation.GetMethod = val;
				}
				getMethod = property.SetMethod;
				if (getMethod != null && getMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)property.SetMethod))
				{
					if (!hasImplementation && !Init(in type, out implementation))
					{
						return false;
					}
					logCallback?.Invoke(arg1: false, "Adding setter of '" + ((MemberReference)property).Name + "' to " + ((MemberReference)type).FullName + "'");
					if (Extensions.FindMethod(type, "set_" + ((MemberReference)property).Name, true) != null)
					{
						logCallback?.Invoke(arg1: true, "Method 'set_" + ((MemberReference)property).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'");
						return false;
					}
					MethodDefinition val2 = new MethodDefinition("set_" + ((MemberReference)property).Name, (MethodAttributes)2534, ((MemberReference)type).Module.TypeSystem.Void);
					((MethodReference)val2).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, ((PropertyReference)property).PropertyType));
					ILProcessor iLProcessor2 = val2.Body.GetILProcessor();
					iLProcessor2.Emit(OpCodes.Ldarg_0);
					iLProcessor2.Emit(OpCodes.Ldarg_1);
					iLProcessor2.Emit(OpCodes.Stfld, (FieldReference)(object)backingField);
					iLProcessor2.Emit(OpCodes.Ret);
					type.Methods.Add(val2);
					implementation.SetMethod = val2;
				}
				if (!hasImplementation)
				{
					return true;
				}
				type.Fields.Add(backingField);
				type.Properties.Add(implementation);
				return true;
				bool Init(in TypeDefinition type, out PropertyDefinition implementation)
				{
					//IL_0082: Unknown result type (might be due to invalid IL or missing references)
					//IL_008c: Expected O, but got Unknown
					//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f3: Expected O, but got Unknown
					implementation = null;
					if (Extensions.FindField(type, "<" + ((MemberReference)property).Name + ">k__BackingField") != null)
					{
						logCallback?.Invoke(arg1: true, "Field '<" + ((MemberReference)property).Name + ">k__BackingField' already exists in " + ((MemberReference)type).FullName);
						return false;
					}
					backingField = new FieldDefinition("<" + ((MemberReference)property).Name + ">k__BackingField", (FieldAttributes)1, ((PropertyReference)property).PropertyType);
					if (Extensions.FindProperty(type, ((MemberReference)property).Name) != null)
					{
						logCallback?.Invoke(arg1: true, "Property '" + ((MemberReference)property).Name + "' already exists in " + ((MemberReference)type).FullName);
						return false;
					}
					implementation = new PropertyDefinition(((MemberReference)property).Name, (PropertyAttributes)0, ((PropertyReference)property).PropertyType);
					hasImplementation = true;
					return true;
				}
			}

			private static bool ImplementEvent(in TypeDefinition type, EventDefinition @event, in HashSet<IMemberDefinition> blacklist, out EventDefinition implementation, Action<bool, string> logCallback = null)
			{
				//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Expected O, but got Unknown
				//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d5: Expected O, but got Unknown
				//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0209: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_025f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0275: Unknown result type (might be due to invalid IL or missing references)
				//IL_0286: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_03db: Expected O, but got Unknown
				//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03fd: Expected O, but got Unknown
				//IL_040d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0419: Unknown result type (might be due to invalid IL or missing references)
				//IL_0425: Unknown result type (might be due to invalid IL or missing references)
				//IL_0437: Unknown result type (might be due to invalid IL or missing references)
				//IL_0443: Unknown result type (might be due to invalid IL or missing references)
				//IL_048f: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0608: Unknown result type (might be due to invalid IL or missing references)
				//IL_060f: Expected O, but got Unknown
				//IL_061f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0624: Unknown result type (might be due to invalid IL or missing references)
				//IL_0641: Unknown result type (might be due to invalid IL or missing references)
				//IL_064d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0657: Expected O, but got Unknown
				//IL_0680: Unknown result type (might be due to invalid IL or missing references)
				//IL_068c: Unknown result type (might be due to invalid IL or missing references)
				//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_071a: Unknown result type (might be due to invalid IL or missing references)
				implementation = @event;
				FieldDefinition backingField = null;
				bool hasImplementation = false;
				if (!blacklist.Add((IMemberDefinition)(object)@event))
				{
					return true;
				}
				logCallback?.Invoke(arg1: false, "Adding Event '" + ((MemberReference)@event).Name + "' to " + ((MemberReference)type).FullName + "'");
				MethodDefinition addMethod = @event.AddMethod;
				if (addMethod != null && addMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)@event.AddMethod))
				{
					if (!Init(in type, out implementation))
					{
						return false;
					}
					logCallback?.Invoke(arg1: false, "Adding registration of '" + ((MemberReference)@event).Name + "' to " + ((MemberReference)type).FullName + "'");
					if (Extensions.FindMethod(type, "add_" + ((MemberReference)@event).Name, true) != null)
					{
						logCallback?.Invoke(arg1: true, "Method 'add_" + ((MemberReference)@event).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'");
						return false;
					}
					MethodDefinition val = new MethodDefinition("add_" + ((MemberReference)@event).Name, (MethodAttributes)2534, ((MemberReference)type).Module.TypeSystem.Void);
					((MethodReference)val).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, ((EventReference)@event).EventType));
					ILProcessor iLProcessor = val.Body.GetILProcessor();
					iLProcessor.Emit(OpCodes.Ldarg_0);
					iLProcessor.Emit(OpCodes.Ldarg_0);
					iLProcessor.Emit(OpCodes.Ldfld, (FieldReference)(object)backingField);
					iLProcessor.Emit(OpCodes.Ldarg_1);
					iLProcessor.Emit(OpCodes.Call, ((MemberReference)type).Module.ImportReference((MethodBase)typeof(Delegate).GetMethod("Combine", new Type[2]
					{
						typeof(Delegate),
						typeof(Delegate)
					})));
					iLProcessor.Emit(OpCodes.Castclass, ((EventReference)@event).EventType);
					iLProcessor.Emit(OpCodes.Stfld, (FieldReference)(object)backingField);
					iLProcessor.Emit(OpCodes.Ret);
					type.Methods.Add(val);
					implementation.AddMethod = val;
				}
				addMethod = @event.RemoveMethod;
				if (addMethod != null && addMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)@event.RemoveMethod))
				{
					if (!hasImplementation && !Init(in type, out implementation))
					{
						return false;
					}
					logCallback?.Invoke(arg1: false, "Adding de-registration of '" + ((MemberReference)@event).Name + "' to " + ((MemberReference)type).FullName + "'");
					if (Extensions.FindMethod(type, "remove_" + ((MemberReference)@event).Name, true) != null)
					{
						logCallback?.Invoke(arg1: true, "Method 'remove_" + ((MemberReference)@event).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'");
						return false;
					}
					MethodDefinition val2 = new MethodDefinition("remove_" + ((MemberReference)@event).Name, (MethodAttributes)2534, ((MemberReference)type).Module.TypeSystem.Void);
					((MethodReference)val2).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, ((EventReference)@event).EventType));
					ILProcessor iLProcessor2 = val2.Body.GetILProcessor();
					iLProcessor2.Emit(OpCodes.Ldarg_0);
					iLProcessor2.Emit(OpCodes.Ldarg_0);
					iLProcessor2.Emit(OpCodes.Ldfld, (FieldReference)(object)backingField);
					iLProcessor2.Emit(OpCodes.Ldarg_1);
					iLProcessor2.Emit(OpCodes.Call, ((MemberReference)type).Module.ImportReference((MethodBase)typeof(Delegate).GetMethod("Remove", new Type[2]
					{
						typeof(Delegate),
						typeof(Delegate)
					})));
					iLProcessor2.Emit(OpCodes.Castclass, ((EventReference)@event).EventType);
					iLProcessor2.Emit(OpCodes.Stfld, (FieldReference)(object)backingField);
					iLProcessor2.Emit(OpCodes.Ret);
					type.Methods.Add(val2);
					implementation.RemoveMethod = val2;
				}
				addMethod = @event.InvokeMethod;
				if (addMethod != null && addMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)@event.InvokeMethod))
				{
					if (!hasImplementation && !Init(in type, out implementation))
					{
						return false;
					}
					logCallback?.Invoke(arg1: false, "Adding invocation of '" + ((MemberReference)@event).Name + "' to " + ((MemberReference)type).FullName + "'");
					if (Extensions.FindMethod(type, "raise_" + ((MemberReference)@event).Name, true) != null)
					{
						logCallback?.Invoke(arg1: true, "Method 'raise_" + ((MemberReference)@event).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'");
						return false;
					}
					MethodDefinition val3 = new MethodDefinition("raise_" + ((MemberReference)@event).Name, (MethodAttributes)2534, ((MemberReference)type).Module.TypeSystem.Void);
					Enumerator<ParameterDefinition> enumerator = ((MethodReference)@event.InvokeMethod).Parameters.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							ParameterDefinition current = enumerator.Current;
							((MethodReference)val3).Parameters.Add(new ParameterDefinition(((ParameterReference)current).Name, current.Attributes, ((ParameterReference)current).ParameterType));
						}
					}
					finally
					{
						((IDisposable)enumerator).Dispose();
					}
					ILProcessor iLProcessor3 = val3.Body.GetILProcessor();
					iLProcessor3.Emit(OpCodes.Ldarg_0);
					iLProcessor3.Emit(OpCodes.Ldfld, (FieldReference)(object)backingField);
					for (int i = 0; i < ((MethodReference)val3).Parameters.Count; i++)
					{
						iLProcessor3.Emit(OpCodes.Ldarg, i + 1);
					}
					iLProcessor3.Emit(OpCodes.Callvirt, ((MemberReference)type).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)((EventReference)@event).EventType.Resolve().Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "Invoke")));
					iLProcessor3.Emit(OpCodes.Ret);
					type.Methods.Add(val3);
					implementation.InvokeMethod = val3;
				}
				if (!hasImplementation)
				{
					return true;
				}
				type.Fields.Add(backingField);
				type.Events.Add(implementation);
				return true;
				bool Init(in TypeDefinition type, out EventDefinition implementation)
				{
					//IL_0064: Unknown result type (might be due to invalid IL or missing references)
					//IL_006e: Expected O, but got Unknown
					//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d5: Expected O, but got Unknown
					implementation = null;
					if (Extensions.FindField(type, ((MemberReference)@event).Name) != null)
					{
						logCallback?.Invoke(arg1: true, "Field '" + ((MemberReference)@event).Name + "' already exists in " + ((MemberReference)type).FullName);
						return false;
					}
					backingField = new FieldDefinition(((MemberReference)@event).Name, (FieldAttributes)1, ((EventReference)@event).EventType);
					if (Extensions.FindEvent(type, ((MemberReference)@event).Name) != null)
					{
						logCallback?.Invoke(arg1: true, "Event '" + ((MemberReference)@event).Name + "' already exists in " + ((MemberReference)type).FullName);
						return false;
					}
					implementation = new EventDefinition(((MemberReference)@event).Name, (EventAttributes)0, ((EventReference)@event).EventType);
					hasImplementation = true;
					return true;
				}
			}

			private static bool ImplementMethod(in TypeDefinition type, MethodDefinition method, in HashSet<IMemberDefinition> blacklist, out MethodDefinition implementation, Action<bool, string> logCallback = null)
			{
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Expected O, but got Unknown
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Expected O, but got Unknown
				//IL_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_0183: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				implementation = null;
				if (!blacklist.Add((IMemberDefinition)(object)method))
				{
					return true;
				}
				logCallback?.Invoke(arg1: false, "Adding Method '" + ((MemberReference)method).Name + "' to " + ((MemberReference)type).FullName + "'");
				if (!method.IsAbstract)
				{
					implementation = method;
					return true;
				}
				if (Extensions.FindMethod(type, ((MemberReference)method).Name, true) != null)
				{
					logCallback?.Invoke(arg1: true, "Method '" + ((MemberReference)method).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'");
					return false;
				}
				implementation = new MethodDefinition(((MemberReference)method).Name, (MethodAttributes)358, ((MethodReference)method).ReturnType);
				Enumerator<ParameterDefinition> enumerator = ((MethodReference)method).Parameters.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						ParameterDefinition current = enumerator.Current;
						((MethodReference)implementation).Parameters.Add(new ParameterDefinition(((ParameterReference)current).Name, current.Attributes, ((ParameterReference)current).ParameterType));
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				ILProcessor iLProcessor = implementation.Body.GetILProcessor();
				if (((MemberReference)((MethodReference)method).ReturnType).FullName != "System.Void")
				{
					ConstructorInfo constructor = typeof(NotImplementedException).GetConstructor(new Type[1] { typeof(string) });
					MethodReference val = ((MemberReference)type).Module.ImportReference((MethodBase)constructor);
					iLProcessor.Emit(OpCodes.Ldstr, "This is a Stub");
					iLProcessor.Emit(OpCodes.Newobj, val);
					iLProcessor.Emit(OpCodes.Throw);
				}
				else
				{
					iLProcessor.Emit(OpCodes.Ret);
				}
				type.Methods.Add(implementation);
				return true;
			}
		}

		public static T GetAttributeInstance<T>(this CustomAttribute ceciAttribute) where T : Attribute
		{
			Type typeFromHandle = typeof(T);
			object[] args = ((IEnumerable<CustomAttributeArgument>)ceciAttribute.ConstructorArguments).Select((CustomAttributeArgument ca) => ((CustomAttributeArgument)(ref ca)).Value).ToArray();
			return (T)Activator.CreateInstance(typeFromHandle, args);
		}

		internal static bool AddRaise(this TypeDefinition self, string eventName, Action<bool, string> logCallback = null)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			string text = "call_" + eventName;
			logCallback?.Invoke(arg1: false, "Adding caller for event '" + eventName + "' to " + ((MemberReference)self).FullName);
			EventDefinition val = Extensions.FindEvent(self, eventName);
			if (val == null)
			{
				logCallback?.Invoke(arg1: true, "Event '" + eventName + "' does not exists in " + ((MemberReference)self).FullName);
				return false;
			}
			FieldDefinition val2 = Extensions.FindField(self, eventName);
			if (val2 == null)
			{
				logCallback?.Invoke(arg1: true, "Field '" + eventName + "' does not exists in " + ((MemberReference)self).FullName);
				return false;
			}
			if (Extensions.FindMethod(self, text, true) != null)
			{
				logCallback?.Invoke(arg1: true, "Method '" + text + "' already exists in " + ((MemberReference)self).FullName);
				return false;
			}
			MethodDefinition val3 = Extensions.FindMethod(((FieldReference)val2).FieldType.Resolve(), "Invoke", true);
			MethodReference val4 = ((MemberReference)self).Module.ImportReference((MethodReference)(object)val3);
			bool flag = false;
			MethodAttributes val5 = (MethodAttributes)0;
			if ((val2.Attributes & 0x10) != 0)
			{
				val5 = (MethodAttributes)(val5 | 0x10);
				flag = true;
			}
			if ((val2.Attributes & 1) != 0)
			{
				val5 = (MethodAttributes)(val5 | 1);
			}
			MethodDefinition val6 = new MethodDefinition(text, val5, ((FieldReference)val2).FieldType);
			self.Methods.Add(val6);
			Extensions.AddRange<ParameterDefinition>(((MethodReference)val6).Parameters, (IEnumerable<ParameterDefinition>)val4.Parameters);
			Collection<Instruction> instructions = val6.Body.Instructions;
			Instruction val7 = Instruction.Create(OpCodes.Pop);
			Instruction val8 = Instruction.Create(OpCodes.Ret);
			Extensions.AddRange<Instruction>(instructions, (IEnumerable<Instruction>)new <>z__ReadOnlyArray<Instruction>((Instruction[])(object)new Instruction[6]
			{
				Instruction.Create(flag ? OpCodes.Nop : OpCodes.Ldarg_0),
				Instruction.Create(flag ? OpCodes.Ldsfld : OpCodes.Ldfld, (FieldReference)(object)val2),
				Instruction.Create(OpCodes.Dup),
				Instruction.Create(OpCodes.Ldnull),
				Instruction.Create(OpCodes.Cgt_Un),
				Instruction.Create(OpCodes.Brfalse, val7)
			}));
			Enumerator<ParameterDefinition> enumerator = ((MethodReference)val6).Parameters.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ParameterDefinition current = enumerator.Current;
					instructions.Add(Instruction.Create(OpCodes.Ldarg, current));
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			instructions.Add(Instruction.Create(OpCodes.Callvirt, val4));
			instructions.Add(Instruction.Create(OpCodes.Br, val8));
			Extensions.AddRange<Instruction>(instructions, (IEnumerable<Instruction>)new <>z__ReadOnlyArray<Instruction>((Instruction[])(object)new Instruction[2] { val7, val8 }));
			return true;
		}

		internal static bool ImplementInterface(this TypeDefinition self, Type @interface, Action<bool, string> logCallback = null)
		{
			if (!@interface.IsInterface)
			{
				logCallback?.Invoke(arg1: true, "Type '" + @interface.FullName + "' is not an interface!");
				return false;
			}
			return self.ImplementInterface(((MemberReference)self).Module.ImportReference(@interface), logCallback);
		}

		internal static bool ImplementInterface(this TypeDefinition self, TypeReference @interface, Action<bool, string> logCallback = null)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			TypeDefinition val = @interface.Resolve();
			if (!val.IsInterface)
			{
				logCallback?.Invoke(arg1: true, "Type '" + ((MemberReference)@interface).FullName + "' is not an interface!");
				return false;
			}
			logCallback?.Invoke(arg1: false, "Adding '" + ((MemberReference)@interface).FullName + "' to " + ((MemberReference)self).FullName + "'");
			TypeReference val2 = ((MemberReference)self).Module.ImportReference(@interface);
			HashSet<IMemberDefinition> blacklist = new HashSet<IMemberDefinition>();
			if (!Interfaces.ImplementProperties(in self, val, in blacklist, out var _, logCallback))
			{
				return false;
			}
			if (!Interfaces.ImplementEvents(in self, val, in blacklist, out var _, logCallback))
			{
				return false;
			}
			if (!Interfaces.ImplementMethods(in self, val, in blacklist, out var _, logCallback))
			{
				return false;
			}
			self.Interfaces.Add(new InterfaceImplementation(val2));
			return true;
		}
	}
	[AttributeUsage(AttributeTargets.Interface, AllowMultiple = true)]
	public sealed class InjectInterfaceAttribute : Attribute
	{
		[CompilerGenerated]
		private string <typeName>P;

		[CompilerGenerated]
		private string <assemblyName>P;

		public string AssemblyName => <assemblyName>P;

		public string TypeName => <typeName>P;

		public InjectInterfaceAttribute(string typeName, string assemblyName = "Assembly-CSharp")
		{
			<typeName>P = typeName;
			<assemblyName>P = assemblyName;
			base..ctor();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
[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();
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			if (!_moveNextCalled)
			{
				return _moveNextCalled = true;
			}
			return false;
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

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

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

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

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
		{
			return -1;
		}
		return 0;
	}

	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 new Enumerator(_item);
	}

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

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

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

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

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

	int IList<T>.IndexOf(T item)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, item))
		{
			return -1;
		}
		return 0;
	}

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

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

BepInEx/plugins/AdditionalNetworking.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using AdditionalNetworking.Dependency;
using AdditionalNetworking.Interfaces;
using AdditionalNetworking.Networking;
using AdditionalNetworking.Patches;
using AdditionalNetworking.Utils;
using AdditionalNetworking.Utils.IL;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using HarmonyLib.Public.Patching;
using JetBrains.Annotations;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLevelLoader;
using LethalLib.Modules;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Pool;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("mattymatty")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.3.3")]
[assembly: AssemblyInformationalVersion("2.3.3+5406240115193c16c96629e8177960f1d8c7ad2f")]
[assembly: AssemblyProduct("AdditionalNetworking")]
[assembly: AssemblyTitle("AdditionalNetworking - Plugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsUnmanagedAttribute : Attribute
	{
	}
	[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 AdditionalNetworking
{
	[BepInPlugin("mattymatty.AdditionalNetworking", "AdditionalNetworking", "2.3.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class AdditionalNetworking : BaseUnityPlugin
	{
		internal static class PluginConfig
		{
			internal static class Inventory
			{
				internal static ConfigEntry<bool> SlotChange;

				internal static ConfigEntry<bool> InventoryChange;
			}

			internal static class ItemState
			{
				internal static ConfigEntry<bool> Shotgun;

				internal static ConfigEntry<bool> Boombox;

				internal static ConfigEntry<bool> Animated;
			}

			internal static class PlayerState
			{
				internal static ConfigEntry<bool> Crouching;
			}

			internal static class Value
			{
				internal static ConfigEntry<bool> Enabled;

				internal static ConfigEntry<bool> SkipVanillaGrabbablesSync;

				internal static ConfigEntry<string> IgnoreScanNodes;

				internal static HashSet<string> IgnoreScanNodesList = new HashSet<string>();

				internal static bool ShouldSkipGrabbableSync => SkipVanillaGrabbablesSync.Value;
			}

			internal static class Misc
			{
				internal static ConfigEntry<bool> Username;
			}

			internal static class Debug
			{
				internal static ConfigEntry<LogLevel> Verbose;
			}

			internal static void Init(BaseUnityPlugin plugin)
			{
				ConfigFile config = plugin.Config;
				config.SaveOnConfigSet = false;
				Inventory.SlotChange = config.Bind<bool>("Inventory", "SlotChange", true, "use explicit slot numbers when swapping slots");
				Inventory.InventoryChange = config.Bind<bool>("Inventory", "InventoryChange", true, "broadcast the exact inventory order");
				PlayerState.Crouching = config.Bind<bool>("Player state", "Crouching", true, "sync isCrouching state to allow Host AIs to correctly use the variable");
				ItemState.Shotgun = config.Bind<bool>("Item state", "Shotgun", true, "use explicit values for ammo/safety instead of toggle states");
				ItemState.Boombox = config.Bind<bool>("Item state", "Boombox", true, "sync state and track id");
				ItemState.Animated = config.Bind<bool>("Item state", "Animated Item", true, "sync noise for ToyRobot/Dentures ecc..");
				Value.Enabled = config.Bind<bool>("Item Values", "Enabled", true, "sync value of scrap if missing");
				Value.SkipVanillaGrabbablesSync = config.Bind<bool>("Item Values", "SkipVanillaGrabbablesSync", false, "disable sync item values in SyncShipUnlockablesServerRpc, replaced by AdditionalNetworking own message");
				Value.IgnoreScanNodes = config.Bind<string>("Item Values", "Ignored Scan Nodes", "Vanilla/Apparatus,", "list of items that have custom scan node texts\nListSeparator=,");
				ParseScanNodeList();
				Value.IgnoreScanNodes.SettingChanged += delegate
				{
					ParseScanNodeList();
				};
				Misc.Username = config.Bind<bool>("Misc", "Username", true, "broadcast the local username once it is assigned to the player object");
				Debug.Verbose = config.Bind<LogLevel>("Debug", "Verbose", (LogLevel)0, "additional log lines");
				config.SaveOnConfigSet = true;
				PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
				Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null);
				dictionary.Clear();
				config.Save();
				if (LethalConfigProxy.Enabled)
				{
					LethalConfigProxy.AddConfig(Inventory.InventoryChange);
					LethalConfigProxy.AddConfig(Inventory.SlotChange);
					LethalConfigProxy.AddConfig(ItemState.Animated);
					LethalConfigProxy.AddConfig(ItemState.Boombox);
					LethalConfigProxy.AddConfig(ItemState.Shotgun);
					LethalConfigProxy.AddConfig(PlayerState.Crouching);
					LethalConfigProxy.AddConfig(Value.Enabled);
					LethalConfigProxy.AddConfig(Value.SkipVanillaGrabbablesSync);
					LethalConfigProxy.AddConfig(Value.IgnoreScanNodes);
					LethalConfigProxy.AddConfig(Misc.Username);
					LethalConfigProxy.AddConfig<LogLevel>(Debug.Verbose, requiresRestart: false);
				}
				static void ParseScanNodeList()
				{
					string[] source = Value.IgnoreScanNodes.Value.Split(",");
					Value.IgnoreScanNodesList = (from s in source
						select s.Trim() into s
						where !Utility.IsNullOrWhiteSpace(s)
						select s).ToHashSet();
				}
			}
		}

		public const string GUID = "mattymatty.AdditionalNetworking";

		public const string NAME = "AdditionalNetworking";

		public const string VERSION = "2.3.3";

		internal static ManualLogSource Log;

		internal static readonly List<Hook> Hooks = new List<Hook>();

		internal static void VerboseLog(LogLevel logLevel, Func<string> message)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (message != null && (PluginConfig.Debug.Verbose.Value & logLevel) != 0)
			{
				Log.Log(logLevel, (object)message());
			}
		}

		private void Awake()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				if (LobbyCompatibilityChecker.Enabled)
				{
					LobbyCompatibilityChecker.Init();
				}
				Log.LogInfo((object)"Initializing Configs");
				PluginConfig.Init((BaseUnityPlugin)(object)this);
				Log.LogInfo((object)"Patching Methods");
				Harmony val = new Harmony("mattymatty.AdditionalNetworking");
				val.PatchAll();
				StartOfRoundPatch.Init();
				Log.LogInfo((object)"AdditionalNetworking v2.3.3 Loaded!");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Exception while initializing: \n" + ex));
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "mattymatty.AdditionalNetworking";

		public const string PLUGIN_NAME = "AdditionalNetworking";

		public const string PLUGIN_VERSION = "2.3.3";
	}
}
namespace AdditionalNetworking.Patches
{
	[HarmonyPatch]
	internal class NetworkManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(NetworkManager), "Initialize")]
		private static void AfterInitialize()
		{
			AdditionalNetworking.Log.LogInfo((object)"Registering Named Messages!");
			PlayerController.RegisterMessages();
			GrabbableObject.RegisterMessages();
			Shotgun.RegisterMessages();
			Boombox.RegisterMessages();
		}

		[HarmonyPatch(typeof(GameNetworkManager), "SetInstanceValuesBackToDefault")]
		[HarmonyPostfix]
		public static void SetInstanceValuesBackToDefault()
		{
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.CustomMessagingManager != null)
			{
				AdditionalNetworking.Log.LogInfo((object)"Unregistering Named Messages!");
				PlayerController.UnregisterMessages();
				GrabbableObject.UnregisterMessages();
				Shotgun.UnregisterMessages();
				Boombox.UnregisterMessages();
			}
		}
	}
	[HarmonyPatch]
	internal class RoundManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		private static void OnNewLevel(RoundManager __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)(object)__instance).IsRPCClientStage())
			{
				((INetworkRoundManager)__instance).AdditionalNetworking_ScrapPendingSync = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(RoundManager), "SyncScrapValuesClientRpc")]
		private static void AfterScrapValueSync(RoundManager __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)(object)__instance).IsRPCClientStage())
			{
				((INetworkRoundManager)__instance).AdditionalNetworking_ScrapPendingSync = false;
			}
		}
	}
	[HarmonyPatch]
	internal class StartOfRoundPatch
	{
		[HarmonyFinalizer]
		[HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")]
		private static void AfterUnlockablesClientSync(StartOfRound __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)(object)__instance).IsRPCClientStage() && !AdditionalNetworking.PluginConfig.Value.ShouldSkipGrabbableSync)
			{
				((INetworkStartOfRound)__instance).AdditionalNetworking_ValuablesSynced = true;
			}
		}

		private static void SyncGrabbableReplacement()
		{
			ulong[] targets = NetworkManager.Singleton.ConnectedClientsIds.Where((ulong id) => id != 0).ToArray();
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			IEnumerable<GrabbableDataHolder> source = from g in array
				where ((NetworkBehaviour)g).IsSpawned
				select new GrabbableDataHolder(g);
			try
			{
				AdditionalNetworking.Log.LogInfo((object)$"Syncing {array.Length} items!");
				foreach (IEnumerable<GrabbableDataHolder> item in Extensions.Chunk(source, 500))
				{
					GrabbableDataHolder[] grabbableItems = item.ToArray();
					GrabbableObject.SyncMultipleValuesClientRpc(in grabbableItems, targets);
				}
				GrabbableObject.MarkValuablesSyncedClientRpc(targets);
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception syncing all grabbables\n{arg}");
			}
		}

		[HarmonyTranspiler]
		[HarmonyBefore(new string[] { "LethalPerformance" })]
		[HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesServerRpc")]
		private static IEnumerable<CodeInstruction> PatchSyncShipUnlockablesServerRpc(IEnumerable<CodeInstruction> instructions, ILGenerator ilGenerator, MethodBase method)
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Expected O, but got Unknown
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			CodeInstruction[] array = instructions.ToArray();
			ILInjector iLInjector = new ILInjector(array, ilGenerator);
			iLInjector.Find(ILMatcher.Ldc(), ILMatcher.Ldc(), ILMatcher.Call(typeof(Object).GetGenericMethod("FindObjectsByType", new Type[2]
			{
				typeof(FindObjectsInactive),
				typeof(FindObjectsSortMode)
			}, new Type[1] { typeof(GrabbableObject) }), "PatchSyncShipUnlockablesServerRpc", "./Plugin/src/Patches/StartOfRoundPatch.cs", 79));
			if (!iLInjector.IsValid)
			{
				AdditionalNetworking.Log.LogError((object)("Failed to find FindObjectsByType in " + method.DeclaringType.FullName + "." + method.Name));
				return array;
			}
			iLInjector.DefineLabel(out var label).DefineLabel(out var label2).InsertAfterBranch(new CodeInstruction(OpCodes.Call, (object)typeof(AdditionalNetworking.PluginConfig.Value).GetProperty("ShouldSkipGrabbableSync", BindingFlags.Static | BindingFlags.NonPublic).GetMethod), new CodeInstruction(OpCodes.Brtrue, (object)label2));
			iLInjector.Find(ILMatcher.Call(typeof(Enumerable).GetGenericMethod("ToArray", new Type[1] { typeof(IEnumerable<GrabbableObject>) }, new Type[1] { typeof(GrabbableObject) }), "PatchSyncShipUnlockablesServerRpc", "./Plugin/src/Patches/StartOfRoundPatch.cs", 102), ILMatcher.Stloc().CaptureAs(out var variable));
			if (!iLInjector.IsValid)
			{
				AdditionalNetworking.Log.LogError((object)("Failed to find ToArray in " + method.DeclaringType.FullName + "." + method.Name));
				return array;
			}
			iLInjector.GoToMatchEnd().AddLabel(label).Insert(new CodeInstruction(OpCodes.Br, (object)label), new CodeInstruction(OpCodes.Call, (object)typeof(Array).GetGenericMethod("Empty", Array.Empty<Type>(), new Type[1] { typeof(GrabbableObject) }))
			{
				labels = new List<Label>(1) { label2 }
			}, variable);
			iLInjector.Find(ILMatcher.Call(typeof(StartOfRound).GetMethod("SyncShipUnlockablesClientRpc"), "PatchSyncShipUnlockablesServerRpc", "./Plugin/src/Patches/StartOfRoundPatch.cs", 128));
			if (!iLInjector.IsValid)
			{
				AdditionalNetworking.Log.LogError((object)("Failed to find call to SyncShipUnlockablesClientRpc in " + method.DeclaringType.FullName + "." + method.Name));
				return array;
			}
			iLInjector.GoToMatchEnd().Insert(new CodeInstruction(OpCodes.Call, (object)typeof(StartOfRoundPatch).GetMethod("SyncGrabbableReplacement", BindingFlags.Static | BindingFlags.NonPublic)));
			return iLInjector.ReleaseInstructions();
		}

		internal static void Init()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			AdditionalNetworking.Hooks.Add(new Hook((MethodBase)AccessTools.Method(typeof(StartOfRound), "Awake", (Type[])null, (Type[])null), (Delegate)new Action<Action<StartOfRound>, StartOfRound>(PrepareItemCache)));
		}

		private static void PrepareItemCache(Action<StartOfRound> orig, StartOfRound __instance)
		{
			ItemCategory.ItemModMap.Clear();
			if (ItemCategory.VanillaItems == null)
			{
				ItemCategory.VanillaItems = __instance.allItemsList.itemsList.ToArray();
			}
			Item[] vanillaItems = ItemCategory.VanillaItems;
			foreach (Item key in vanillaItems)
			{
				ItemCategory.ItemModMap.TryAdd(key, ("Vanilla", ""));
			}
			orig(__instance);
		}

		[HarmonyPrefix]
		[HarmonyAfter(new string[] { "imabatby.lethallevelloader" })]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static void PopulateModdedCache(StartOfRound __instance)
		{
			if (LethalLibProxy.Enabled)
			{
				LethalLibProxy.GetModdedItems(in ItemCategory.ItemModMap);
			}
			if (LethalLevelLoaderProxy.Enabled)
			{
				LethalLevelLoaderProxy.GetModdedItems(in ItemCategory.ItemModMap);
			}
			foreach (Item items in __instance.allItemsList.itemsList)
			{
				ItemCategory.ItemModMap.TryAdd(items, ("Unknown", ""));
			}
		}
	}
}
namespace AdditionalNetworking.Patches.Value
{
	[HarmonyPatch]
	internal class GrabbableObjectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void CheckScrapHasValue(GrabbableObject __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.Value.Enabled.Value || ((NetworkBehaviour)__instance).IsServer || !__instance.itemProperties.isScrap || ((INetworkGrabbableObject)__instance).AdditionalNetworking_IsInitialized || ((INetworkGrabbableObject)__instance).AdditionalNetworking_RequestedSync || (StartOfRound.Instance.inShipPhase && !((INetworkStartOfRound)StartOfRound.Instance).AdditionalNetworking_ValuablesSynced) || ((INetworkRoundManager)RoundManager.Instance).AdditionalNetworking_ScrapPendingSync)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				string keyForItem = ItemCategory.GetKeyForItem(__instance.itemProperties);
				AdditionalNetworking.Log.LogFatal((object)$"{keyForItem}({((Object)__instance).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			try
			{
				GrabbableObject.RequestSyncServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
				((INetworkGrabbableObject)__instance).AdditionalNetworking_RequestedSync = true;
			}
			catch (Exception arg)
			{
				string keyForItem2 = ItemCategory.GetKeyForItem(__instance.itemProperties);
				AdditionalNetworking.Log.LogError((object)$"Exception during networking of {keyForItem2}({((NetworkBehaviour)__instance).NetworkObjectId}): {arg}");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")]
		[HarmonyPatch(typeof(GrabbableObject), "LoadItemSaveData")]
		private static void OnInitialize(GrabbableObject __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((INetworkGrabbableObject)__instance).AdditionalNetworking_IsInitialized = true;
		}
	}
}
namespace AdditionalNetworking.Patches.State
{
	[HarmonyPatch(typeof(AnimatedItem))]
	internal static class AnimatedItemPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void OnStart(AnimatedItem __instance)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.ItemState.Animated.Value || ((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				string keyForItem = ItemCategory.GetKeyForItem(((GrabbableObject)__instance).itemProperties);
				AdditionalNetworking.Log.LogFatal((object)$"{keyForItem}({((Object)__instance).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			try
			{
				AnimatedObject.RequestSyncServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
			}
			catch (Exception arg)
			{
				string keyForItem2 = ItemCategory.GetKeyForItem(((GrabbableObject)__instance).itemProperties);
				AdditionalNetworking.Log.LogError((object)$"Exception during networking of {keyForItem2}({((NetworkBehaviour)__instance).NetworkObjectId}): {arg}");
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch("EquipItem")]
		private static void OnEquipItem(AnimatedItem __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.ItemState.Animated.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				((INetworkAnimatedItem)__instance).AdditionalNetworking_Changed = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void OnLateUpdate(GrabbableObject __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.ItemState.Animated.Value)
			{
				return;
			}
			AnimatedItem val = (AnimatedItem)(object)((__instance is AnimatedItem) ? __instance : null);
			if ((Object)(object)val == (Object)null || ((INetworkAnimatedItem)__instance).AdditionalNetworking_Changed)
			{
				return;
			}
			((INetworkAnimatedItem)__instance).AdditionalNetworking_Changed = false;
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				string keyForItem = ItemCategory.GetKeyForItem(__instance.itemProperties);
				AdditionalNetworking.Log.LogFatal((object)$"{keyForItem}({((Object)__instance).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
			}
			else if (((NetworkBehaviour)__instance).IsOwner)
			{
				try
				{
					AudioSource itemAudio = val.itemAudio;
					AnimatedObject.SyncStateServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), itemAudio.isPlaying);
				}
				catch (Exception arg)
				{
					string keyForItem2 = ItemCategory.GetKeyForItem(__instance.itemProperties);
					AdditionalNetworking.Log.LogFatal((object)$"Exception syncing animator state of {keyForItem2}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
				}
			}
		}
	}
	[HarmonyPatch]
	internal class BoomboxItemPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(BoomboxItem), "Start")]
		private static void OnStart(BoomboxItem __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.ItemState.Boombox.Value || ((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			try
			{
				Boombox.RequestSyncServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(BoomboxItem), "StartMusic")]
		private static void OnMusicChange(BoomboxItem __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.ItemState.Boombox.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				((INetworkBoomboxItem)__instance).AdditionalNetworking_Changed = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void OnLateUpdate(GrabbableObject __instance)
		{
			//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_0092: Unknown result type (might be due to invalid IL or missing references)
			BoomboxItem val = (BoomboxItem)(object)((__instance is BoomboxItem) ? __instance : null);
			if ((Object)(object)val == (Object)null || ((INetworkBoomboxItem)__instance).AdditionalNetworking_Changed)
			{
				return;
			}
			((INetworkBoomboxItem)__instance).AdditionalNetworking_Changed = false;
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				string keyForItem = ItemCategory.GetKeyForItem(__instance.itemProperties);
				AdditionalNetworking.Log.LogFatal((object)$"{keyForItem}({((Object)__instance).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
			}
			else if (((NetworkBehaviour)__instance).IsOwner)
			{
				int track = Array.IndexOf(val.musicAudios, val.boomboxAudio.clip);
				bool isPlayingMusic = val.isPlayingMusic;
				try
				{
					Boombox.SyncStateServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), isPlayingMusic, track);
				}
				catch (Exception arg)
				{
					string keyForItem2 = ItemCategory.GetKeyForItem(__instance.itemProperties);
					AdditionalNetworking.Log.LogError((object)$"Exception during networking of {keyForItem2}({((NetworkBehaviour)__instance).NetworkObjectId}): {arg}");
				}
			}
		}
	}
	[HarmonyPatch]
	internal class NutcrackerEnemyAiPatch
	{
		[HarmonyFinalizer]
		[HarmonyPatch(typeof(NutcrackerEnemyAI), "ReloadGunClientRpc")]
		private static void OnReload(NutcrackerEnemyAI __instance)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)(object)__instance).IsRPCClientStage() || !((NetworkBehaviour)__instance).IsOwner || !AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				AdditionalNetworking.Log.LogFatal((object)$"{((Object)((NetworkBehaviour)__instance).NetworkObject).name}({((Object)__instance).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			if (!((NetworkBehaviour)__instance.gun).NetworkObject.IsSpawned)
			{
				string keyForItem = ItemCategory.GetKeyForItem(((GrabbableObject)__instance.gun).itemProperties);
				AdditionalNetworking.Log.LogFatal((object)$"{keyForItem}({((Object)__instance.gun).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			try
			{
				Shotgun.SyncAmmoServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance.gun).NetworkObject), __instance.gun.shellsLoaded);
			}
			catch (Exception arg)
			{
				string keyForItem2 = ItemCategory.GetKeyForItem(((GrabbableObject)__instance.gun).itemProperties);
				AdditionalNetworking.Log.LogError((object)$"Exception during networking of {keyForItem2}({((NetworkBehaviour)__instance).NetworkObjectId}): {arg}");
			}
		}
	}
	[HarmonyPatch]
	internal class PlayerControllerBPatch
	{
		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		private static void OnLateUpdate(PlayerControllerB __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (((INetworkPlayerControllerB)__instance).AdditionalNetworking_LastCrouchState == __instance.isCrouching)
			{
				return;
			}
			((INetworkPlayerControllerB)__instance).AdditionalNetworking_LastCrouchState = __instance.isCrouching;
			if (!AdditionalNetworking.PluginConfig.PlayerState.Crouching.Value || !((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			try
			{
				PlayerController.SyncCrouchServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), __instance.isCrouching);
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception during networking of {__instance.playerUsername}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectServerRpc")]
		private static void OnGrabRequest(PlayerControllerB __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)(object)__instance).IsRPCServerStage())
			{
				GrabbableObject currentlyGrabbingObject = __instance.currentlyGrabbingObject;
				if (Object.op_Implicit((Object)(object)currentlyGrabbingObject) && currentlyGrabbingObject is ShotgunItem)
				{
					Shotgun.RequestSyncServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance.currentlyGrabbingObject).NetworkObject));
				}
			}
		}
	}
	[HarmonyPatch]
	internal class ShotgunItemPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShotgunItem), "Start")]
		private static void OnStart(ShotgunItem __instance)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value || ((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				string keyForItem = ItemCategory.GetKeyForItem(((GrabbableObject)__instance).itemProperties);
				AdditionalNetworking.Log.LogFatal((object)$"{keyForItem}({((Object)__instance).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			try
			{
				Shotgun.RequestSyncServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
			}
			catch (Exception arg)
			{
				string keyForItem2 = ItemCategory.GetKeyForItem(((GrabbableObject)__instance).itemProperties);
				AdditionalNetworking.Log.LogError((object)$"Exception during networking of {keyForItem2}({((NetworkBehaviour)__instance).NetworkObjectId}): {arg}");
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(ShotgunItem), "ReloadGunEffectsServerRpc")]
		private static void OnAmmoReload(ShotgunItem __instance, bool start)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value && !start && ((NetworkBehaviour)__instance).IsOwner)
			{
				((INetworkShotgunItem)__instance).AdditionalNetworking_AmmoCountChanged = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(ShotgunItem), "ShootGun")]
		private static void OnShot(ShotgunItem __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				((INetworkShotgunItem)__instance).AdditionalNetworking_AmmoCountChanged = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(ShotgunItem), "ItemInteractLeftRight")]
		private static void OnSafetyToggle(ShotgunItem __instance, bool right)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				((INetworkShotgunItem)__instance).AdditionalNetworking_SafetyChanged = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void OnLateUpdate(GrabbableObject __instance)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			ShotgunItem val = (ShotgunItem)(object)((__instance is ShotgunItem) ? __instance : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				string keyForItem = ItemCategory.GetKeyForItem(__instance.itemProperties);
				AdditionalNetworking.Log.LogFatal((object)$"{keyForItem}({((Object)__instance).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			if (((INetworkShotgunItem)__instance).AdditionalNetworking_AmmoCountChanged)
			{
				((INetworkShotgunItem)__instance).AdditionalNetworking_AmmoCountChanged = false;
				if (((NetworkBehaviour)__instance).IsOwner)
				{
					try
					{
						Shotgun.SyncAmmoServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), val.shellsLoaded);
					}
					catch (Exception arg)
					{
						string keyForItem2 = ItemCategory.GetKeyForItem(__instance.itemProperties);
						AdditionalNetworking.Log.LogError((object)$"Exception during networking of {keyForItem2}({((NetworkBehaviour)__instance).NetworkObjectId}): {arg}");
					}
				}
			}
			if (!((INetworkShotgunItem)__instance).AdditionalNetworking_SafetyChanged)
			{
				return;
			}
			((INetworkShotgunItem)__instance).AdditionalNetworking_SafetyChanged = false;
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			try
			{
				Shotgun.SyncSafetyServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), val.safetyOn);
			}
			catch (Exception arg2)
			{
				string keyForItem3 = ItemCategory.GetKeyForItem(__instance.itemProperties);
				AdditionalNetworking.Log.LogError((object)$"Exception during networking of {keyForItem3}({((NetworkBehaviour)__instance).NetworkObjectId}): {arg2}");
			}
		}
	}
}
namespace AdditionalNetworking.Patches.Inventory
{
	[HarmonyPatch]
	internal class PlayerControllerBPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		private static void OnStart(PlayerControllerB __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.Misc.Username.Value || ((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			try
			{
				PlayerController.RequestSyncUsernameServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking of {__instance.playerUsername}({((NetworkBehaviour)__instance).NetworkObjectId}): {arg}");
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")]
		private static void OnSlotChange(PlayerControllerB __instance, int slot)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.Inventory.SlotChange.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				((INetworkPlayerControllerB)__instance).AdditionalNetworking_SlotChanged = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")]
		private static void OnItemGrabbed(PlayerControllerB __instance, bool grabValidated)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)(object)__instance).IsRPCClientStage() && AdditionalNetworking.PluginConfig.Inventory.InventoryChange.Value && ((NetworkBehaviour)__instance).IsOwner && grabValidated)
			{
				((INetworkPlayerControllerB)__instance).AdditionalNetworking_InventoryChanged = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
		private static void OnDiscardItem(PlayerControllerB __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.Inventory.InventoryChange.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				((INetworkPlayerControllerB)__instance).AdditionalNetworking_InventoryChanged = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "DropAllHeldItems")]
		private static void OnDropItem(PlayerControllerB __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.Inventory.InventoryChange.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				((INetworkPlayerControllerB)__instance).AdditionalNetworking_InventoryChanged = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		private static void OnPlayerConnected(PlayerControllerB __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.Misc.Username.Value || ((NetworkBehaviour)__instance).IsServer || !((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			try
			{
				PlayerController.SyncUsernameServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), __instance.playerUsername);
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception during networking of {__instance.playerUsername}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		private static void OnLateUpdate(PlayerControllerB __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if (((INetworkPlayerControllerB)__instance).AdditionalNetworking_SlotChanged)
			{
				((INetworkPlayerControllerB)__instance).AdditionalNetworking_SlotChanged = false;
				if (((NetworkBehaviour)__instance).IsOwner)
				{
					try
					{
						PlayerController.SyncSelectedSlotServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), __instance.currentItemSlot);
					}
					catch (Exception arg)
					{
						AdditionalNetworking.Log.LogFatal((object)$"Exception during networking of {__instance.playerUsername}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
					}
				}
			}
			if (!((INetworkPlayerControllerB)__instance).AdditionalNetworking_InventoryChanged)
			{
				return;
			}
			((INetworkPlayerControllerB)__instance).AdditionalNetworking_InventoryChanged = false;
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			List<NetworkObjectReference> list = default(List<NetworkObjectReference>);
			PooledObject<List<NetworkObjectReference>> val = CollectionPool<List<NetworkObjectReference>, NetworkObjectReference>.Get(ref list);
			try
			{
				List<int> list2 = default(List<int>);
				PooledObject<List<int>> val2 = CollectionPool<List<int>, int>.Get(ref list2);
				try
				{
					for (int i = 0; i < __instance.ItemSlots.Length; i++)
					{
						GrabbableObject val3 = __instance.ItemSlots[i];
						if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((NetworkBehaviour)val3).NetworkObject == (Object)null))
						{
							if (!((NetworkBehaviour)val3).NetworkObject.IsSpawned)
							{
								string keyForItem = ItemCategory.GetKeyForItem(val3.itemProperties);
								AdditionalNetworking.Log.LogFatal((object)$"{keyForItem}({((Object)val3).GetInstanceID()}) is not spawned! nobody else in the network knows about it!");
							}
							else
							{
								list.Add(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val3).NetworkObject));
								list2.Add(i);
							}
						}
					}
					try
					{
						PlayerController.SyncInventoryServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), list.ToArray(), list2.ToArray());
					}
					catch (Exception arg2)
					{
						AdditionalNetworking.Log.LogFatal((object)$"Exception during networking of {__instance.playerUsername}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg2}");
					}
				}
				finally
				{
					((IDisposable)val2).Dispose();
				}
			}
			finally
			{
				((IDisposable)val).Dispose();
			}
		}
	}
}
namespace AdditionalNetworking.Networking
{
	public static class AnimatedObject
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnSyncAudioStateServerRpc;

			public static HandleNamedMessageDelegate <1>__OnSyncAudioStateClientRpc;

			public static HandleNamedMessageDelegate <2>__OnRequestSyncServerRpc;
		}

		private static readonly string BaseName = typeof(AnimatedObject).FullName;

		private static readonly string SyncAudioStateServerRpcMessage = BaseName + "|SyncAudioStateServerRpc";

		private static readonly string SyncAudioStateClientRpcMessage = BaseName + "|SyncAudioStateClientRpc";

		private static readonly string RequestSyncServerRpcMessage = BaseName + "|RequestSyncServerRpc";

		internal static void RegisterMessages()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_007d: 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)
			//IL_0088: Expected O, but got Unknown
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			string syncAudioStateServerRpcMessage = SyncAudioStateServerRpcMessage;
			object obj = <>O.<0>__OnSyncAudioStateServerRpc;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = OnSyncAudioStateServerRpc;
				<>O.<0>__OnSyncAudioStateServerRpc = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler(syncAudioStateServerRpcMessage, (HandleNamedMessageDelegate)obj);
			CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
			string syncAudioStateClientRpcMessage = SyncAudioStateClientRpcMessage;
			object obj2 = <>O.<1>__OnSyncAudioStateClientRpc;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnSyncAudioStateClientRpc;
				<>O.<1>__OnSyncAudioStateClientRpc = val2;
				obj2 = (object)val2;
			}
			customMessagingManager2.RegisterNamedMessageHandler(syncAudioStateClientRpcMessage, (HandleNamedMessageDelegate)obj2);
			CustomMessagingManager customMessagingManager3 = NetworkManager.Singleton.CustomMessagingManager;
			string requestSyncServerRpcMessage = RequestSyncServerRpcMessage;
			object obj3 = <>O.<2>__OnRequestSyncServerRpc;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val3 = OnRequestSyncServerRpc;
				<>O.<2>__OnRequestSyncServerRpc = val3;
				obj3 = (object)val3;
			}
			customMessagingManager3.RegisterNamedMessageHandler(requestSyncServerRpcMessage, (HandleNamedMessageDelegate)obj3);
		}

		public static void SyncStateServerRpc(NetworkObjectReference itemReference, bool playing)
		{
			//IL_001d: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref itemReference);
			((FastBufferWriter)(ref val)).WriteValue<bool>(ref playing, default(ForPrimitives));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncAudioStateServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnSyncAudioStateServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			try
			{
				NetworkObjectReference itemReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref itemReference);
				bool playing = default(bool);
				((FastBufferReader)(ref data)).ReadValue<bool>(ref playing, default(ForPrimitives));
				NetworkObject val = default(NetworkObject);
				if (((NetworkObjectReference)(ref itemReference)).TryGet(ref val, (NetworkManager)null) && (senderId == 0L || val.OwnerClientId == senderId))
				{
					AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncStateServerRpc was called for {1}! playing: {2}", "AnimatedObject", ((NetworkObjectReference)(ref itemReference)).NetworkObjectId, playing));
					SyncStateClientRpc(itemReference, playing);
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		private static void SyncStateClientRpc(NetworkObjectReference itemReference, bool playing, ulong[] targets = null)
		{
			//IL_001d: 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_0053: 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)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref itemReference);
			((FastBufferWriter)(ref val)).WriteValue<bool>(ref playing, default(ForPrimitives));
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncAudioStateClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncAudioStateClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnSyncAudioStateClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (senderId != 0L)
			{
				return;
			}
			try
			{
				NetworkObjectReference itemReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref itemReference);
				bool playing = default(bool);
				((FastBufferReader)(ref data)).ReadValue<bool>(ref playing, default(ForPrimitives));
				NetworkObject val = default(NetworkObject);
				if (!((NetworkObjectReference)(ref itemReference)).TryGet(ref val, (NetworkManager)null))
				{
					return;
				}
				AnimatedItem component = NetworkObjectReference.op_Implicit(itemReference).GetComponent<AnimatedItem>();
				bool oldState = component.itemAudio.isPlaying;
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncStateClientRpc was called for {1}! playing: {2} was: {3}", "Boombox", ((NetworkObjectReference)(ref itemReference)).NetworkObjectId, playing, oldState));
				if (!((NetworkBehaviour)component).IsOwner && playing != oldState)
				{
					AudioSource itemAudio = component.itemAudio;
					if (playing)
					{
						itemAudio.clip = component.grabAudio;
						itemAudio.loop = component.loopGrabAudio;
						itemAudio.Play();
					}
					else
					{
						itemAudio.Stop();
					}
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		public static void RequestSyncServerRpc(NetworkObjectReference itemReference)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref itemReference);
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(RequestSyncServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnRequestSyncServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			try
			{
				NetworkObjectReference itemReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref itemReference);
				NetworkObject val = default(NetworkObject);
				if (((NetworkObjectReference)(ref itemReference)).TryGet(ref val, (NetworkManager)null))
				{
					AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.RequestSyncServerRpc was called for {1} by {2}!", "Boombox", ((NetworkObjectReference)(ref itemReference)).NetworkObjectId, senderId));
					AnimatedItem component = NetworkObjectReference.op_Implicit(itemReference).GetComponent<AnimatedItem>();
					bool isPlaying = component.itemAudio.isPlaying;
					SyncStateClientRpc(itemReference, isPlaying, new ulong[1] { senderId });
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}
	}
	public static class Boombox
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnSyncStateServerRpc;

			public static HandleNamedMessageDelegate <1>__OnSyncStateClientRpc;

			public static HandleNamedMessageDelegate <2>__OnRequestSyncServerRpc;
		}

		private static readonly string BaseName = typeof(Boombox).FullName;

		private static readonly string SyncStateServerRpcMessage = BaseName + "|SyncStateServerRpc";

		private static readonly string SyncStateClientRpcMessage = BaseName + "|SyncStateClientRpc";

		private static readonly string RequestSyncServerRpcMessage = BaseName + "|RequestSyncServerRpc";

		internal static void RegisterMessages()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_007d: 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)
			//IL_0088: Expected O, but got Unknown
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			string syncStateServerRpcMessage = SyncStateServerRpcMessage;
			object obj = <>O.<0>__OnSyncStateServerRpc;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = OnSyncStateServerRpc;
				<>O.<0>__OnSyncStateServerRpc = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler(syncStateServerRpcMessage, (HandleNamedMessageDelegate)obj);
			CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
			string syncStateClientRpcMessage = SyncStateClientRpcMessage;
			object obj2 = <>O.<1>__OnSyncStateClientRpc;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnSyncStateClientRpc;
				<>O.<1>__OnSyncStateClientRpc = val2;
				obj2 = (object)val2;
			}
			customMessagingManager2.RegisterNamedMessageHandler(syncStateClientRpcMessage, (HandleNamedMessageDelegate)obj2);
			CustomMessagingManager customMessagingManager3 = NetworkManager.Singleton.CustomMessagingManager;
			string requestSyncServerRpcMessage = RequestSyncServerRpcMessage;
			object obj3 = <>O.<2>__OnRequestSyncServerRpc;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val3 = OnRequestSyncServerRpc;
				<>O.<2>__OnRequestSyncServerRpc = val3;
				obj3 = (object)val3;
			}
			customMessagingManager3.RegisterNamedMessageHandler(requestSyncServerRpcMessage, (HandleNamedMessageDelegate)obj3);
		}

		internal static void UnregisterMessages()
		{
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncStateServerRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncStateClientRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(RequestSyncServerRpcMessage);
		}

		public static void SyncStateServerRpc(NetworkObjectReference boomboxReference, bool playing, int track)
		{
			//IL_001d: 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_002f: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref boomboxReference);
			((FastBufferWriter)(ref val)).WriteValue<bool>(ref playing, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValue<int>(ref track, default(ForPrimitives));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncStateServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnSyncStateServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			try
			{
				NetworkObjectReference boomboxReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref boomboxReference);
				bool playing = default(bool);
				((FastBufferReader)(ref data)).ReadValue<bool>(ref playing, default(ForPrimitives));
				int track = default(int);
				((FastBufferReader)(ref data)).ReadValue<int>(ref track, default(ForPrimitives));
				NetworkObject val = default(NetworkObject);
				if (((NetworkObjectReference)(ref boomboxReference)).TryGet(ref val, (NetworkManager)null) && (senderId == 0L || val.OwnerClientId == senderId))
				{
					AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncStateServerRpc was called for {1}! track: {2}, playing: {3}", "Boombox", ((NetworkObjectReference)(ref boomboxReference)).NetworkObjectId, track, playing));
					SyncStateClientRpc(boomboxReference, playing, track);
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		private static void SyncStateClientRpc(NetworkObjectReference boomboxReference, bool playing, int track, ulong[] targets = null)
		{
			//IL_001d: 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_002f: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref boomboxReference);
			((FastBufferWriter)(ref val)).WriteValue<bool>(ref playing, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValue<int>(ref track, default(ForPrimitives));
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncStateClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncStateClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnSyncStateClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (senderId != 0L)
			{
				return;
			}
			try
			{
				NetworkObjectReference boomboxReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref boomboxReference);
				bool playing = default(bool);
				((FastBufferReader)(ref data)).ReadValue<bool>(ref playing, default(ForPrimitives));
				int track = default(int);
				((FastBufferReader)(ref data)).ReadValue<int>(ref track, default(ForPrimitives));
				NetworkObject val = default(NetworkObject);
				if (!((NetworkObjectReference)(ref boomboxReference)).TryGet(ref val, (NetworkManager)null))
				{
					return;
				}
				BoomboxItem component = NetworkObjectReference.op_Implicit(boomboxReference).GetComponent<BoomboxItem>();
				int oldTrack = Array.IndexOf(component.musicAudios, component.boomboxAudio.clip);
				bool oldState = component.isPlayingMusic;
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncStateClientRpc was called for {1}! track: {2}, playing: {3} was track: {4}, playing: {5}", "Boombox", ((NetworkObjectReference)(ref boomboxReference)).NetworkObjectId, track, playing, oldTrack, oldState));
				if (((NetworkBehaviour)component).IsOwner)
				{
					return;
				}
				if (!playing)
				{
					if (oldState)
					{
						component.StartMusic(false, false);
					}
				}
				else if (track != -1 && (!oldState || oldTrack != track))
				{
					component.isPlayingMusic = true;
					((GrabbableObject)component).isBeingUsed = true;
					component.boomboxAudio.Stop();
					component.boomboxAudio.clip = component.musicAudios[track];
					component.boomboxAudio.pitch = 1f;
					component.boomboxAudio.Play();
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		public static void RequestSyncServerRpc(NetworkObjectReference boomboxReference)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref boomboxReference);
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(RequestSyncServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnRequestSyncServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			try
			{
				NetworkObjectReference boomboxReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref boomboxReference);
				NetworkObject val = default(NetworkObject);
				if (((NetworkObjectReference)(ref boomboxReference)).TryGet(ref val, (NetworkManager)null))
				{
					AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.RequestSyncServerRpc was called for {1} by {2}!", "Boombox", ((NetworkObjectReference)(ref boomboxReference)).NetworkObjectId, senderId));
					BoomboxItem component = NetworkObjectReference.op_Implicit(boomboxReference).GetComponent<BoomboxItem>();
					int track = Array.IndexOf(component.musicAudios, component.boomboxAudio.clip);
					bool isPlayingMusic = component.isPlayingMusic;
					SyncStateClientRpc(boomboxReference, isPlayingMusic, track, new ulong[1] { senderId });
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}
	}
	public static class GrabbableObject
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnSyncValuesClientRpc;

			public static HandleNamedMessageDelegate <1>__OnRequestSyncServerRpc;

			public static HandleNamedMessageDelegate <2>__OnSyncMultipleValuesClientRpc;

			public static HandleNamedMessageDelegate <3>__OnMarkValuablesSyncedClientRpc;
		}

		private static readonly string BaseName = typeof(GrabbableObject).FullName;

		private static readonly string SyncValuesClientRpcMessage = BaseName + "|SyncValuesClientRpc";

		private static readonly string RequestSyncServerRpcMessage = BaseName + "|RequestSyncServerRpc";

		private static readonly string SyncMultipleValuesClientRpcMessage = BaseName + "|SyncMultipleValuesClientRpc";

		private static readonly string MarkValuablesSyncedClientRpcMessage = BaseName + "|MarkValuablesSyncedClientRpc";

		internal static void RegisterMessages()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_007d: 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)
			//IL_0088: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			string syncValuesClientRpcMessage = SyncValuesClientRpcMessage;
			object obj = <>O.<0>__OnSyncValuesClientRpc;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = OnSyncValuesClientRpc;
				<>O.<0>__OnSyncValuesClientRpc = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler(syncValuesClientRpcMessage, (HandleNamedMessageDelegate)obj);
			CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
			string requestSyncServerRpcMessage = RequestSyncServerRpcMessage;
			object obj2 = <>O.<1>__OnRequestSyncServerRpc;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnRequestSyncServerRpc;
				<>O.<1>__OnRequestSyncServerRpc = val2;
				obj2 = (object)val2;
			}
			customMessagingManager2.RegisterNamedMessageHandler(requestSyncServerRpcMessage, (HandleNamedMessageDelegate)obj2);
			CustomMessagingManager customMessagingManager3 = NetworkManager.Singleton.CustomMessagingManager;
			string syncMultipleValuesClientRpcMessage = SyncMultipleValuesClientRpcMessage;
			object obj3 = <>O.<2>__OnSyncMultipleValuesClientRpc;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val3 = OnSyncMultipleValuesClientRpc;
				<>O.<2>__OnSyncMultipleValuesClientRpc = val3;
				obj3 = (object)val3;
			}
			customMessagingManager3.RegisterNamedMessageHandler(syncMultipleValuesClientRpcMessage, (HandleNamedMessageDelegate)obj3);
			CustomMessagingManager customMessagingManager4 = NetworkManager.Singleton.CustomMessagingManager;
			string markValuablesSyncedClientRpcMessage = MarkValuablesSyncedClientRpcMessage;
			object obj4 = <>O.<3>__OnMarkValuablesSyncedClientRpc;
			if (obj4 == null)
			{
				HandleNamedMessageDelegate val4 = OnMarkValuablesSyncedClientRpc;
				<>O.<3>__OnMarkValuablesSyncedClientRpc = val4;
				obj4 = (object)val4;
			}
			customMessagingManager4.RegisterNamedMessageHandler(markValuablesSyncedClientRpcMessage, (HandleNamedMessageDelegate)obj4);
		}

		internal static void UnregisterMessages()
		{
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncValuesClientRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(RequestSyncServerRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncMultipleValuesClientRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(MarkValuablesSyncedClientRpcMessage);
		}

		private static void SyncValuesClientRpc(in GrabbableDataHolder grabbableItem, ulong[] targets = null)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			val.WriteGrabbableDataHolder(grabbableItem);
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncValuesClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncValuesClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnSyncValuesClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_000b: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (senderId != 0L)
			{
				return;
			}
			try
			{
				data.ReadGrabbableDataHolder(out var data2);
				GrabbableDataHolder grabbableDataHolder = data2;
				var (grabbableReference, scrapValue, dataValue) = (GrabbableDataHolder)(ref grabbableDataHolder);
				NetworkObject val2 = default(NetworkObject);
				if (((NetworkObjectReference)(ref grabbableReference)).TryGet(ref val2, (NetworkManager)null))
				{
					GrabbableObject grabbableObject = NetworkObjectReference.op_Implicit(grabbableReference).GetComponent<GrabbableObject>();
					string itemTag = ItemCategory.GetKeyForItem(grabbableObject.itemProperties);
					AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.OnSyncValuesClientRpc was called for {1}! ItemTag: {2} scrap: {3}, data: {4}", "GrabbableObject", ((NetworkObjectReference)(ref grabbableReference)).NetworkObjectId, itemTag, scrapValue, dataValue));
					SyncSingleItem(in grabbableObject, in itemTag, in scrapValue, in dataValue);
					((INetworkGrabbableObject)grabbableObject).AdditionalNetworking_RequestedSync = false;
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		private static void SyncSingleItem(in GrabbableObject grabbableObject, in string itemTag, in int scrapValue, in int dataValue)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (grabbableObject.itemProperties.saveItemVariable)
			{
				grabbableObject.LoadItemSaveData(dataValue);
			}
			GrabbableObject obj = grabbableObject;
			GiftBoxItem val = (GiftBoxItem)(object)((obj is GiftBoxItem) ? obj : null);
			if (val != null)
			{
				val.loadedItemFromSave = false;
			}
			if (grabbableObject.itemProperties.isScrap)
			{
				if (AdditionalNetworking.PluginConfig.Value.IgnoreScanNodesList.Contains(itemTag))
				{
					grabbableObject.scrapValue = scrapValue;
					((INetworkGrabbableObject)grabbableObject).AdditionalNetworking_IsInitialized = true;
				}
				else
				{
					grabbableObject.SetScrapValue(scrapValue);
				}
			}
		}

		public static void RequestSyncServerRpc(NetworkObjectReference grabbableReference)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref grabbableReference);
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(RequestSyncServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnRequestSyncServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			try
			{
				NetworkObjectReference grabbableReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref grabbableReference);
				NetworkObject val = default(NetworkObject);
				if (((NetworkObjectReference)(ref grabbableReference)).TryGet(ref val, (NetworkManager)null))
				{
					AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.RequestValuesServerRpc was called for {1} by {2}!", "GrabbableObject", ((NetworkObjectReference)(ref grabbableReference)).NetworkObjectId, senderId));
					GrabbableObject component = NetworkObjectReference.op_Implicit(grabbableReference).GetComponent<GrabbableObject>();
					GrabbableDataHolder grabbableItem = new GrabbableDataHolder(component);
					SyncValuesClientRpc(in grabbableItem, new ulong[1] { senderId });
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		internal static void SyncMultipleValuesClientRpc(in GrabbableDataHolder[] grabbableItems, ulong[] targets = null)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			int grabbableDataHolderSize = GrabbableDataHolderSerializer.GrabbableDataHolderSize;
			int num = FastBufferWriter.GetWriteSize<int>() + grabbableDataHolderSize * grabbableItems.Length;
			if (num > NetworkManager.Singleton.MaximumFragmentedMessageSize)
			{
				AdditionalNetworking.Log.LogFatal((object)"SyncMultipleValuesClientRpc: grabbableItems array is too big!");
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num, (Allocator)2, -1);
			val.WriteGrabbableDataHolderArray(grabbableItems);
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncMultipleValuesClientRpcMessage, val, (NetworkDelivery)4);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncMultipleValuesClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)4);
			}
		}

		private static void OnSyncMultipleValuesClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			if (senderId != 0L)
			{
				return;
			}
			try
			{
				data.ReadGrabbableDataHolderArray(out var dataArray);
				GrabbableDataHolder[] array = dataArray;
				NetworkObject val2 = default(NetworkObject);
				for (int i = 0; i < array.Length; i++)
				{
					GrabbableDataHolder grabbableDataHolder = array[i];
					var (grabbableReference, scrapValue, dataValue) = (GrabbableDataHolder)(ref grabbableDataHolder);
					if (!((NetworkObjectReference)(ref grabbableReference)).TryGet(ref val2, (NetworkManager)null))
					{
						break;
					}
					GrabbableObject grabbableObject = ((Component)val2).GetComponent<GrabbableObject>();
					string itemTag = ItemCategory.GetKeyForItem(grabbableObject.itemProperties);
					AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncMultipleValuesClientRpc was called for {1}! ItemTag: {2} isScrap:{3}, value: {4}, hasData:{5}, data: {6}", "GrabbableObject", ((NetworkObjectReference)(ref grabbableReference)).NetworkObjectId, itemTag, grabbableObject.itemProperties.isScrap, scrapValue, grabbableObject.itemProperties.saveItemVariable, dataValue));
					SyncSingleItem(in grabbableObject, in itemTag, in scrapValue, in dataValue);
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		internal static void MarkValuablesSyncedClientRpc(ulong[] targets = null)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1);
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(MarkValuablesSyncedClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(MarkValuablesSyncedClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnMarkValuablesSyncedClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (senderId != 0L)
			{
				return;
			}
			try
			{
				AdditionalNetworking.VerboseLog((LogLevel)32, () => "GrabbableObject.MarkValuablesSyncedClientRpc was called!");
				((INetworkStartOfRound)StartOfRound.Instance).AdditionalNetworking_ValuablesSynced = true;
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}
	}
	public static class PlayerController
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnSyncInventoryServerRpc;

			public static HandleNamedMessageDelegate <1>__OnSyncInventoryClientRpc;

			public static HandleNamedMessageDelegate <2>__OnThrowExtraItemsClientRpc;

			public static HandleNamedMessageDelegate <3>__OnSyncSelectedSlotServerRpc;

			public static HandleNamedMessageDelegate <4>__OnSyncSelectedSlotClientRpc;

			public static HandleNamedMessageDelegate <5>__OnSyncCrouchServerRpc;

			public static HandleNamedMessageDelegate <6>__OnSyncCrouchClientRpc;

			public static HandleNamedMessageDelegate <7>__OnSyncUsernameServerRpc;

			public static HandleNamedMessageDelegate <8>__OnSyncUsernameClientRpc;

			public static HandleNamedMessageDelegate <9>__OnRequestSyncUsernameServerRpc;
		}

		private static readonly string BaseName = typeof(PlayerController).FullName;

		private static readonly string SyncInventoryServerRpcMessage = BaseName + "|SyncInventoryServerRpc";

		private static readonly string SyncInventoryClientRpcMessage = BaseName + "|SyncInventoryClientRpc";

		private static readonly string ThrowExtraItemsClientRpcMessage = BaseName + "|ThrowExtraItemsClientRpc";

		private static readonly string SyncSelectedSlotServerRpcMessage = BaseName + "|SyncSelectedSlotServerRpc";

		private static readonly string SyncSelectedSlotClientRpcMessage = BaseName + "|SyncSelectedSlotClientRpc";

		private static readonly string SyncCrouchServerRpcMessage = BaseName + "|SyncCrouchServerRpc";

		private static readonly string SyncCrouchClientRpcMessage = BaseName + "|SyncCrouchClientRpc";

		private static readonly string SyncUsernameServerRpcMessage = BaseName + "|SyncUsernameServerRpc";

		private static readonly string SyncUsernameClientRpcMessage = BaseName + "|SyncUsernameClientRpc";

		private static readonly string RequestSyncUsernameServerRpcMessage = BaseName + "|RequestSyncUsernameServerRpc";

		internal static void RegisterMessages()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_007d: 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)
			//IL_0088: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			string syncInventoryServerRpcMessage = SyncInventoryServerRpcMessage;
			object obj = <>O.<0>__OnSyncInventoryServerRpc;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = OnSyncInventoryServerRpc;
				<>O.<0>__OnSyncInventoryServerRpc = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler(syncInventoryServerRpcMessage, (HandleNamedMessageDelegate)obj);
			CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
			string syncInventoryClientRpcMessage = SyncInventoryClientRpcMessage;
			object obj2 = <>O.<1>__OnSyncInventoryClientRpc;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnSyncInventoryClientRpc;
				<>O.<1>__OnSyncInventoryClientRpc = val2;
				obj2 = (object)val2;
			}
			customMessagingManager2.RegisterNamedMessageHandler(syncInventoryClientRpcMessage, (HandleNamedMessageDelegate)obj2);
			CustomMessagingManager customMessagingManager3 = NetworkManager.Singleton.CustomMessagingManager;
			string throwExtraItemsClientRpcMessage = ThrowExtraItemsClientRpcMessage;
			object obj3 = <>O.<2>__OnThrowExtraItemsClientRpc;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val3 = OnThrowExtraItemsClientRpc;
				<>O.<2>__OnThrowExtraItemsClientRpc = val3;
				obj3 = (object)val3;
			}
			customMessagingManager3.RegisterNamedMessageHandler(throwExtraItemsClientRpcMessage, (HandleNamedMessageDelegate)obj3);
			CustomMessagingManager customMessagingManager4 = NetworkManager.Singleton.CustomMessagingManager;
			string syncSelectedSlotServerRpcMessage = SyncSelectedSlotServerRpcMessage;
			object obj4 = <>O.<3>__OnSyncSelectedSlotServerRpc;
			if (obj4 == null)
			{
				HandleNamedMessageDelegate val4 = OnSyncSelectedSlotServerRpc;
				<>O.<3>__OnSyncSelectedSlotServerRpc = val4;
				obj4 = (object)val4;
			}
			customMessagingManager4.RegisterNamedMessageHandler(syncSelectedSlotServerRpcMessage, (HandleNamedMessageDelegate)obj4);
			CustomMessagingManager customMessagingManager5 = NetworkManager.Singleton.CustomMessagingManager;
			string syncSelectedSlotClientRpcMessage = SyncSelectedSlotClientRpcMessage;
			object obj5 = <>O.<4>__OnSyncSelectedSlotClientRpc;
			if (obj5 == null)
			{
				HandleNamedMessageDelegate val5 = OnSyncSelectedSlotClientRpc;
				<>O.<4>__OnSyncSelectedSlotClientRpc = val5;
				obj5 = (object)val5;
			}
			customMessagingManager5.RegisterNamedMessageHandler(syncSelectedSlotClientRpcMessage, (HandleNamedMessageDelegate)obj5);
			CustomMessagingManager customMessagingManager6 = NetworkManager.Singleton.CustomMessagingManager;
			string syncCrouchServerRpcMessage = SyncCrouchServerRpcMessage;
			object obj6 = <>O.<5>__OnSyncCrouchServerRpc;
			if (obj6 == null)
			{
				HandleNamedMessageDelegate val6 = OnSyncCrouchServerRpc;
				<>O.<5>__OnSyncCrouchServerRpc = val6;
				obj6 = (object)val6;
			}
			customMessagingManager6.RegisterNamedMessageHandler(syncCrouchServerRpcMessage, (HandleNamedMessageDelegate)obj6);
			CustomMessagingManager customMessagingManager7 = NetworkManager.Singleton.CustomMessagingManager;
			string syncCrouchClientRpcMessage = SyncCrouchClientRpcMessage;
			object obj7 = <>O.<6>__OnSyncCrouchClientRpc;
			if (obj7 == null)
			{
				HandleNamedMessageDelegate val7 = OnSyncCrouchClientRpc;
				<>O.<6>__OnSyncCrouchClientRpc = val7;
				obj7 = (object)val7;
			}
			customMessagingManager7.RegisterNamedMessageHandler(syncCrouchClientRpcMessage, (HandleNamedMessageDelegate)obj7);
			CustomMessagingManager customMessagingManager8 = NetworkManager.Singleton.CustomMessagingManager;
			string syncUsernameServerRpcMessage = SyncUsernameServerRpcMessage;
			object obj8 = <>O.<7>__OnSyncUsernameServerRpc;
			if (obj8 == null)
			{
				HandleNamedMessageDelegate val8 = OnSyncUsernameServerRpc;
				<>O.<7>__OnSyncUsernameServerRpc = val8;
				obj8 = (object)val8;
			}
			customMessagingManager8.RegisterNamedMessageHandler(syncUsernameServerRpcMessage, (HandleNamedMessageDelegate)obj8);
			CustomMessagingManager customMessagingManager9 = NetworkManager.Singleton.CustomMessagingManager;
			string syncUsernameClientRpcMessage = SyncUsernameClientRpcMessage;
			object obj9 = <>O.<8>__OnSyncUsernameClientRpc;
			if (obj9 == null)
			{
				HandleNamedMessageDelegate val9 = OnSyncUsernameClientRpc;
				<>O.<8>__OnSyncUsernameClientRpc = val9;
				obj9 = (object)val9;
			}
			customMessagingManager9.RegisterNamedMessageHandler(syncUsernameClientRpcMessage, (HandleNamedMessageDelegate)obj9);
			CustomMessagingManager customMessagingManager10 = NetworkManager.Singleton.CustomMessagingManager;
			string requestSyncUsernameServerRpcMessage = RequestSyncUsernameServerRpcMessage;
			object obj10 = <>O.<9>__OnRequestSyncUsernameServerRpc;
			if (obj10 == null)
			{
				HandleNamedMessageDelegate val10 = OnRequestSyncUsernameServerRpc;
				<>O.<9>__OnRequestSyncUsernameServerRpc = val10;
				obj10 = (object)val10;
			}
			customMessagingManager10.RegisterNamedMessageHandler(requestSyncUsernameServerRpcMessage, (HandleNamedMessageDelegate)obj10);
		}

		internal static void UnregisterMessages()
		{
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncInventoryServerRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncInventoryClientRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(ThrowExtraItemsClientRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncSelectedSlotServerRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncSelectedSlotClientRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncCrouchServerRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncCrouchClientRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncUsernameServerRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(SyncUsernameClientRpcMessage);
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(RequestSyncUsernameServerRpcMessage);
		}

		public static void SyncInventoryServerRpc(NetworkObjectReference controllerReference, NetworkObjectReference[] inventory, int[] slots)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(inventory, -1, 0);
			((FastBufferWriter)(ref val)).WriteValue<int>(slots, default(ForPrimitives));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncInventoryServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnSyncInventoryServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_0030: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			try
			{
				NetworkObjectReference controllerReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref controllerReference);
				NetworkObjectReference[] array = default(NetworkObjectReference[]);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref array);
				int[] array2 = default(int[]);
				((FastBufferReader)(ref data)).ReadValue<int>(ref array2, default(ForPrimitives));
				NetworkObject val = default(NetworkObject);
				if (!((NetworkObjectReference)(ref controllerReference)).TryGet(ref val, (NetworkManager)null) || val.OwnerClientId != senderId)
				{
					return;
				}
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.syncInventoryServerRpc was called for {1}!", "PlayerController", ((NetworkObjectReference)(ref controllerReference)).NetworkObjectId));
				PlayerControllerB component = NetworkObjectReference.op_Implicit(controllerReference).GetComponent<PlayerControllerB>();
				List<NetworkObjectReference> list = new List<NetworkObjectReference>();
				List<int> list2 = new List<int>();
				List<NetworkObjectReference> list3 = new List<NetworkObjectReference>();
				for (int i = 0; i < array2.Length; i++)
				{
					if (array2[i] < component.ItemSlots.Length)
					{
						list.Add(array[i]);
						list2.Add(array2[i]);
					}
					else
					{
						list3.Add(array[i]);
					}
				}
				SyncInventoryClientRpc(controllerReference, list.ToArray(), list2.ToArray());
				if (list3.Count > 0)
				{
					ThrowExtraItemsClientRpc(controllerReference, list3.ToArray(), new ulong[1] { senderId });
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		private static void SyncInventoryClientRpc(NetworkObjectReference controllerReference, NetworkObjectReference[] inventory, int[] slots, ulong[] targets = null)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(inventory, -1, 0);
			((FastBufferWriter)(ref val)).WriteValue<int>(slots, default(ForPrimitives));
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncInventoryClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncInventoryClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnSyncInventoryClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (senderId != 0L)
			{
				return;
			}
			try
			{
				NetworkObjectReference controllerReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref controllerReference);
				NetworkObjectReference[] array = default(NetworkObjectReference[]);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref array);
				int[] array2 = default(int[]);
				((FastBufferReader)(ref data)).ReadValue<int>(ref array2, default(ForPrimitives));
				NetworkObject val = default(NetworkObject);
				if (!((NetworkObjectReference)(ref controllerReference)).TryGet(ref val, (NetworkManager)null))
				{
					return;
				}
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.syncInventoryClientRpc was called for {1}!", "PlayerController", ((NetworkObjectReference)(ref controllerReference)).NetworkObjectId));
				PlayerControllerB component = NetworkObjectReference.op_Implicit(controllerReference).GetComponent<PlayerControllerB>();
				if (((NetworkBehaviour)component).IsOwner)
				{
					return;
				}
				component.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[component.ItemSlots.Length];
				NetworkObject val3 = default(NetworkObject);
				GrabbableObject val4 = default(GrabbableObject);
				for (int i = 0; i < array.Length; i++)
				{
					int num = array2[i];
					NetworkObjectReference val2 = array[i];
					if (num < component.ItemSlots.Length)
					{
						if (((NetworkObjectReference)(ref val2)).TryGet(ref val3, (NetworkManager)null) && ((Component)val3).TryGetComponent<GrabbableObject>(ref val4))
						{
							component.ItemSlots[num] = val4;
						}
						else
						{
							component.ItemSlots[num] = null;
						}
					}
				}
				if ((Object)(object)component.currentlyHeldObjectServer != (Object)(object)component.ItemSlots[component.currentItemSlot])
				{
					component.SwitchToItemSlot(component.currentItemSlot, (GrabbableObject)null);
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		private static void ThrowExtraItemsClientRpc(NetworkObjectReference controllerReference, NetworkObjectReference[] objectsToThrow, ulong[] targets = null)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(objectsToThrow, -1, 0);
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(ThrowExtraItemsClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(ThrowExtraItemsClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnThrowExtraItemsClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (senderId != 0L)
			{
				return;
			}
			try
			{
				NetworkObjectReference val = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref val);
				NetworkObjectReference[] array = default(NetworkObjectReference[]);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref array);
				NetworkObject val2 = default(NetworkObject);
				if (!((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null))
				{
					return;
				}
				AdditionalNetworking.Log.LogWarning((object)string.Format("{0}.throwExtraItemsClientRpc was called for {1}!", "PlayerController", ((NetworkObjectReference)(ref val)).NetworkObjectId));
				PlayerControllerB component = NetworkObjectReference.op_Implicit(val).GetComponent<PlayerControllerB>();
				if (!((NetworkBehaviour)component).IsOwner)
				{
					return;
				}
				NetworkObjectReference[] array2 = array;
				NetworkObject val4 = default(NetworkObject);
				GrabbableObject val5 = default(GrabbableObject);
				for (int i = 0; i < array2.Length; i++)
				{
					NetworkObjectReference val3 = array2[i];
					if (((NetworkObjectReference)(ref val3)).TryGet(ref val4, (NetworkManager)null) && ((Component)val4).TryGetComponent<GrabbableObject>(ref val5))
					{
						component.ThrowObjectServerRpc(val3, component.isInElevator, component.isInHangarShipRoom, ((Component)component).transform.position, (int)((Component)component).transform.eulerAngles.y);
					}
				}
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogError((object)$"Exception during networking: {arg}");
			}
		}

		public static void SyncSelectedSlotServerRpc(NetworkObjectReference controllerReference, int selectedSlot)
		{
			//IL_001d: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			((FastBufferWriter)(ref val)).WriteValue<int>(ref selectedSlot, default(ForPrimitives));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncSelectedSlotServerRpcMessage, 0uL, val

BepInEx/plugins/AdditionalNetworking.Interfaces.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using AdditionalNetworking.Preloader.Utils;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("mattymatty")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.3.3")]
[assembly: AssemblyInformationalVersion("2.3.3+5406240115193c16c96629e8177960f1d8c7ad2f")]
[assembly: AssemblyProduct("AdditionalNetworking")]
[assembly: AssemblyTitle("Interfaces For AdditionalNetworking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[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 AdditionalNetworking.Interfaces
{
	[InjectInterface("AnimatedItem", "Assembly-CSharp")]
	public interface INetworkAnimatedItem
	{
		bool AdditionalNetworking_Changed { get; set; }
	}
	[InjectInterface("BoomboxItem", "Assembly-CSharp")]
	public interface INetworkBoomboxItem
	{
		bool AdditionalNetworking_Changed { get; set; }
	}
	[InjectInterface("GrabbableObject", "Assembly-CSharp")]
	public interface INetworkGrabbableObject
	{
		bool AdditionalNetworking_IsInitialized { get; set; }

		bool AdditionalNetworking_RequestedSync { get; set; }
	}
	[InjectInterface("PlayerControllerB", "Assembly-CSharp")]
	public interface INetworkPlayerControllerB
	{
		bool AdditionalNetworking_InventoryChanged { get; set; }

		bool AdditionalNetworking_SlotChanged { get; set; }

		bool AdditionalNetworking_LastCrouchState { get; set; }
	}
	[InjectInterface("RoundManager", "Assembly-CSharp")]
	public interface INetworkRoundManager
	{
		bool AdditionalNetworking_ScrapPendingSync { get; set; }
	}
	[InjectInterface("ShotgunItem", "Assembly-CSharp")]
	public interface INetworkShotgunItem
	{
		bool AdditionalNetworking_AmmoCountChanged { get; set; }

		bool AdditionalNetworking_SafetyChanged { get; set; }
	}
	[InjectInterface("StartOfRound", "Assembly-CSharp")]
	public interface INetworkStartOfRound
	{
		bool AdditionalNetworking_ValuablesSynced { get; set; }
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "mattymatty.AdditionalNetworking";

		public const string PLUGIN_NAME = "AdditionalNetworking";

		public const string PLUGIN_VERSION = "2.3.3";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}