Decompiled source of ShotgunFreedom v1.0.0

ShotgunFreedom.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ShotgunRoulette.Network;
using ShotgunRoulette.Patches;
using ShotgunRoulette.Players;
using ShotgunRoulette.UI;
using ShotgunRoulette.Utils;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using zeeblo.ShotgunRoulette.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("zeeblo.ShotgunRoulette")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0+9b6a3b2052f358904c4505fa32e9c8e417175564")]
[assembly: AssemblyProduct("ShotgunRoulette")]
[assembly: AssemblyTitle("zeeblo.ShotgunRoulette")]
[assembly: AssemblyVersion("0.3.0.0")]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 ShotgunRoulette
{
	[BepInPlugin("ShotgunFreedom", "ShotgunFreedom", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string MOD_GUID = "ShotgunFreedom";

		private const string MOD_Name = "ShotgunFreedom";

		private const string MOD_Version = "1.0.0";

		private readonly Harmony _harmony = new Harmony("ShotgunFreedom");

		public static Plugin? instance;

		internal static ManualLogSource mls = Logger.CreateLogSource("ShotgunFreedom");

		public static bool gunIsOnFace = false;

		public static List<ConfigEntry<string>> AllHotkeys = new List<ConfigEntry<string>>();

		public static Random random = new Random();

		public static int randomDamage = random.Next(999, 999);

		public static string MainDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "");

		public static string BundleDir = GetAssetPath();

		public static AssetBundle myBundle = AssetBundle.LoadFromFile(BundleDir);

		private void Awake()
		{
			instance = this;
			LConfig.AllConfigs(((BaseUnityPlugin)this).Config);
			NetcodePatcher();
			PatchAll();
			Controls.InitControls();
		}

		private void PatchAll()
		{
			_harmony.PatchAll(typeof(PlayerControllerBPatch));
			_harmony.PatchAll(typeof(ShotgunItemPatch));
			_harmony.PatchAll(typeof(KeybindsUI));
			_harmony.PatchAll(typeof(NetObjectManager));
		}

		private void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		public static bool ToggleGunRotation(PlayerControllerB __instance)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)__instance.ItemSlots[__instance.currentItemSlot] == (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)__instance.ItemSlots[__instance.currentItemSlot]).GetComponent<ShotgunItem>() == (Object)null)
			{
				return false;
			}
			gunIsOnFace = !gunIsOnFace;
			if (gunIsOnFace)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(0.28f, 0.28f, -0.28f);
				((Component)__instance.ItemSlots[__instance.currentItemSlot]).transform.localScale = val;
				NetObjectManager.RequestFromPlayer(localPlayerController.playerClientId, __instance.currentItemSlot, val);
			}
			else
			{
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(0.28f, 0.28f, 0.28f);
				((Component)__instance.ItemSlots[__instance.currentItemSlot]).transform.localScale = val2;
				NetObjectManager.RequestFromPlayer(localPlayerController.playerClientId, __instance.currentItemSlot, val2);
			}
			return gunIsOnFace;
		}

		private static string GetAssetPath()
		{
			string text = MainDir + "\\Assets\\Assetbundles\\roulette";
			string result = MainDir + "/roulette";
			if (File.Exists(text))
			{
				return text;
			}
			return result;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "zeeblo.ShotgunRoulette";

		public const string PLUGIN_NAME = "ShotgunRoulette";

		public const string PLUGIN_VERSION = "0.3.0";
	}
}
namespace ShotgunRoulette.Utils
{
	public class LConfig
	{
		public static ConfigFile _config;

		public static ConfigEntry<string> gunRotationBind;

		public static void AllConfigs(ConfigFile cfg)
		{
			_config = cfg;
			gunRotationBind = cfg.Bind<string>("Keybinds", "Aim at Yourself", "h", "Point the gun at yourself");
			Plugin.AllHotkeys.Add(gunRotationBind);
		}
	}
}
namespace ShotgunRoulette.UI
{
	[HarmonyPatch]
	internal class KeybindsUI
	{
		private static List<RemappableKey> allCustomBinds = new List<RemappableKey>();

		private static List<string> ControlNames = new List<string>();

		public static void AddCustomBinds()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (!((Object)(object)Controls.gunRotationRef == (Object)null))
			{
				RemappableKey item = new RemappableKey
				{
					ControlName = "Aim at Yourself",
					currentInput = Controls.gunRotationRef,
					rebindingIndex = 0,
					gamepadOnly = false
				};
				allCustomBinds.Add(item);
			}
		}

