Decompiled source of AdditionalNetworking v2.1.2

BepInEx/patchers/AdditionalNetworking_Preloader.dll

Decompiled 2 months 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.Runtime.Versioning;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("AdditionalNetworking_Preloader")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.1.0")]
[assembly: AssemblyInformationalVersion("2.1.1+c083797e0d439c859f4b8751458ade87ad41f995")]
[assembly: AssemblyProduct("Additional Networking")]
[assembly: AssemblyTitle("AdditionalNetworking_Preloader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AdditionalNetworking_Preloader
{
	internal class AdditionalNetworking
	{
		public static class PluginConfig
		{
			internal static ConfigEntry<bool> Enabled;

			internal static ConfigEntry<string> OutputPath;

			internal static ConfigEntry<string> OutputExtension;

			public static void Init()
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				ConfigFile val = new ConfigFile(Utility.CombinePaths(new string[2] { MainDir, "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 "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);
							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 "StartOfRound":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_unlockablesSynced", ((MemberReference)current).Module.ImportReference(typeof(bool)), logCallback);
							break;
						case "RoundManager":
							current.AddField((FieldAttributes)1, "AdditionalNetworking_spawnedScrapPendingSync", ((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)
		{
		}
	}
}
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 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AdditionalNetworking.Dependency;
using AdditionalNetworking.Networking;
using AsyncLoggers.DBAPI;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("AdditionalNetworking")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.2.0")]
[assembly: AssemblyInformationalVersion("2.1.2+c083797e0d439c859f4b8751458ade87ad41f995")]
[assembly: AssemblyProduct("Additional Networking")]
[assembly: AssemblyTitle("AdditionalNetworking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.2.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
{
	[BepInPlugin("mattymatty.AdditionalNetworking", "AdditionalNetworking", "2.1.2")]
	[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 State
			{
				internal static ConfigEntry<bool> Shotgun;

				internal static ConfigEntry<bool> Boombox;
			}

			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;
				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");
				State.Shotgun = config.Bind<bool>("Item state", "Shotgun", true, "use explicit values for ammo/safety instead of toggle states");
				State.Boombox = config.Bind<bool>("Item state", "Boombox", true, "sync state and track id");
				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");
				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();
			}
		}

		public const string GUID = "mattymatty.AdditionalNetworking";

		public const string NAME = "AdditionalNetworking";

		public const string VERSION = "2.1.2";

		internal static ManualLogSource Log;

		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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				if (LobbyCompatibilityChecker.Enabled)
				{
					LobbyCompatibilityChecker.Init();
				}
				if (AsyncLoggerProxy.Enabled)
				{
					AsyncLoggerProxy.WriteEvent("AdditionalNetworking", "Awake", "Initializing");
				}
				Log.LogInfo((object)"Initializing Configs");
				PluginConfig.Init((BaseUnityPlugin)(object)this);
				Log.LogInfo((object)"Patching Methods");
				Harmony val = new Harmony("mattymatty.AdditionalNetworking");
				val.PatchAll();
				Log.LogInfo((object)"AdditionalNetworking v2.1.2 Loaded!");
				if (AsyncLoggerProxy.Enabled)
				{
					AsyncLoggerProxy.WriteEvent("AdditionalNetworking", "Awake", "Finished Initializing");
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Exception while initializing: \n" + ex));
			}
		}
	}
}
namespace AdditionalNetworking.Patches
{
	[HarmonyPatch]
	internal class NetworkManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(NetworkManager), "Initialize")]
		private static void AfterInitialize()
		{
			AdditionalNetworking.Log.LogInfo((object)"Registering CustomMessages!");
			PlayerControllerB.RegisterMessages();
			GrabbableObject.RegisterMessages();
			Shotgun.RegisterMessages();
			Boombox.RegisterMessages();
		}
	}
	[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))
			{
				__instance.AdditionalNetworking_spawnedScrapPendingSync = true;
			}
		}

		[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))
			{
				__instance.AdditionalNetworking_spawnedScrapPendingSync = false;
			}
		}
	}
	[HarmonyPatch]
	internal class StartOfRoundPatch
	{
		[HarmonyFinalizer]
		[HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")]
		private static void AfterUnlockablesSync(StartOfRound __instance)
		{
			__instance.AdditionalNetworking_unlockablesSynced = true;
		}
	}
}
namespace AdditionalNetworking.Patches.State
{
	[HarmonyPatch]
	internal class BoomboxItemPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(BoomboxItem), "Start")]
		private static void OnStart(BoomboxItem __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.State.Boombox.Value && !((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				Boombox.RequestSyncServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(BoomboxItem), "StartMusic")]
		private static void OnMusicChange(BoomboxItem __instance)
		{
			if (AdditionalNetworking.PluginConfig.State.Boombox.Value && ((NetworkBehaviour)__instance).IsOwner)
			{
				__instance.AdditionalNetworking_dirtyStatus = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void OnLateUpdate(GrabbableObject __instance)
		{
			//IL_0084: 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)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				AdditionalNetworking.Log.LogFatal((object)$"{__instance.itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}) is not spawned! nobody else in the network knows about it!");
			}
			else
			{
				if (!val.AdditionalNetworking_dirtyStatus)
				{
					return;
				}
				val.AdditionalNetworking_dirtyStatus = false;
				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)
					{
						AdditionalNetworking.Log.LogFatal((object)$"Exception syncing boombox state of {__instance.itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
					}
				}
			}
		}
	}
	[HarmonyPatch]
	internal class GrabbableObjectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void CheckScrapHasValue(GrabbableObject __instance)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.itemProperties.isScrap || __instance.AdditionalNetworking_isInitialized || __instance.AdditionalNetworking_hasRequestedSync || (StartOfRound.Instance.inShipPhase && !StartOfRound.Instance.AdditionalNetworking_unlockablesSynced) || RoundManager.Instance.AdditionalNetworking_spawnedScrapPendingSync)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				AdditionalNetworking.Log.LogFatal((object)$"{__instance.itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			try
			{
				GrabbableObject.RequestSyncServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
				__instance.AdditionalNetworking_hasRequestedSync = true;
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception syncing value of {__instance.itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")]
		[HarmonyPatch(typeof(GrabbableObject), "LoadItemSaveData")]
		private static void OnInitialize(GrabbableObject __instance)
		{
			__instance.AdditionalNetworking_isInitialized = true;
		}
	}
	[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_00d4: 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.State.Shotgun.Value)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				AdditionalNetworking.Log.LogFatal((object)$"{((Object)((NetworkBehaviour)__instance).NetworkObject).name}({((NetworkBehaviour)__instance).NetworkObjectId}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			if (!((NetworkBehaviour)__instance.gun).NetworkObject.IsSpawned)
			{
				AdditionalNetworking.Log.LogFatal((object)$"{((GrabbableObject)__instance.gun).itemProperties.itemName}({((NetworkBehaviour)__instance.gun).NetworkObjectId}) 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)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception syncing ammo of {((GrabbableObject)__instance.gun).itemProperties.itemName}({((NetworkBehaviour)__instance.gun).NetworkObjectId}):\n{arg}");
			}
		}
	}
	[HarmonyPatch]
	internal class ShotgunItemPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShotgunItem), "Start")]
		private static void OnStart(ShotgunItem __instance)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (!AdditionalNetworking.PluginConfig.State.Shotgun.Value || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				AdditionalNetworking.Log.LogFatal((object)$"{((GrabbableObject)__instance).itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			try
			{
				Shotgun.RequestSyncServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception syncing status of {((GrabbableObject)__instance).itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(ShotgunItem), "ReloadGunEffectsServerRpc")]
		private static void OnAmmoReload(ShotgunItem __instance, bool start)
		{
			if (AdditionalNetworking.PluginConfig.State.Shotgun.Value && !start && ((NetworkBehaviour)__instance).IsOwner)
			{
				__instance.AdditionalNetworking_dirtyAmmo = true;
			}
		}

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

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

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		private static void OnLateUpdate(GrabbableObject __instance)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			ShotgunItem val = (ShotgunItem)(object)((__instance is ShotgunItem) ? __instance : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				AdditionalNetworking.Log.LogFatal((object)$"{__instance.itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}) is not spawned! nobody else in the network knows about it!");
				return;
			}
			if (val.AdditionalNetworking_dirtyAmmo)
			{
				val.AdditionalNetworking_dirtyAmmo = false;
				if (!((NetworkBehaviour)__instance).IsOwner)
				{
					return;
				}
				try
				{
					Shotgun.SyncAmmoServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), val.shellsLoaded);
				}
				catch (Exception arg)
				{
					AdditionalNetworking.Log.LogFatal((object)$"Exception syncing ammo of {__instance.itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
				}
			}
			if (!val.AdditionalNetworking_dirtySafety)
			{
				return;
			}
			val.AdditionalNetworking_dirtySafety = false;
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			try
			{
				Shotgun.SyncSafetyServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), val.safetyOn);
			}
			catch (Exception arg2)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception syncing safety of {__instance.itemProperties.itemName}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg2}");
			}
		}
	}
}
namespace AdditionalNetworking.Patches.Inventory
{
	[HarmonyPatch]
	internal class PlayerControllerBPatch
	{
		internal static readonly Dictionary<PlayerControllerB, bool> DirtySlots = new Dictionary<PlayerControllerB, bool>();

