Decompiled source of ShotgunRoulette v0.1.0

zeeblo.ShotgunRoulette.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.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 TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
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.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+a79f0d64ef0a756de234f2475ef5337e53f65c6a")]
[assembly: AssemblyProduct("ShotgunRoulette")]
[assembly: AssemblyTitle("zeeblo.ShotgunRoulette")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShotgunRoulette
{
	[BepInPlugin("ShotgunRoulette.zeeblo.dev", "zeeblo.ShotgunRoulette", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string MOD_GUID = "ShotgunRoulette.zeeblo.dev";

		private const string MOD_Name = "zeeblo.ShotgunRoulette";

		private const string MOD_Version = "0.1.0";

		private readonly Harmony _harmony = new Harmony("ShotgunRoulette.zeeblo.dev");

		public static Plugin? instance;

		internal static ManualLogSource mls = Logger.CreateLogSource("ShotgunRoulette.zeeblo.dev");

		public static bool gunIsOnFace = false;

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

		public static ConfigEntry<string>? gunRotationBind;

		public static Random random = new Random();

		public static int rouletteNumber = random.Next(1, 5);

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

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

		public static string BundleDir = MainDir + "\\Assets\\Assetbundles\\roulette";

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

		public static AudioClip? SFX_revolverSpin;

		private void Awake()
		{
			instance = this;
			gunRotationBind = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay Controls", "Aim at you", "h", "Point the gun at yourself");
			AllHotkeys.Add(gunRotationBind);
			NetcodePatcher();
			PatchAll();
			AssetLoader();
			Controls.InitControls();
		}

		private void PatchAll()
		{
			_harmony.PatchAll(typeof(PlayerControllerBPatch));
			_harmony.PatchAll(typeof(HUDManagerPatch));
			_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 void AssetLoader()
		{
			AudioClip sFX_revolverSpin = myBundle.LoadAsset<AudioClip>("revolver-spin.mp3");
			SFX_revolverSpin = sFX_revolverSpin;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "zeeblo.ShotgunRoulette";

		public const string PLUGIN_NAME = "ShotgunRoulette";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace ShotgunRoulette.Utils
{
	[HarmonyPatch]
	internal class GunTests
	{
		public static bool spawnedNut;

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "Update")]
		[HarmonyPrefix]
		private static bool UpdatePatch(NutcrackerEnemyAI __instance)
		{
			if (!spawnedNut)
			{
				((EnemyAI)__instance).KillEnemy(false);
				spawnedNut = true;
				((MonoBehaviour)StartOfRound.Instance).StartCoroutine(DespawnEnemies());
			}
			return true;
		}

		public static void InitTestControls()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			Plugin.mls.LogInfo((object)">> added keybind");
			InputAction val = new InputAction("spawn", (InputActionType)1, "<Keyboard>/J", (string)null, (string)null, (string)null);
			val.performed += KeyPressed_performed;
			val.Enable();
		}

		private static void KeyPressed_performed(CallbackContext context)
		{
			Plugin.mls.LogInfo((object)"pressed");
			SpawnShotgun();
			spawnedNut = false;
		}

		public static void SpawnShotgun()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position;
			SelectableLevel val = RoundManager.Instance.playersManager.levels[6];
			Object.Instantiate<GameObject>(val.Enemies[9].enemyType.enemyPrefab, position, Quaternion.identity).gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
		}

		public static IEnumerator DespawnEnemies()
		{
			yield return (object)new WaitForSeconds(3f);
			Scene SampleScene = SceneManager.GetSceneAt(0);
			GameObject[] rootGameObjects = ((Scene)(ref SampleScene)).GetRootGameObjects();
			foreach (GameObject obj in rootGameObjects)
			{
				if (((Object)obj).name.Contains("Nutcracker"))
				{
					Object.Destroy((Object)(object)obj.gameObject);
				}
			}
		}
	}
}
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 you",
					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 j = 0; j < __instance.remappableKeys.Count; j++)
			{
				ControlNames.Add(__instance.remappableKeys[j].ControlName.ToLower());
			}
			int i;
			for (i = 0; i < allCustomBinds.Count; i++)
			{
				string value = Array.Find(ControlNames.ToArray(), (string elem) => elem.Equals(allCustomBinds[i].ControlName.ToLower()));
				if (string.IsNullOrEmpty(value))
				{
					__instance.remappableKeys.Insert(0, allCustomBinds[i]);
				}
			}
			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 (Plugin.gunRotationBind != null)
			{
				InputAction val = InputActionSetupExtensions.AddAction(userControls, "aim at you", (InputActionType)1, "<Keyboard>/" + Plugin.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(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("PingScan_performed")]
		[HarmonyPrefix]
		private static bool Roulette()
		{
			if (Plugin.gunIsOnFace)
			{
				Plugin.rouletteNumber = Plugin.random.Next(1, 5);
				Plugin.randomDamage = Plugin.random.Next(95, 145);
				PlayerControllerBPatch.rouletteMode = !PlayerControllerBPatch.rouletteMode;
				if (PlayerControllerBPatch.rouletteMode)
				{
					PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
					((Component)localPlayerController.currentlyHeldObjectServer).gameObject.GetComponent<AudioSource>().PlayOneShot(Plugin.SFX_revolverSpin, 0.6f);
				}
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		public static bool rouletteMode;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(PlayerControllerB __instance)
		{
			if (Plugin.gunIsOnFace)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			if ((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 = (Plugin.gunIsOnFace ? $"\n Roulette Mode ({rouletteMode}) : [RMB] \n Shoot Yourself : [LMB]" : "");
				string text2 = (((Component)__instance.ItemSlots[__instance.currentItemSlot]).GetComponent<ShotgunItem>().safetyOn ? "off" : "on");
				((TMP_Text)HUDManager.Instance.controlTipLines.Last()).text = "Turn Safety " + text2 + " : [Q] \n Aim at you : [" + Plugin.gunRotationBind?.Value + "] " + text;
			}
		}

		[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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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;
				}
				if (PlayerControllerBPatch.rouletteMode)
				{
					if (Plugin.rouletteNumber == 1)
					{
						RotatePlayer();
						localPlayerController.DamagePlayer(Plugin.randomDamage, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
						return true;
					}
					__instance.gunAudio.PlayOneShot(__instance.noAmmoSFX);
					return false;
				}
				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);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(ShotgunItem __instance)
		{
			__instance.shellsLoaded = 2;
		}
	}
}
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_0114: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1213105983u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, plrID);
					BytePacker.WriteValueBitPacked(val2, itemPos);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref gunRotation);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1213105983u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && 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_00e6: 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 val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1383985616u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, plrID);
					BytePacker.WriteValueBitPacked(val2, itemPos);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref gunRotation);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1383985616u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					RotateGunClientRpc(plrID, itemPos, gunRotation);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_NetHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1213105983u, new RpcReceiveHandler(__rpc_handler_1213105983));
			NetworkManager.__rpc_func_table.Add(1383985616u, new RpcReceiveHandler(__rpc_handler_1383985616));
		}

		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)2;
				((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 zeeblo.ShotgunRoulette.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}