		[HarmonyPatch(typeof(KepRemapPanel), "LoadKeybindsUI")]
		[HarmonyPrefix]
		private static bool LoadBindsPatch(KepRemapPanel __instance)
		{
			__instance.maxVertical += 1f;
			Controls.userControls.Disable();
			for (int i = 0; i < __instance.remappableKeys.Count; i++)
			{
				ControlNames.Add(__instance.remappableKeys[i].ControlName.ToLower());
			}
			int j;
			for (j = 0; j < allCustomBinds.Count; j++)
			{
				string value = Array.Find(ControlNames.ToArray(), (string elem) => elem.Equals(allCustomBinds[j].ControlName.ToLower()));
				if (string.IsNullOrEmpty(value))
				{
					__instance.remappableKeys.Insert(0, allCustomBinds[j]);
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "CompleteRebind")]
		[HarmonyPostfix]
		private static void CompleteRebindPatch(SettingsOption optionUI)
		{
			for (int i = 0; i < Plugin.AllHotkeys.Count; i++)
			{
				if (((ConfigEntryBase)Plugin.AllHotkeys[i]).Definition.Key.ToLower() == ((TMP_Text)optionUI.textElement).text.ToLower())
				{
					Plugin.AllHotkeys[i].Value = ((TMP_Text)optionUI.currentlyUsedKeyText).text;
					((ConfigEntryBase)Plugin.AllHotkeys[i]).ConfigFile.Save();
					InputActionRebindingExtensions.ApplyBindingOverride(Controls.userControls.FindAction(((ConfigEntryBase)Plugin.AllHotkeys[i]).Definition.Key.ToLower(), false), "<Keyboard>/" + ((TMP_Text)optionUI.currentlyUsedKeyText).text.ToLower(), (string)null, (string)null);
					break;
				}
			}
		}

		[HarmonyPatch(typeof(KepRemapPanel), "OnDisable")]
		[HarmonyPostfix]
		private static void KepOnDisablePatch()
		{
			ControlNames.Clear();
			if (!Controls.userControls.enabled)
			{
				Controls.userControls.Enable();
			}
		}
	}
}
namespace ShotgunRoulette.Players
{
	internal class Controls
	{
		private static InputActionAsset actionAsset = ScriptableObject.CreateInstance<InputActionAsset>();

		public static InputActionMap userControls = InputActionSetupExtensions.AddActionMap(actionAsset, "UserControls");

		public static InputActionReference? gunRotationRef;

		public static void InitControls()
		{
			if (LConfig.gunRotationBind != null)
			{
				InputAction val = InputActionSetupExtensions.AddAction(userControls, "aim at you", (InputActionType)1, "<Keyboard>/" + LConfig.gunRotationBind.Value, (string)null, (string)null, (string)null, (string)null);
				val.performed += GunRotation_performed;
				userControls.Enable();
				gunRotationRef = InputActionReference.Create(val);
				KeybindsUI.AddCustomBinds();
			}
		}