		internal static readonly Dictionary<PlayerControllerB, bool> DirtyInventory = new Dictionary<PlayerControllerB, bool>();

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		private static void OnStart(PlayerControllerB __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (AdditionalNetworking.PluginConfig.Misc.Username.Value && !((NetworkBehaviour)__instance).IsServer)
			{
				PlayerControllerB.RequestSyncUsernameServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")]
		private static void OnSlotChange(PlayerControllerB __instance, int slot)
		{
			if (AdditionalNetworking.PluginConfig.Inventory.SlotChange.Value)
			{
				DirtySlots[__instance] = true;
			}
		}

		[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 && grabValidated)
			{
				DirtyInventory[__instance] = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
		private static void OnDiscardItem(PlayerControllerB __instance)
		{
			if (AdditionalNetworking.PluginConfig.Inventory.InventoryChange.Value)
			{
				DirtyInventory[__instance] = true;
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "DropAllHeldItems")]
		private static void OnDropItem(PlayerControllerB __instance)
		{
			if (AdditionalNetworking.PluginConfig.Inventory.InventoryChange.Value)
			{
				DirtyInventory[__instance] = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		private static void OnPlayerConnected(PlayerControllerB __instance)
		{
			//IL_0023: 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
			{
				PlayerControllerB.SyncUsernameServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), __instance.playerUsername);
			}
			catch (Exception arg)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception syncing name of {__instance.playerUsername}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		private static void OnLateUpdate(PlayerControllerB __instance)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (DirtySlots.TryGetValue(__instance, out var value) && value)
			{
				DirtySlots[__instance] = false;
				if (((NetworkBehaviour)__instance).IsOwner)
				{
					try
					{
						PlayerControllerB.SyncSelectedSlotServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), __instance.currentItemSlot);
					}
					catch (Exception arg)
					{
						AdditionalNetworking.Log.LogFatal((object)$"Exception syncing slots of {__instance.playerUsername}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg}");
					}
				}
			}
			if (!(DirtyInventory.TryGetValue(__instance, out var value2) && value2))
			{
				return;
			}
			DirtyInventory[__instance] = false;
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			List<NetworkObjectReference> list = new List<NetworkObjectReference>();
			List<int> list2 = new List<int>();
			for (int i = 0; i < __instance.ItemSlots.Length; i++)
			{
				GrabbableObject val = __instance.ItemSlots[i];
				if ((Object)(object)val != (Object)null && (Object)(object)((NetworkBehaviour)val).NetworkObject != (Object)null)
				{
					if (!((NetworkBehaviour)val).NetworkObject.IsSpawned)
					{
						AdditionalNetworking.Log.LogFatal((object)$"{val.itemProperties.itemName}({((NetworkBehaviour)val).NetworkObjectId}) is not spawned! nobody else in the network knows about it!");
						return;
					}
					list.Add(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject));
					list2.Add(i);
				}
			}
			try
			{
				PlayerControllerB.SyncInventoryServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), list.ToArray(), list2.ToArray());
			}
			catch (Exception arg2)
			{
				AdditionalNetworking.Log.LogFatal((object)$"Exception syncing inventory of {__instance.playerUsername}({((NetworkBehaviour)__instance).NetworkObjectId}):\n{arg2}");
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PlayerControllerB), "OnDestroy")]
		private static void OnDestroy(PlayerControllerB __instance)
		{
			DirtyInventory.Remove(__instance);
			DirtySlots.Remove(__instance);
		}
	}
}
namespace AdditionalNetworking.Networking
{
	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);
		}

		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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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;
			}
			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);
			}
		}

		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_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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			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)
			{
				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();
			}
		}

		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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			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 });
			}
		}
	}
	public static class GrabbableObject
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnSyncValuesClientRpc;

			public static HandleNamedMessageDelegate <1>__OnRequestSyncServerRpc;
		}

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

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

		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
			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);
		}

		private static void SyncValuesClientRpc(NetworkObjectReference grabbableReference, int scrapValue, int dataValue, 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 grabbableReference);
			((FastBufferWriter)(ref val)).WriteValue<int>(ref scrapValue, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValue<int>(ref dataValue, default(ForPrimitives));
			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_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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			NetworkObjectReference grabbableReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref grabbableReference);
			int scrapValue = default(int);
			((FastBufferReader)(ref data)).ReadValue<int>(ref scrapValue, default(ForPrimitives));
			int dataValue = default(int);
			((FastBufferReader)(ref data)).ReadValue<int>(ref dataValue, default(ForPrimitives));
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref grabbableReference)).TryGet(ref val, (NetworkManager)null) && senderId == 0L)
			{
				GrabbableObject component = NetworkObjectReference.op_Implicit(grabbableReference).GetComponent<GrabbableObject>();
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncValuesClientRpc was called for {1}! scrap: {2}, data: {3}", "GrabbableObject", ((NetworkObjectReference)(ref grabbableReference)).NetworkObjectId, scrapValue, dataValue));
				if (component.itemProperties.saveItemVariable)
				{
					component.LoadItemSaveData(dataValue);
				}
				component.SetScrapValue(scrapValue);
				component.AdditionalNetworking_hasRequestedSync = false;
			}
		}

		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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			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>();
				SyncValuesClientRpc(grabbableReference, component.scrapValue, component.itemProperties.saveItemVariable ? component.GetItemDataToSave() : 0, new ulong[1] { senderId });
			}
		}
	}
	public static class PlayerControllerB
	{
		[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>__OnSyncUsernameServerRpc;

			public static HandleNamedMessageDelegate <6>__OnSyncUsernameClientRpc;

			public static HandleNamedMessageDelegate <7>__OnRequestSyncUsernameServerRpc;
		}

		private static readonly string BaseName = typeof(PlayerControllerB).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 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
			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 syncUsernameServerRpcMessage = SyncUsernameServerRpcMessage;
			object obj6 = <>O.<5>__OnSyncUsernameServerRpc;
			if (obj6 == null)
			{
				HandleNamedMessageDelegate val6 = OnSyncUsernameServerRpc;
				<>O.<5>__OnSyncUsernameServerRpc = val6;
				obj6 = (object)val6;
			}
			customMessagingManager6.RegisterNamedMessageHandler(syncUsernameServerRpcMessage, (HandleNamedMessageDelegate)obj6);
			CustomMessagingManager customMessagingManager7 = NetworkManager.Singleton.CustomMessagingManager;
			string syncUsernameClientRpcMessage = SyncUsernameClientRpcMessage;
			object obj7 = <>O.<6>__OnSyncUsernameClientRpc;
			if (obj7 == null)
			{
				HandleNamedMessageDelegate val7 = OnSyncUsernameClientRpc;
				<>O.<6>__OnSyncUsernameClientRpc = val7;
				obj7 = (object)val7;
			}
			customMessagingManager7.RegisterNamedMessageHandler(syncUsernameClientRpcMessage, (HandleNamedMessageDelegate)obj7);
			CustomMessagingManager customMessagingManager8 = NetworkManager.Singleton.CustomMessagingManager;
			string requestSyncUsernameServerRpcMessage = RequestSyncUsernameServerRpcMessage;
			object obj8 = <>O.<7>__OnRequestSyncUsernameServerRpc;
			if (obj8 == null)
			{
				HandleNamedMessageDelegate val8 = OnRequestSyncUsernameServerRpc;
				<>O.<7>__OnRequestSyncUsernameServerRpc = val8;
				obj8 = (object)val8;
			}
			customMessagingManager8.RegisterNamedMessageHandler(requestSyncUsernameServerRpcMessage, (HandleNamedMessageDelegate)obj8);
		}

		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_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_006a: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			NetworkObjectReference controllerReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			NetworkObjectReference[] array = default(NetworkObjectReference[]);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref array);
			int[] array2 = default(int[]);
			((FastBufferReader)(ref data)).ReadValue<int>(ref array2, default(ForPrimitives));
			NetworkObject val = default(NetworkObject);
			if (!((NetworkObjectReference)(ref controllerReference)).TryGet(ref val, (NetworkManager)null) || val.OwnerClientId != senderId)
			{
				return;
			}
			AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.syncInventoryServerRpc was called for {1}!", "PlayerControllerB", ((NetworkObjectReference)(ref controllerReference)).NetworkObjectId));
			PlayerControllerB component = NetworkObjectReference.op_Implicit(controllerReference).GetComponent<PlayerControllerB>();
			List<NetworkObjectReference> list = new List<NetworkObjectReference>();
			List<int> list2 = new List<int>();
			List<NetworkObjectReference> list3 = new List<NetworkObjectReference>();
			for (int i = 0; i < array2.Length; i++)
			{
				if (array2[i] < component.ItemSlots.Length)
				{
					list.Add(array[i]);
					list2.Add(array2[i]);
				}
				else
				{
					list3.Add(array[i]);
				}
			}
			SyncInventoryClientRpc(controllerReference, list.ToArray(), list2.ToArray());
			if (list3.Count > 0)
			{
				ThrowExtraItemsClientRpc(controllerReference, list3.ToArray(), new ulong[1] { senderId });
			}
		}

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

		private static void OnSyncInventoryClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_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_0057: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			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) || senderId != 0L)
			{
				return;
			}
			AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.syncInventoryClientRpc was called for {1}!", "PlayerControllerB", ((NetworkObjectReference)(ref controllerReference)).NetworkObjectId));
			PlayerControllerB component = NetworkObjectReference.op_Implicit(controllerReference).GetComponent<PlayerControllerB>();
			if (((NetworkBehaviour)component).IsOwner)
			{
				return;
			}
			component.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[component.ItemSlots.Length];
			NetworkObject val3 = default(NetworkObject);
			GrabbableObject val4 = default(GrabbableObject);
			for (int i = 0; i < array.Length; i++)
			{
				int num = array2[i];
				NetworkObjectReference val2 = array[i];
				if (num < component.ItemSlots.Length)
				{
					if (((NetworkObjectReference)(ref val2)).TryGet(ref val3, (NetworkManager)null) && ((Component)val3).TryGetComponent<GrabbableObject>(ref val4))
					{
						component.ItemSlots[num] = val4;
					}
					else
					{
						component.ItemSlots[num] = null;
					}
				}
			}
			component.SwitchToItemSlot(component.currentItemSlot, (GrabbableObject)null);
		}

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

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

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

		private static void OnSyncSelectedSlotServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			NetworkObjectReference controllerReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			int selectedSlot = default(int);
			((FastBufferReader)(ref data)).ReadValue<int>(ref selectedSlot, default(ForPrimitives));
			NetworkObject val = default(NetworkObject);
			if (!((NetworkObjectReference)(ref controllerReference)).TryGet(ref val, (NetworkManager)null) || val.OwnerClientId != senderId)
			{
				return;
			}
			PlayerControllerB component = NetworkObjectReference.op_Implicit(controllerReference).GetComponent<PlayerControllerB>();
			if (selectedSlot < 0 || selectedSlot >= component.ItemSlots.Length)
			{
				AdditionalNetworking.Log.LogWarning((object)string.Format("Invalid {0}.syncSelectedSlotServerRpc was called for {1}, Ignored! slot:{2}", "PlayerControllerB", ((NetworkObjectReference)(ref controllerReference)).NetworkObjectId, selectedSlot));
				return;
			}
			AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.syncSelectedSlotServerRpc was called for {1}! slot:{2}", "PlayerControllerB", ((NetworkObjectReference)(ref controllerReference)).NetworkObjectId, selectedSlot));
			SyncSelectedSlotClientRpc(controllerReference, selectedSlot);
		}

		private static void SyncSelectedSlotClientRpc(NetworkObjectReference controllerReference, int selectedSlot, 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 controllerReference);
			((FastBufferWriter)(ref val)).WriteValue<int>(ref selectedSlot, default(ForPrimitives));
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncSelectedSlotClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncSelectedSlotClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnSyncSelectedSlotClientRpc(ulong senderId, FastBufferReader data)
		{
			//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_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkObjectReference controllerReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			int selectedSlot = default(int);
			((FastBufferReader)(ref data)).ReadValue<int>(ref selectedSlot, default(ForPrimitives));
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref controllerReference)).TryGet(ref val, (NetworkManager)null) && senderId == 0L)
			{
				PlayerControllerB controllerB = NetworkObjectReference.op_Implicit(controllerReference).GetComponent<PlayerControllerB>();
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.syncSelectedSlotClientRpc was called for {1}! slot:{2} was:{3}", "PlayerControllerB", ((NetworkObjectReference)(ref controllerReference)).NetworkObjectId, selectedSlot, controllerB.currentItemSlot));
				if (!((NetworkBehaviour)controllerB).IsOwner && controllerB.currentItemSlot != selectedSlot)
				{
					controllerB.SwitchToItemSlot(selectedSlot, (GrabbableObject)null);
				}
			}
		}

		public static void SyncUsernameServerRpc(NetworkObjectReference controllerReference, string username)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			((FastBufferWriter)(ref val)).WriteValue(username, false);
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncUsernameServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnSyncUsernameServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				NetworkObjectReference controllerReference = default(NetworkObjectReference);
				((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref controllerReference);
				string username = default(string);
				((FastBufferReader)(ref data)).ReadValue(ref username, false);
				NetworkObject val = default(NetworkObject);
				if (((NetworkObjectReference)(ref controllerReference)).TryGet(ref val, (NetworkManager)null) && (senderId == 0L || val.OwnerClientId == senderId))
				{
					AdditionalNetworking.Log.LogDebug((object)string.Format("{0}.syncUsernameServerRpc was called for {1}!", "PlayerControllerB", ((NetworkObjectReference)(ref controllerReference)).NetworkObjectId));
					SyncUsernameClientRpc(controllerReference, username);
				}
			}
		}

		private static void SyncUsernameClientRpc(NetworkObjectReference controllerReference, string username, ulong[] targets = null)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteNetworkSerializable<NetworkObjectReference>(ref controllerReference);
			((FastBufferWriter)(ref val)).WriteValue(username, false);
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncUsernameClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncUsernameClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnSyncUsernameClientRpc(ulong senderId, FastBufferReader data)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			NetworkObjectReference val = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref val);
			string text = default(string);
			((FastBufferReader)(ref data)).ReadValue(ref text, false);
			NetworkObject val2 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) || senderId != 0L)
			{
				return;
			}
			AdditionalNetworking.Log.LogDebug((object)string.Format("{0}.syncUsernameClientRpc was called for {1}!", "PlayerControllerB", ((NetworkObjectReference)(ref val)).NetworkObjectId));
			PlayerControllerB controllerB = NetworkObjectReference.op_Implicit(val).GetComponent<PlayerControllerB>();
			if (((NetworkBehaviour)controllerB).IsOwner)
			{
				return;
			}
			controllerB.playerUsername = text;
			((TMP_Text)controllerB.usernameBillboardText).text = text;
			StartOfRound.Instance.mapScreen.ChangeNameOfTargetTransform(((Component)controllerB).transform, text);
			if (HUDManager.Instance.spectatingPlayerBoxes.ContainsValue(controllerB))
			{
				GameObject gameObject = ((Component)HUDManager.Instance.spectatingPlayerBoxes.First((KeyValuePair<Animator, PlayerControllerB> x) => (Object)(object)x.Value == (Object)(object)controllerB).Key).gameObject;
				((TMP_Text)gameObject.GetComponentInChildren<TextMeshProUGUI>()).text = text;
			}
		}

		public static void RequestSyncUsernameServerRpc(NetworkObjectReference controllerReference)
		{
			//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 controllerReference);
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(RequestSyncUsernameServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnRequestSyncUsernameServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			NetworkObjectReference val = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref val);
			NetworkObject val2 = default(NetworkObject);
			if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null))
			{
				AdditionalNetworking.Log.LogDebug((object)string.Format("{0}.requestSyncUsernameServerRpc was called for {1} by {2}!", "PlayerControllerB", ((NetworkObjectReference)(ref val)).NetworkObjectId, senderId));
				PlayerControllerB component = NetworkObjectReference.op_Implicit(val).GetComponent<PlayerControllerB>();
				if (!((NetworkBehaviour)component).IsOwnedByServer)
				{
					SyncUsernameClientRpc(val, component.playerUsername, new ulong[1] { senderId });
				}
			}
		}
	}
	public static class Shotgun
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnSyncAmmoServerRpc;

			public static HandleNamedMessageDelegate <1>__OnSyncAmmoClientRpc;

			public static HandleNamedMessageDelegate <2>__OnSyncSafetyServerRpc;

			public static HandleNamedMessageDelegate <3>__OnSyncSafetyClientRpc;

			public static HandleNamedMessageDelegate <4>__OnRequestSyncServerRpc;
		}

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

		private static readonly string SyncAmmoClientRpcMessage = BaseName + "|SyncAmmoClientRpc";

		private static readonly string SyncAmmoServerRpcMessage = BaseName + "|SyncAmmoServerRpc";

		private static readonly string SyncSafetyClientRpcMessage = BaseName + "|SyncSafetyClientRpc";

		private static readonly string SyncSafetyServerRpcMessage = BaseName + "|SyncSafetyServerRpc";

		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
			//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
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			string syncAmmoServerRpcMessage = SyncAmmoServerRpcMessage;
			object obj = <>O.<0>__OnSyncAmmoServerRpc;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = OnSyncAmmoServerRpc;
				<>O.<0>__OnSyncAmmoServerRpc = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler(syncAmmoServerRpcMessage, (HandleNamedMessageDelegate)obj);
			CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
			string syncAmmoClientRpcMessage = SyncAmmoClientRpcMessage;
			object obj2 = <>O.<1>__OnSyncAmmoClientRpc;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnSyncAmmoClientRpc;
				<>O.<1>__OnSyncAmmoClientRpc = val2;
				obj2 = (object)val2;
			}
			customMessagingManager2.RegisterNamedMessageHandler(syncAmmoClientRpcMessage, (HandleNamedMessageDelegate)obj2);
			CustomMessagingManager customMessagingManager3 = NetworkManager.Singleton.CustomMessagingManager;
			string syncSafetyServerRpcMessage = SyncSafetyServerRpcMessage;
			object obj3 = <>O.<2>__OnSyncSafetyServerRpc;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val3 = OnSyncSafetyServerRpc;
				<>O.<2>__OnSyncSafetyServerRpc = val3;
				obj3 = (object)val3;
			}
			customMessagingManager3.RegisterNamedMessageHandler(syncSafetyServerRpcMessage, (HandleNamedMessageDelegate)obj3);
			CustomMessagingManager customMessagingManager4 = NetworkManager.Singleton.CustomMessagingManager;
			string syncSafetyClientRpcMessage = SyncSafetyClientRpcMessage;
			object obj4 = <>O.<3>__OnSyncSafetyClientRpc;
			if (obj4 == null)
			{
				HandleNamedMessageDelegate val4 = OnSyncSafetyClientRpc;
				<>O.<3>__OnSyncSafetyClientRpc = val4;
				obj4 = (object)val4;
			}
			customMessagingManager4.RegisterNamedMessageHandler(syncSafetyClientRpcMessage, (HandleNamedMessageDelegate)obj4);
			CustomMessagingManager customMessagingManager5 = NetworkManager.Singleton.CustomMessagingManager;
			string requestSyncServerRpcMessage = RequestSyncServerRpcMessage;
			object obj5 = <>O.<4>__OnRequestSyncServerRpc;
			if (obj5 == null)
			{
				HandleNamedMessageDelegate val5 = OnRequestSyncServerRpc;
				<>O.<4>__OnRequestSyncServerRpc = val5;
				obj5 = (object)val5;
			}
			customMessagingManager5.RegisterNamedMessageHandler(requestSyncServerRpcMessage, (HandleNamedMessageDelegate)obj5);
		}

		public static void SyncAmmoServerRpc(NetworkObjectReference shotgunReference, int ammoCount)
		{
			//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 shotgunReference);
			((FastBufferWriter)(ref val)).WriteValue<int>(ref ammoCount, default(ForPrimitives));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncAmmoServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnSyncAmmoServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			NetworkObjectReference shotgunReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref shotgunReference);
			int ammoCount = default(int);
			((FastBufferReader)(ref data)).ReadValue<int>(ref ammoCount, default(ForPrimitives));
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref shotgunReference)).TryGet(ref val, (NetworkManager)null) && (senderId == 0L || val.OwnerClientId == senderId))
			{
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncAmmoServerRpc was called for {1}! ammo: {2}", "Shotgun", ((NetworkObjectReference)(ref shotgunReference)).NetworkObjectId, ammoCount));
				SyncAmmoClientRpc(shotgunReference, ammoCount);
			}
		}

		private static void SyncAmmoClientRpc(NetworkObjectReference shotgunReference, int ammoCount, 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 shotgunReference);
			((FastBufferWriter)(ref val)).WriteValue<int>(ref ammoCount, default(ForPrimitives));
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncAmmoClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncAmmoClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnSyncAmmoClientRpc(ulong senderId, FastBufferReader data)
		{
			//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_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkObjectReference shotgunReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref shotgunReference);
			int ammoCount = default(int);
			((FastBufferReader)(ref data)).ReadValue<int>(ref ammoCount, default(ForPrimitives));
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref shotgunReference)).TryGet(ref val, (NetworkManager)null) && senderId == 0L)
			{
				ShotgunItem shotgunItem = NetworkObjectReference.op_Implicit(shotgunReference).GetComponent<ShotgunItem>();
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncAmmoClientRpc was called for {1}! ammo: {2} was: {3}", "Shotgun", ((NetworkObjectReference)(ref shotgunReference)).NetworkObjectId, ammoCount, shotgunItem.shellsLoaded));
				if (!((NetworkBehaviour)shotgunItem).IsOwner)
				{
					shotgunItem.shellsLoaded = ammoCount;
				}
			}
		}

		public static void SyncSafetyServerRpc(NetworkObjectReference shotgunReference, bool safety)
		{
			//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 shotgunReference);
			((FastBufferWriter)(ref val)).WriteValue<bool>(ref safety, default(ForPrimitives));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncSafetyServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnSyncSafetyServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			NetworkObjectReference shotgunReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref shotgunReference);
			bool safety = default(bool);
			((FastBufferReader)(ref data)).ReadValue<bool>(ref safety, default(ForPrimitives));
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref shotgunReference)).TryGet(ref val, (NetworkManager)null) && (senderId == 0L || val.OwnerClientId == senderId))
			{
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncSafetyServerRpc was called for {1}! safety:{2}", "Shotgun", ((NetworkObjectReference)(ref shotgunReference)).NetworkObjectId, safety ? "on" : "off"));
				SyncSafetyClientRpc(shotgunReference, safety);
			}
		}

		private static void SyncSafetyClientRpc(NetworkObjectReference shotgunReference, bool safety, 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 shotgunReference);
			((FastBufferWriter)(ref val)).WriteValue<bool>(ref safety, default(ForPrimitives));
			if (targets == null)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(SyncSafetyClientRpcMessage, val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(SyncSafetyClientRpcMessage, (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)3);
			}
		}

		private static void OnSyncSafetyClientRpc(ulong senderId, FastBufferReader data)
		{
			//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_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkObjectReference shotgunReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref shotgunReference);
			bool safety = default(bool);
			((FastBufferReader)(ref data)).ReadValue<bool>(ref safety, default(ForPrimitives));
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref shotgunReference)).TryGet(ref val, (NetworkManager)null) && senderId == 0L)
			{
				ShotgunItem shotgunItem = NetworkObjectReference.op_Implicit(shotgunReference).GetComponent<ShotgunItem>();
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.SyncSafetyClientRpc was called for {1}! safety:{2} was: {3}", "Shotgun", ((NetworkObjectReference)(ref shotgunReference)).NetworkObjectId, safety ? "on" : "off", shotgunItem.safetyOn ? "on" : "off"));
				if (!((NetworkBehaviour)shotgunItem).IsOwner)
				{
					shotgunItem.safetyOn = safety;
				}
			}
		}

		public static void RequestSyncServerRpc(NetworkObjectReference shotgunReference)
		{
			//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 shotgunReference);
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(RequestSyncServerRpcMessage, 0uL, val, (NetworkDelivery)3);
		}

		private static void OnRequestSyncServerRpc(ulong senderId, FastBufferReader data)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			NetworkObjectReference shotgunReference = default(NetworkObjectReference);
			((FastBufferReader)(ref data)).ReadNetworkSerializable<NetworkObjectReference>(ref shotgunReference);
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref shotgunReference)).TryGet(ref val, (NetworkManager)null))
			{
				AdditionalNetworking.VerboseLog((LogLevel)32, () => string.Format("{0}.RequestSyncServerRpc was called for {1} by {2}!", "Shotgun", ((NetworkObjectReference)(ref shotgunReference)).NetworkObjectId, senderId));
				ShotgunItem component = NetworkObjectReference.op_Implicit(shotgunReference).GetComponent<ShotgunItem>();
				SyncAmmoClientRpc(shotgunReference, component.shellsLoaded, new ulong[1] { senderId });
				SyncSafetyClientRpc(shotgunReference, component.safetyOn, new ulong[1] { senderId });
			}
		}
	}
}
namespace AdditionalNetworking.Dependency
{
	public static class AsyncLoggerProxy
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (_enabled.HasValue)
				{
					return _enabled.Value;
				}
				try
				{
					_enabled = isDbEnabled();
				}
				catch (Exception)
				{
					_enabled = false;
					return false;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void WriteEvent(string source, string tag, string data, DateTime? timestamp = null)
		{
			SqliteLogger.WriteEvent(source, tag, data, timestamp);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void WriteData(string source, string tag, string data, DateTime? timestamp = null)
		{
			SqliteLogger.WriteData(source, tag, data, timestamp);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool isDbEnabled()
		{
			return SqliteLogger.Enabled;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static int getExecutionID()
		{
			return SqliteLogger.ExecutionId;
		}
	}
	public static class LobbyCompatibilityChecker
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Init()
		{
			PluginHelper.RegisterPlugin("mattymatty.AdditionalNetworking", Version.Parse("2.1.2"), (CompatibilityLevel)0, (VersionStrictness)2);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}