Decompiled source of AdditionalNetworking Experimental v2.3.0

BepInEx/patchers/AdditionalNetworking.Preloader.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
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.0")]
[assembly: AssemblyInformationalVersion("2.3.0+4b04e9bf8e6c067457f396c8118347738b28f0e8")]
[assembly: AssemblyProduct("AdditionalNetworking")]
[assembly: AssemblyTitle("AdditionalNetworking - Preloader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[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
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "mattymatty.AdditionalNetworking";

		public const string PLUGIN_NAME = "AdditionalNetworking";

		public const string PLUGIN_VERSION = "2.3.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, "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();
			}
		}

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

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


		public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" };


		public static void Patch(AssemblyDefinition assembly)
		{
			//IL_0064: 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)
			Action<bool, string> logCallback = delegate(bool fail, string message)
			{
				if (fail)
				{
					Log.LogWarning((object)message);
				}
				Log.LogInfo((object)message);
			};
			Log.LogWarning((object)("Patching " + ((AssemblyNameReference)assembly.Name).Name));
			if (((AssemblyNameReference)assembly.Name).Name == "Assembly-CSharp")
			{
				Enumerator<TypeDefinition> enumerator = assembly.MainModule.Types.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						TypeDefinition current = enumerator.Current;
						switch (((MemberReference)current).FullName)
						{
						case "GrabbableObject":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_isInitialized", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							current.AddField((FieldAttributes)1, "AdditionalNetworking_hasRequestedSync", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							break;
						case "GameNetcodeStuff.PlayerControllerB":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_dirtyInventory", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							current.AddField((FieldAttributes)1, "AdditionalNetworking_dirtySlots", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							current.AddField((FieldAttributes)1, "AdditionalNetworking_lastCrouchState", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							break;
						case "ShotgunItem":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_dirtyAmmo", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							current.AddField((FieldAttributes)1, "AdditionalNetworking_dirtySafety", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							break;
						case "BoomboxItem":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_dirtyStatus", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							break;
						case "AnimatedItem":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_dirtyStatus", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							break;
						case "StartOfRound":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_valuablesSynced", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							break;
						case "RoundManager":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_spawnedScrapPendingSync", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							break;
						case "MenuManager":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_preloaded", ((MemberReference)current).Module.ImportReference(typeof(bool)), 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()
		{
			Log.LogInfo((object)"AdditionalNetworking Prepatcher Started");
			PluginConfig.Init();
		}

		public static void Finish()
		{
			Log.LogInfo((object)"AdditionalNetworking Prepatcher Finished");
		}
	}
	public static class CecilHelper
	{
		public static bool AddField(this TypeDefinition self, FieldAttributes fieldAttributes, string name, TypeReference type, Action<bool, string> logCallback = null)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			logCallback?.Invoke(arg1: false, "Adding field '" + name + "' to " + ((MemberReference)self).FullName);
			if (Extensions.FindField(self, name) != null)
			{
				logCallback?.Invoke(arg1: true, "Field '" + name + "' already exists in " + ((MemberReference)self).FullName);
				return false;
			}
			self.Fields.Add(new FieldDefinition(name, fieldAttributes, type));
			return true;
		}

		public static bool AddGetter(this TypeDefinition self, string name, Action<bool, string> logCallback = null)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00aa: 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_00b8: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			string text = "Get" + name;
			logCallback?.Invoke(arg1: false, "Adding getter for field '" + name + "' to " + ((MemberReference)self).FullName);
			FieldDefinition val = Extensions.FindField(self, name);
			if (val == null)
			{
				logCallback?.Invoke(arg1: true, "Field '" + name + "' 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;
			}
			bool flag = false;
			MethodAttributes val2 = (MethodAttributes)0;
			if ((val.Attributes & 0x10) != 0)
			{
				val2 = (MethodAttributes)(val2 | 0x10);
				flag = true;
			}
			if ((val.Attributes & 1) != 0)
			{
				val2 = (MethodAttributes)(val2 | 1);
			}
			MethodDefinition val3 = new MethodDefinition(text, val2, ((FieldReference)val).FieldType);
			self.Methods.Add(val3);
			Extensions.InsertRange<Instruction>(val3.Body.Instructions, 0, (IEnumerable<Instruction>)new <>z__ReadOnlyArray<Instruction>((Instruction[])(object)new Instruction[3]
			{
				Instruction.Create(flag ? OpCodes.Nop : OpCodes.Ldarg_0),
				Instruction.Create(flag ? OpCodes.Ldsfld : OpCodes.Ldfld, (FieldReference)(object)val),
				Instruction.Create(OpCodes.Ret)
			}));
			return true;
		}

		public 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 = "Get" + 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;
		}
	}
}
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();
	}
}