		private static void GunRotation_performed(CallbackContext context)
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				Plugin.ToggleGunRotation(GameNetworkManager.Instance.localPlayerController);
			}
		}
	}
}
namespace ShotgunRoulette.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(PlayerControllerB __instance)
		{
			if (Plugin.gunIsOnFace)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			if (__instance.currentItemSlot >= 0 && __instance.currentItemSlot < __instance.ItemSlots.Length && !((Object)(object)__instance.ItemSlots[__instance.currentItemSlot] == (Object)null) && !((Object)(object)((Component)__instance.ItemSlots[__instance.currentItemSlot]).GetComponent<ShotgunItem>() == (Object)null) && __instance.ItemSlots[__instance.currentItemSlot].playerHeldBy.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId)
			{
				string text = (((Component)__instance.ItemSlots[__instance.currentItemSlot]).GetComponent<ShotgunItem>().safetyOn ? "off" : "on");
				((TMP_Text)HUDManager.Instance.controlTipLines.Last()).text = "Turn Safety " + text + " : [Q] \n Aim at Yourself : [" + LConfig.gunRotationBind?.Value.ToUpper() + "]";
			}
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static void KillPlayerPatch(PlayerControllerB __instance)
		{
			Plugin.gunIsOnFace = false;
		}

		[HarmonyPatch("ScrollMouse_performed")]
		[HarmonyPrefix]
		private static void ScrollPatch(PlayerControllerB __instance)
		{
			if (Plugin.gunIsOnFace)
			{
				Plugin.ToggleGunRotation(__instance);
			}
		}

		[HarmonyPatch("SwitchToItemSlot")]
		[HarmonyPrefix]
		private static void SwitchToItemSlotPatch(PlayerControllerB __instance)
		{
			if (Plugin.gunIsOnFace)
			{
				Plugin.ToggleGunRotation(__instance);
			}
		}

		[HarmonyPatch("DiscardHeldObject")]
		[HarmonyPrefix]
		private static void DiscardHeldObjectPatch(PlayerControllerB __instance)
		{
			if (Plugin.gunIsOnFace)
			{
				Plugin.ToggleGunRotation(__instance);
			}
		}

		[HarmonyPatch("OnDisable")]
		[HarmonyPrefix]
		private static void OnDisablePatch(PlayerControllerB __instance)
		{
			if (Plugin.gunIsOnFace)
			{
				Plugin.ToggleGunRotation(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(ShotgunItem))]
	internal class ShotgunItemPatch
	{
		[HarmonyPatch("ShootGunAndSync")]
		[HarmonyPrefix]
		private static bool ShootFace(ShotgunItem __instance)
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			if (StartOfRound.Instance.inShipPhase && Plugin.gunIsOnFace)
			{
				__instance.gunAudio.PlayOneShot(__instance.noAmmoSFX);
				return false;
			}
			if (Plugin.gunIsOnFace && __instance.shellsLoaded >= 1 && !__instance.safetyOn)
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				MethodInfo method = typeof(PlayerControllerB).GetMethod("CanUseItem", BindingFlags.Instance | BindingFlags.NonPublic);
				bool flag = (bool)method.Invoke(localPlayerController, null);
				if (StartOfRound.Instance.inShipPhase)
				{
					return true;
				}
				if (!Plugin.gunIsOnFace)
				{
					return true;
				}
				if ((Object)(object)localPlayerController.currentlyHeldObjectServer == (Object)null)
				{
					return true;
				}
				if (!flag)
				{
					return true;
				}
				RotatePlayer();
				localPlayerController.DamagePlayer(Plugin.randomDamage, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
			}
			return true;
		}

		private static void RotatePlayer()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			((Component)localPlayerController.thisPlayerBody).transform.Rotate(0f, 180f, 0f);
			((Component)localPlayerController.gameplayCamera).transform.localEulerAngles = new Vector3(0f, 0f, ((Component)localPlayerController.gameplayCamera).transform.localEulerAngles.z);
		}
	}
}
namespace ShotgunRoulette.Network
{
	public class NetHandler : NetworkBehaviour
	{
		public static NetHandler instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ClientRpc]
		public void RotateGunClientRpc(ulong plrID, int itemPos, Vector3 gunRotation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1213105983u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, plrID);
				BytePacker.WriteValueBitPacked(val, itemPos);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref gunRotation);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1213105983u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (GameNetworkManager.Instance.localPlayerController.playerClientId != plrID)
				{
					((Component)StartOfRound.Instance.allPlayerScripts[plrID].ItemSlots[itemPos]).transform.localScale = gunRotation;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RotateGunServerRpc(ulong plrID, int itemPos, Vector3 gunRotation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1383985616u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, plrID);
					BytePacker.WriteValueBitPacked(val, itemPos);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref gunRotation);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1383985616u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					RotateGunClientRpc(plrID, itemPos, gunRotation);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1213105983u, new RpcReceiveHandler(__rpc_handler_1213105983), "RotateGunClientRpc");
			((NetworkBehaviour)this).__registerRpc(1383985616u, new RpcReceiveHandler(__rpc_handler_1383985616), "RotateGunServerRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1213105983(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong plrID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref plrID);
				int itemPos = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemPos);
				Vector3 gunRotation = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref gunRotation);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetHandler)(object)target).RotateGunClientRpc(plrID, itemPos, gunRotation);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1383985616(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong plrID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref plrID);
				int itemPos = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemPos);
				Vector3 gunRotation = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref gunRotation);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetHandler)(object)target).RotateGunServerRpc(plrID, itemPos, gunRotation);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "NetHandler";
		}
	}
	[HarmonyPatch]
	internal class NetObjectManager
	{
		private static GameObject networkPrefab;

		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPostfix]
		private static void StartPatch(GameNetworkManager __instance)
		{
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = Plugin.myBundle.LoadAsset<GameObject>("NetworkManager_roulette.prefab");
				networkPrefab.AddComponent<NetHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void SpawnNetworkHandler()
		{
			//IL_0035: 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)
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && !((Object)(object)networkPrefab == (Object)null))
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		public static void RequestFromPlayer(ulong plrID, int itemPos, Vector3 gunRotation)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)NetHandler.instance == (Object)null))
			{
				if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
				{
					NetHandler.instance.RotateGunClientRpc(plrID, itemPos, gunRotation);
				}
				else
				{
					NetHandler.instance.RotateGunServerRpc(plrID, itemPos, gunRotation);
				}
			}
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace zeeblo.ShotgunRoulette.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}