BepInEx/plugins/AdditionalNetworking.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
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.Networking;
using AdditionalNetworking.Patches;
using AdditionalNetworking.Preloader;
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.Bindings;
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("DissonanceVoip")]
[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.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.0")]
[assembly: AssemblyInformationalVersion("2.3.0+4b04e9bf8e6c067457f396c8118347738b28f0e8")]
[assembly: AssemblyProduct("AdditionalNetworking")]
[assembly: AssemblyTitle("AdditionalNetworking - Plugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class 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.0")]
	[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.0";

		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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				FieldInfo field = typeof(MenuManager).GetField("AdditionalNetworking_preloaded", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field == null)
				{
					Log.LogFatal((object)"Error missing Preloader, Disabling mod!");
					return;
				}
				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.0 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.0";
	}
}
namespace AdditionalNetworking.Preloader
{
	public static class ExtraFields
	{
		private static readonly FieldInfo GrabbableIsInitialized = typeof(GrabbableObject).GetField("AdditionalNetworking_isInitialized", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<GrabbableObject, bool> _getterGrabbableIsInitialized;

		private static Func<GrabbableObject, bool, bool> _setterGrabbableIsInitialized;

		private static readonly FieldInfo GrabbableHasRequestedSync = typeof(GrabbableObject).GetField("AdditionalNetworking_hasRequestedSync", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<GrabbableObject, bool> _getterGrabbableHasRequestedSync;

		private static Func<GrabbableObject, bool, bool> _setterGrabbableHasRequestedSync;

		private static readonly FieldInfo PlayerControllerBDirtySlots = typeof(PlayerControllerB).GetField("AdditionalNetworking_dirtySlots", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<PlayerControllerB, bool> _getterPlayerControllerBDirtySlots;

		private static Func<PlayerControllerB, bool, bool> _setterPlayerControllerBDirtySlots;

		private static readonly FieldInfo PlayerControllerBDirtyInventory = typeof(PlayerControllerB).GetField("AdditionalNetworking_dirtyInventory", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<PlayerControllerB, bool> _getterPlayerControllerBDirtyInventory;

		private static Func<PlayerControllerB, bool, bool> _setterPlayerControllerBDirtyInventory;

		private static readonly FieldInfo PlayerControllerBLastCrouchState = typeof(PlayerControllerB).GetField("AdditionalNetworking_lastCrouchState", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<PlayerControllerB, bool> _getterPlayerControllerBLastCrouchState;

		private static Func<PlayerControllerB, bool, bool> _setterPlayerControllerBLastCrouchState;

		private static readonly FieldInfo RoundManagerSpawnedScrapPendingSync = typeof(RoundManager).GetField("AdditionalNetworking_spawnedScrapPendingSync", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<RoundManager, bool> _getterRoundManagerSpawnedScrapPendingSync;

		private static Func<RoundManager, bool, bool> _setterRoundManagerSpawnedScrapPendingSync;

		private static readonly FieldInfo StartOfRoundValuablesSynced = typeof(StartOfRound).GetField("AdditionalNetworking_valuablesSynced", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<StartOfRound, bool> _getterStartOfRoundValuablesSynced;

		private static Func<StartOfRound, bool, bool> _setterStartOfRoundValuablesSynced;

		private static readonly FieldInfo ShotgunItemDirtyAmmo = typeof(ShotgunItem).GetField("AdditionalNetworking_dirtyAmmo", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<ShotgunItem, bool> _getterShotgunItemDirtyAmmo;

		private static Func<ShotgunItem, bool, bool> _setterShotgunItemDirtyAmmo;

		private static readonly FieldInfo ShotgunItemDirtySafety = typeof(ShotgunItem).GetField("AdditionalNetworking_dirtySafety", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<ShotgunItem, bool> _getterShotgunItemDirtySafety;

		private static Func<ShotgunItem, bool, bool> _setterShotgunItemDirtySafety;

		private static readonly FieldInfo BoomboxItemDirtyStatus = typeof(BoomboxItem).GetField("AdditionalNetworking_dirtyStatus", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<BoomboxItem, bool> _getterBoomboxItemDirtyStatus;

		private static Func<BoomboxItem, bool, bool> _setterBoomboxItemDirtyStatus;

		private static readonly FieldInfo AnimatedItemDirtyStatus = typeof(AnimatedItem).GetField("AdditionalNetworking_dirtyStatus", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Func<AnimatedItem, bool> _getterAnimatedItemDirtyStatus;

		private static Func<AnimatedItem, bool, bool> _setterAnimatedItemDirtyStatus;

		public static bool GetIsInitialized(this GrabbableObject @this)
		{
			if (_getterGrabbableIsInitialized == null)
			{
				_getterGrabbableIsInitialized = (Func<GrabbableObject, bool>)GrabbableIsInitialized.FastGetter();
			}
			return _getterGrabbableIsInitialized(@this);
		}

		public static bool SetIsInitialized(this GrabbableObject @this, in bool value)
		{
			if (_setterGrabbableIsInitialized == null)
			{
				_setterGrabbableIsInitialized = (Func<GrabbableObject, bool, bool>)GrabbableIsInitialized.FastSetter();
			}
			return _setterGrabbableIsInitialized(@this, value);
		}

		public static bool GetHasRequestedSync(this GrabbableObject @this)
		{
			if (_getterGrabbableHasRequestedSync == null)
			{
				_getterGrabbableHasRequestedSync = (Func<GrabbableObject, bool>)GrabbableHasRequestedSync.FastGetter();
			}
			return _getterGrabbableHasRequestedSync(@this);
		}

		public static bool SetHasRequestedSync(this GrabbableObject @this, in bool value)
		{
			if (_setterGrabbableHasRequestedSync == null)
			{
				_setterGrabbableHasRequestedSync = (Func<GrabbableObject, bool, bool>)GrabbableHasRequestedSync.FastSetter();
			}
			return _setterGrabbableHasRequestedSync(@this, value);
		}

		public static bool GetDirtySlots(this PlayerControllerB @this)
		{
			if (_getterPlayerControllerBDirtySlots == null)
			{
				_getterPlayerControllerBDirtySlots = (Func<PlayerControllerB, bool>)PlayerControllerBDirtySlots.FastGetter();
			}
			return _getterPlayerControllerBDirtySlots(@this);
		}

		public static bool SetDirtySlots(this PlayerControllerB @this, in bool value)
		{
			if (_setterPlayerControllerBDirtySlots == null)
			{
				_setterPlayerControllerBDirtySlots = (Func<PlayerControllerB, bool, bool>)PlayerControllerBDirtySlots.FastSetter();
			}
			return _setterPlayerControllerBDirtySlots(@this, value);
		}

		public static bool GetDirtyInventory(this PlayerControllerB @this)
		{
			if (_getterPlayerControllerBDirtyInventory == null)
			{
				_getterPlayerControllerBDirtyInventory = (Func<PlayerControllerB, bool>)PlayerControllerBDirtyInventory.FastGetter();
			}
			return _getterPlayerControllerBDirtyInventory(@this);
		}

		public static bool SetDirtyInventory(this PlayerControllerB @this, in bool value)
		{
			if (_setterPlayerControllerBDirtyInventory == null)
			{
				_setterPlayerControllerBDirtyInventory = (Func<PlayerControllerB, bool, bool>)PlayerControllerBDirtyInventory.FastSetter();
			}
			return _setterPlayerControllerBDirtyInventory(@this, value);
		}

		public static bool GetLastCrouchState(this PlayerControllerB @this)
		{
			if (_getterPlayerControllerBLastCrouchState == null)
			{
				_getterPlayerControllerBLastCrouchState = (Func<PlayerControllerB, bool>)PlayerControllerBLastCrouchState.FastGetter();
			}
			return _getterPlayerControllerBLastCrouchState(@this);
		}

		public static bool SetLastCrouchState(this PlayerControllerB @this, in bool value)
		{
			if (_setterPlayerControllerBLastCrouchState == null)
			{
				_setterPlayerControllerBLastCrouchState = (Func<PlayerControllerB, bool, bool>)PlayerControllerBLastCrouchState.FastSetter();
			}
			return _setterPlayerControllerBLastCrouchState(@this, value);
		}

		public static bool GetSpawnedScrapPendingSync(this RoundManager @this)
		{
			if (_getterRoundManagerSpawnedScrapPendingSync == null)
			{
				_getterRoundManagerSpawnedScrapPendingSync = (Func<RoundManager, bool>)RoundManagerSpawnedScrapPendingSync.FastGetter();
			}
			return _getterRoundManagerSpawnedScrapPendingSync(@this);
		}

		public static bool SetSpawnedScrapPendingSync(this RoundManager @this, in bool value)
		{
			if (_setterRoundManagerSpawnedScrapPendingSync == null)
			{
				_setterRoundManagerSpawnedScrapPendingSync = (Func<RoundManager, bool, bool>)RoundManagerSpawnedScrapPendingSync.FastSetter();
			}
			return _setterRoundManagerSpawnedScrapPendingSync(@this, value);
		}

		public static bool GetValuablesSynced(this StartOfRound @this)
		{
			if (_getterStartOfRoundValuablesSynced == null)
			{
				_getterStartOfRoundValuablesSynced = (Func<StartOfRound, bool>)StartOfRoundValuablesSynced.FastGetter();
			}
			return _getterStartOfRoundValuablesSynced(@this);
		}

		public static bool SetValuablesSynced(this StartOfRound @this, in bool value)
		{
			if (_setterStartOfRoundValuablesSynced == null)
			{
				_setterStartOfRoundValuablesSynced = (Func<StartOfRound, bool, bool>)StartOfRoundValuablesSynced.FastSetter();
			}
			return _setterStartOfRoundValuablesSynced(@this, value);
		}

		public static bool GetDirtyAmmo(this ShotgunItem @this)
		{
			if (_getterShotgunItemDirtyAmmo == null)
			{
				_getterShotgunItemDirtyAmmo = (Func<ShotgunItem, bool>)ShotgunItemDirtyAmmo.FastGetter();
			}
			return _getterShotgunItemDirtyAmmo(@this);
		}

		public static bool SetDirtyAmmo(this ShotgunItem @this, in bool value)
		{
			if (_setterShotgunItemDirtyAmmo == null)
			{
				_setterShotgunItemDirtyAmmo = (Func<ShotgunItem, bool, bool>)ShotgunItemDirtyAmmo.FastSetter();
			}
			return _setterShotgunItemDirtyAmmo(@this, value);
		}

		public static bool GetDirtySafety(this ShotgunItem @this)
		{
			if (_getterShotgunItemDirtySafety == null)
			{
				_getterShotgunItemDirtySafety = (Func<ShotgunItem, bool>)ShotgunItemDirtySafety.FastGetter();
			}
			return _getterShotgunItemDirtySafety(@this);
		}

		public static bool SetDirtySafety(this ShotgunItem @this, in bool value)
		{
			if (_setterShotgunItemDirtySafety == null)
			{
				_setterShotgunItemDirtySafety = (Func<ShotgunItem, bool, bool>)ShotgunItemDirtySafety.FastSetter();
			}
			return _setterShotgunItemDirtySafety(@this, value);
		}

		public static bool GetDirtyStatus(this BoomboxItem @this)
		{
			if (_getterBoomboxItemDirtyStatus == null)
			{
				_getterBoomboxItemDirtyStatus = (Func<BoomboxItem, bool>)BoomboxItemDirtyStatus.FastGetter();
			}
			return _getterBoomboxItemDirtyStatus(@this);
		}

		public static bool SetDirtyStatus(this BoomboxItem @this, in bool value)
		{
			if (_setterBoomboxItemDirtyStatus == null)
			{
				_setterBoomboxItemDirtyStatus = (Func<BoomboxItem, bool, bool>)BoomboxItemDirtyStatus.FastSetter();
			}
			return _setterBoomboxItemDirtyStatus(@this, value);
		}

		public static bool GetDirtyStatus(this AnimatedItem @this)
		{
			if (_getterAnimatedItemDirtyStatus == null)
			{
				_getterAnimatedItemDirtyStatus = (Func<AnimatedItem, bool>)AnimatedItemDirtyStatus.FastGetter();
			}
			return _getterAnimatedItemDirtyStatus(@this);
		}

		public static bool SetDirtyStatus(this AnimatedItem @this, in bool value)
		{
			if (_setterAnimatedItemDirtyStatus == null)
			{
				_setterAnimatedItemDirtyStatus = (Func<AnimatedItem, bool, bool>)AnimatedItemDirtyStatus.FastSetter();
			}
			return _setterAnimatedItemDirtyStatus(@this, value);
		}
	}
}
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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				bool value = true;
				__instance.SetSpawnedScrapPendingSync(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(RoundManager), "SyncScrapValuesClientRpc")]
		private static void AfterScrapValueSync(RoundManager __instance)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				bool value = false;
				__instance.SetSpawnedScrapPendingSync(in value);
			}
		}
	}
	[HarmonyPatch]
	internal class StartOfRoundPatch
	{
		[HarmonyFinalizer]
		[HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")]
		private static void AfterUnlockablesClientSync(StartOfRound __instance)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !AdditionalNetworking.PluginConfig.Value.ShouldSkipGrabbableSync)
			{
				bool value = true;
				__instance.SetValuablesSynced(in value);
			}
		}

		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", 83));
			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", 106), 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", 132));
			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_0094: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.Value.Enabled.Value || !__instance.itemProperties.isScrap || __instance.GetIsInitialized() || __instance.GetHasRequestedSync() || (StartOfRound.Instance.inShipPhase && !StartOfRound.Instance.GetValuablesSynced()) || RoundManager.Instance.GetSpawnedScrapPendingSync())
			{
				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));
				bool value = true;
				__instance.SetHasRequestedSync(in value);
			}
			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)
		{
			bool value = true;
			__instance.SetIsInitialized(in value);
		}
	}
}
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)
		{
			if (AdditionalNetworking.PluginConfig.ItemState.Animated.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				bool value = true;
				__instance.SetDirtyStatus(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void OnLateUpdate(GrabbableObject __instance)
		{
			//IL_0083: 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 || !val.GetDirtyStatus())
			{
				return;
			}
			bool value = false;
			val.SetDirtyStatus(in value);
			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_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.ItemState.Boombox.Value || ((NetworkBehaviour)StartOfRound.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)
		{
			if (AdditionalNetworking.PluginConfig.ItemState.Boombox.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				bool value = true;
				__instance.SetDirtyStatus(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void OnLateUpdate(GrabbableObject __instance)
		{
			//IL_008e: 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 || !val.GetDirtyStatus())
			{
				return;
			}
			bool value = false;
			val.SetDirtyStatus(in value);
			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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening || (int)((NetworkBehaviour)__instance).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || !((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_0036: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.GetLastCrouchState() == __instance.isCrouching)
			{
				return;
			}
			__instance.SetLastCrouchState(in __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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (networkManager != null && networkManager.IsListening && (int)((NetworkBehaviour)__instance).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkBehaviour)__instance).OwnerClientId != networkManager.LocalClientId)
			{
				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_005b: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value || ((NetworkBehaviour)StartOfRound.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)
		{
			if (AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value && !start && ((NetworkBehaviour)__instance).IsOwner)
			{
				bool value = true;
				__instance.SetDirtyAmmo(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(ShotgunItem), "ShootGun")]
		private static void OnShot(ShotgunItem __instance)
		{
			if (AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				bool value = true;
				__instance.SetDirtyAmmo(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(ShotgunItem), "ItemInteractLeftRight")]
		private static void OnSafetyToggle(ShotgunItem __instance, bool right)
		{
			if (AdditionalNetworking.PluginConfig.ItemState.Shotgun.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				bool value = true;
				__instance.SetDirtySafety(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void OnLateUpdate(GrabbableObject __instance)
		{
			//IL_00d1: 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)
			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;
			}
			bool value;
			if (val.GetDirtyAmmo())
			{
				value = false;
				val.SetDirtyAmmo(in value);
				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 (!val.GetDirtySafety())
			{
				return;
			}
			value = false;
			val.SetDirtySafety(in value);
			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)
		{
			if (AdditionalNetworking.PluginConfig.Inventory.SlotChange.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				bool value = true;
				__instance.SetDirtySlots(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")]
		private static void OnItemGrabbed(PlayerControllerB __instance, bool grabValidated)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && AdditionalNetworking.PluginConfig.Inventory.InventoryChange.Value && ((NetworkBehaviour)__instance).IsOwner && grabValidated)
			{
				bool value = true;
				__instance.SetDirtyInventory(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
		private static void OnDiscardItem(PlayerControllerB __instance)
		{
			if (AdditionalNetworking.PluginConfig.Inventory.InventoryChange.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				bool value = true;
				__instance.SetDirtyInventory(in value);
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "DropAllHeldItems")]
		private static void OnDropItem(PlayerControllerB __instance)
		{
			if (AdditionalNetworking.PluginConfig.Inventory.InventoryChange.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				bool value = true;
				__instance.SetDirtyInventory(in value);
			}
		}

		[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_0021: 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)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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)
			bool value;
			if (__instance.GetDirtySlots())
			{
				value = false;
				__instance.SetDirtySlots(in value);
				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 (!__instance.GetDirtyInventory())
			{
				return;
			}
			value = false;
			__instance.SetDirtySlots(in value);
			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)
			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);
					GrabbableObject @this = grabbableObject;
					bool value = false;
					@this.SetHasRequestedSync(in value);
				}
			}
			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)
		{
			if (grabbableObject.itemProperties.saveItemVariable)
			{
				grabbableObject.LoadItemSaveData(dataValue);
			}
			if (grabbableObject.itemProperties.isScrap)
			{
				if (AdditionalNetworking.PluginConfig.Value.IgnoreScanNodesList.Contains(itemTag))
				{
					grabbableObject.scrapValue = scrapValue;
					GrabbableObject @this = grabbableObject;
					bool value = true;
					@this.SetIsInitialized(in value);
				}
				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)
		{
			if (senderId != 0L)
			{
				return;
			}
			try
			{
				AdditionalNetworking.VerboseLog((LogLevel)32, () => "GrabbableObject.MarkValuablesSyncedClientRpc was called!");
				StartOfRound instance = StartOfRound.Instance;
				bool value = true;
				instance.SetValuablesSynced(in value);
			}
			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;
				}
				AdditionalNet