Decompiled source of Piggys Variety Mod v1.3.16

PiggyVarietyMod.dll

Decompiled 3 days 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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MoreEmotes.Patch;
using PiggyVarietyMod.Patches;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RadiationIsCool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RadiationIsCool")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
		}
	}
}
public class AxeItem : GrabbableObject
{
	public int shovelHitForce = 1;

	public bool reelingUp;

	public bool isHoldingButton;

	private RaycastHit rayHit;

	private Coroutine reelingUpCoroutine;

	private RaycastHit[] objectsHitByShovel;

	private List<RaycastHit> objectsHitByShovelList = new List<RaycastHit>();

	public AudioClip reelUp;

	public AudioClip swing;

	public AudioClip[] hitSFX;

	public AudioSource shovelAudio;

	private PlayerControllerB previousPlayerHeldBy;

	private int shovelMask = 11012424;

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		if ((Object)(object)base.playerHeldBy == (Object)null)
		{
			return;
		}
		Debug.Log((object)$"Is player pressing down button?: {buttonDown}");
		isHoldingButton = buttonDown;
		Debug.Log((object)("PLAYER ACTIVATED ITEM TO HIT WITH SHOVEL. Who sent this log: " + ((Object)((Component)GameNetworkManager.Instance.localPlayerController).gameObject).name));
		if (!reelingUp && buttonDown)
		{
			reelingUp = true;
			previousPlayerHeldBy = base.playerHeldBy;
			Debug.Log((object)$"Set previousPlayerHeldBy: {previousPlayerHeldBy}");
			if (reelingUpCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(reelingUpCoroutine);
			}
			reelingUpCoroutine = ((MonoBehaviour)this).StartCoroutine(reelUpShovel());
		}
	}

	private IEnumerator reelUpShovel()
	{
		base.playerHeldBy.activatingItem = true;
		base.playerHeldBy.twoHanded = true;
		base.playerHeldBy.playerBodyAnimator.ResetTrigger("shovelHit");
		base.playerHeldBy.playerBodyAnimator.SetBool("reelingUp", true);
		shovelAudio.PlayOneShot(reelUp);
		ReelUpSFXServerRpc();
		yield return (object)new WaitForSeconds(0.35f);
		yield return (object)new WaitUntil((Func<bool>)(() => !isHoldingButton || !base.isHeld));
		SwingShovel(!base.isHeld);
		yield return (object)new WaitForSeconds(0.13f);
		yield return (object)new WaitForEndOfFrame();
		HitShovel(!base.isHeld);
		yield return (object)new WaitForSeconds(0.3f);
		reelingUp = false;
		reelingUpCoroutine = null;
	}

	[ServerRpc]
	public void ReelUpSFXServerRpc()
	{
		ReelUpSFXClientRpc();
	}

	[ClientRpc]
	public void ReelUpSFXClientRpc()
	{
		if (!((NetworkBehaviour)this).IsOwner)
		{
			shovelAudio.PlayOneShot(reelUp);
		}
	}

	public override void DiscardItem()
	{
		if ((Object)(object)base.playerHeldBy != (Object)null)
		{
			base.playerHeldBy.activatingItem = false;
		}
		((GrabbableObject)this).DiscardItem();
	}

	public void SwingShovel(bool cancel = false)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		previousPlayerHeldBy.playerBodyAnimator.SetBool("reelingUp", false);
		if (!cancel)
		{
			shovelAudio.PlayOneShot(swing);
			previousPlayerHeldBy.UpdateSpecialAnimationValue(true, (short)((Component)previousPlayerHeldBy).transform.localEulerAngles.y, 0.4f, false);
		}
	}

	public void HitShovel(bool cancel = false)
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_052c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_0464: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)previousPlayerHeldBy == (Object)null)
		{
			Debug.LogError((object)"Previousplayerheldby is null on this client when HitShovel is called.");
			return;
		}
		previousPlayerHeldBy.activatingItem = false;
		bool flag = false;
		bool flag2 = false;
		bool flag3 = false;
		int num = -1;
		if (!cancel)
		{
			previousPlayerHeldBy.twoHanded = false;
			objectsHitByShovel = Physics.SphereCastAll(((Component)previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)previousPlayerHeldBy.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward, 1.5f, shovelMask, (QueryTriggerInteraction)2);
			objectsHitByShovelList = objectsHitByShovel.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
			List<EnemyAI> list = new List<EnemyAI>();
			IHittable val2 = default(IHittable);
			RaycastHit val3 = default(RaycastHit);
			for (int i = 0; i < objectsHitByShovelList.Count; i++)
			{
				Vector3 forward = ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward;
				RaycastHit val = objectsHitByShovelList[i];
				if (((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
				{
					val = objectsHitByShovelList[i];
					if (!((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform))
					{
						val = objectsHitByShovelList[i];
						if (!(((RaycastHit)(ref val)).point == Vector3.zero))
						{
							Vector3 position = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
							val = objectsHitByShovelList[i];
							if (Physics.Linecast(position, ((RaycastHit)(ref val)).point, ref val3, StartOfRound.Instance.walkableSurfacesMask, (QueryTriggerInteraction)1))
							{
								goto IL_0221;
							}
						}
						val = objectsHitByShovelList[i];
						TerrainObstacleTrigger componentInChildren = ((Component)((RaycastHit)(ref val)).collider).GetComponentInChildren<TerrainObstacleTrigger>();
						if ((Object)(object)componentInChildren != (Object)null && ((NetworkBehaviour)this).IsOwner)
						{
							RoundManager.Instance.DestroyTreeOnLocalClient(((Component)componentInChildren).transform.position);
						}
					}
				}
				goto IL_0221;
				IL_0221:
				val = objectsHitByShovelList[i];
				if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 8)
				{
					val = objectsHitByShovelList[i];
					if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 11)
					{
						val = objectsHitByShovelList[i];
						if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
						{
							continue;
						}
						val = objectsHitByShovelList[i];
						if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform)
						{
							continue;
						}
						val = objectsHitByShovelList[i];
						if (!(((RaycastHit)(ref val)).point == Vector3.zero))
						{
							Vector3 position2 = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
							val = objectsHitByShovelList[i];
							if (Physics.Linecast(position2, ((RaycastHit)(ref val)).point, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
							{
								continue;
							}
						}
						flag = true;
						try
						{
							val = objectsHitByShovelList[i];
							EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<EnemyAICollisionDetect>();
							if ((Object)(object)component != (Object)null)
							{
								if ((Object)(object)component.mainScript == (Object)null || list.Contains(component.mainScript))
								{
									continue;
								}
								goto IL_045c;
							}
							val = objectsHitByShovelList[i];
							if (!((Object)(object)((Component)((RaycastHit)(ref val)).transform).GetComponent<PlayerControllerB>() != (Object)null))
							{
								goto IL_045c;
							}
							if (flag3)
							{
								continue;
							}
							flag3 = true;
							goto IL_045c;
							IL_045c:
							bool flag4 = val2.Hit(shovelHitForce, forward, previousPlayerHeldBy, true, 1);
							if (flag4 && (Object)(object)component != (Object)null)
							{
								list.Add(component.mainScript);
							}
							if (!flag2)
							{
								flag2 = flag4;
							}
						}
						catch (Exception arg)
						{
							Debug.Log((object)$"Exception caught when hitting object with shovel from player #{previousPlayerHeldBy.playerClientId}: {arg}");
						}
						continue;
					}
				}
				val = objectsHitByShovelList[i];
				if (((RaycastHit)(ref val)).collider.isTrigger)
				{
					continue;
				}
				flag = true;
				val = objectsHitByShovelList[i];
				string tag = ((Component)((RaycastHit)(ref val)).collider).gameObject.tag;
				for (int j = 0; j < StartOfRound.Instance.footstepSurfaces.Length; j++)
				{
					if (StartOfRound.Instance.footstepSurfaces[j].surfaceTag == tag)
					{
						num = j;
						break;
					}
				}
			}
		}
		if (flag)
		{
			RoundManager.PlayRandomClip(shovelAudio, hitSFX, true, 1f, 0, 1000);
			Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)this).transform.position, 17f, 0.8f, 0, false, 0);
			if (!flag2 && num != -1)
			{
				shovelAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX);
				WalkieTalkie.TransmitOneShotAudio(shovelAudio, StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX, 1f);
			}
			base.playerHeldBy.playerBodyAnimator.SetTrigger("shovelHit");
			HitShovelServerRpc(num);
		}
	}

	[ServerRpc]
	public void HitShovelServerRpc(int hitSurfaceID)
	{
		HitShovelClientRpc(hitSurfaceID);
	}

	[ClientRpc]
	public void HitShovelClientRpc(int hitSurfaceID)
	{
		if (!((NetworkBehaviour)this).IsOwner)
		{
			RoundManager.PlayRandomClip(shovelAudio, hitSFX, true, 1f, 0, 1000);
			if (hitSurfaceID != -1)
			{
				HitSurfaceWithShovel(hitSurfaceID);
			}
		}
	}

	private void HitSurfaceWithShovel(int hitSurfaceID)
	{
		shovelAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX);
		WalkieTalkie.TransmitOneShotAudio(shovelAudio, StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX, 1f);
	}
}
namespace PiggyVarietyMod
{
	[BepInPlugin("Piggy.PiggyVarietyMod", "PiggyVarietyMod", "1.3.16")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Piggy.PiggyVarietyMod";

		private const string modName = "PiggyVarietyMod";

		private const string modVersion = "1.3.16";

		private readonly Harmony harmony = new Harmony("Piggy.PiggyVarietyMod");

		private static Plugin Instance;

		public static ManualLogSource mls;

		public static AssetBundle Bundle;

		public static GameObject teslaGateSpawn;

		public static GameObject teslaGatePrefab;

		public static AudioClip teslaIdleStart;

		public static AudioClip teslaIdle;

		public static AudioClip teslaIdleEnd;

		public static AudioClip teslaCrack;

		public static AudioClip teslaBeep;

		public static AudioClip teslaWindUp;

		public static AudioClip teslaUnderbass;

		public static AudioClip teslaClimax;

		public static AudioClip flashlightShake;

		public static AudioClip gummylightClick;

		public static AudioClip gummylightOutage;

		public static AudioClip flashFlicker;

		public static Material flashlightBulb;

		public static Material blackRubber;

		public static GameObject gummylightPrefab;

		public static GameObject m4Prefab;

		public static GameObject axePrefab;

		public static Item revolverItem;

		public static Item revolverAmmoItem;

		public static Item gummyFlashlight;

		public static Item arItem;

		public static Item arMagItem;

		public static Item axeItem;

		public static Item bulbItem;

		public static Item chemicalItem;

		public static int revolverRarity;

		public static int revolverAmmoRarity;

		public static int revolverMaxPlayerDamage;

		public static int revolverMaxMonsterDamage;

		public static int rifleMaxPlayerDamage;

		public static int rifleMonsterDamage;

		public static bool customGunInfinityAmmo;

		public static int revolverPrice;

		public static int revolverAmmoPrice;

		public static int riflePrice;

		public static int rifleMagPrice;

		public static int rifleRarity;

		public static int rifleMagRarity;

		public static bool twoHandedRifle;

		public static int bulbRarity;

		public static int chemicalRarity;

		public static float teslaSpawnWeight;

		public static float teslaSoundVolume;

		public static bool teslaShake;

		public static bool translateKorean;

		public static AudioClip revolverAmmoInsert;

		public static AudioClip revolverCylinderOpen;

		public static AudioClip revolverCylinderClose;

		public static AudioClip revolverDryFire;

		public static AudioClip revolverBlast1;

		public static AudioClip revolverBlast2;

		public static AudioClip m4FireClip;

		public static AudioClip m4ReloadClip;

		public static AudioClip m4InspectClip;

		public static AudioClip m4TriggerClip;

		public static RuntimeAnimatorController playerAnimator;

		public static RuntimeAnimatorController otherPlayerAnimator;

		public static bool foundMoreEmotes;

		public static string PluginDirectory;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			LoadAssets();
			mls = Logger.CreateLogSource("Piggy.PiggyVarietyMod");
			mls.LogInfo((object)"Piggy's Variety Mod is loaded");
			teslaSoundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Generic", "TeslaGateVolume", 1f, "(Default 1) Sets the sound volume for Tesla Gate.").Value;
			teslaShake = ((BaseUnityPlugin)this).Config.Bind<bool>("Generic", "TeslaGateShake", false, "(Experimental, Default false) Shake the screen when near Tesla Gate.").Value;
			revolverMaxPlayerDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Generic", "RevolverMaxPlayerDamage", 70, "(Default 70) Sets the maximum amount of damage the Revolver can deals on the player.").Value;
			revolverMaxMonsterDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Generic", "RevolverMaxMonsterDamage", 4, "(Default 4) Sets the maximum amount of damage the Revolver can deals on the monster.").Value;
			rifleMaxPlayerDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Generic", "RifleMaxPlayerDamage", 22, "(Default 22) Sets the maximum amount of damage the Rifle can deals on the player.").Value;
			rifleMonsterDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Generic", "RifleMonsterDamage", 1, "(Default 1) Sets the amount of damage the Rifle deals to monsters.").Value;
			customGunInfinityAmmo = ((BaseUnityPlugin)this).Config.Bind<bool>("Generic", "CustomGunInfinityAmmo", false, "(Default false) If true, reloading custom guns will no longer require ammo.").Value;
			twoHandedRifle = ((BaseUnityPlugin)this).Config.Bind<bool>("Generic", "TwoHandedRifle", false, "(Default false) If true, changes the rifle to a two-handed item.").Value;
			teslaSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn", "TeslaGateWeight", 1f, "(Default 1) Sets the spawn weight for the Tesla Gate.").Value;
			revolverRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "RevolverRarity", 20, "(Default 20) Sets the spawn rarity for the Revolver.").Value;
			revolverAmmoRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "RevolverAmmoRarity", 60, "(Default 60) Sets the spawn rarity for the Revolver ammo.").Value;
			revolverPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "RevolverPrice", -1, "(Recommended -1 or 550) Set the price of the Revolver. If -1, removes the item from the store list.").Value;
			revolverAmmoPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "RevolverAmmoPrice", -1, "(Recommended -1 or 30) Set the price of the Revolver ammo. If -1, removes the item from the store list.").Value;
			riflePrice = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "RiflePrice", -1, "(Recommended -1 or 1,000~) Set the price of the Rifle (M4A1). If -1, removes the item from the store list.").Value;
			rifleMagPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "RifleMagPrice", -1, "(Recommended -1 or 400~) Set the price of the Rifle magazine. If -1, removes the item from the store list.").Value;
			rifleRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "RifleRarity", 20, "(Default 20) Sets the spawn rarity for the Rifle.").Value;
			rifleMagRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "RifleMagRarity", 60, "(Default 60) Sets the spawn rarity for the Rifle magazine.").Value;
			bulbRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "BulbRarity", 30, "(Default 30) Sets the spawn rarity for the Bulb.").Value;
			chemicalRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "ChemicalRarity", 30, "(Default 30) Sets the spawn rarity for the Chemical.").Value;
			translateKorean = ((BaseUnityPlugin)this).Config.Bind<bool>("Translation", "Enable Korean", false, "Set language to Korean.").Value;
			NetworkPrefabs.RegisterNetworkPrefab(teslaGatePrefab);
			NetworkPrefabs.RegisterNetworkPrefab(revolverItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(revolverAmmoItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(gummyFlashlight.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(arItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(arMagItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(axeItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(bulbItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(chemicalItem.spawnPrefab);
			Utilities.FixMixerGroups(revolverItem.spawnPrefab);
			Utilities.FixMixerGroups(revolverAmmoItem.spawnPrefab);
			Utilities.FixMixerGroups(gummyFlashlight.spawnPrefab);
			Utilities.FixMixerGroups(arItem.spawnPrefab);
			Utilities.FixMixerGroups(arMagItem.spawnPrefab);
			Utilities.FixMixerGroups(axeItem.spawnPrefab);
			Utilities.FixMixerGroups(bulbItem.spawnPrefab);
			Utilities.FixMixerGroups(chemicalItem.spawnPrefab);
			Items.RegisterItem(revolverItem);
			Items.RegisterItem(revolverAmmoItem);
			Items.RegisterItem(gummyFlashlight);
			Items.RegisterItem(arItem);
			Items.RegisterItem(arMagItem);
			Items.RegisterItem(axeItem);
			Items.RegisterItem(bulbItem);
			Items.RegisterItem(chemicalItem);
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				BepInPlugin metadata = pluginInfo.Value.Metadata;
				if (metadata.GUID.Equals("MoreEmotes", StringComparison.OrdinalIgnoreCase) || metadata.GUID.Equals("BetterEmotes", StringComparison.OrdinalIgnoreCase))
				{
					foundMoreEmotes = true;
					mls.LogInfo((object)"[Piggys Variety Mod] Detected More Emotes / Better Emotes!");
					mls.LogInfo((object)"[Piggys Variety Mod] More Emotes / Better Emotes may not be compatible!");
				}
			}
			if (translateKorean)
			{
				Translate();
			}
			CreateShopItem();
			Items.RegisterScrap(revolverItem, revolverRarity, (LevelTypes)(-1));
			Items.RegisterScrap(revolverAmmoItem, revolverAmmoRarity, (LevelTypes)(-1));
			Items.RegisterScrap(arItem, rifleRarity, (LevelTypes)(-1));
			Items.RegisterScrap(arMagItem, rifleMagRarity, (LevelTypes)(-1));
			Items.RegisterScrap(bulbItem, bulbRarity, (LevelTypes)(-1));
			Items.RegisterScrap(chemicalItem, chemicalRarity, (LevelTypes)(-1));
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}

		private void LoadAssets()
		{
			try
			{
				Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PluginDirectory), "piggyvarietymod"));
			}
			catch (Exception ex)
			{
				mls.LogError((object)("Couldn't load asset bundle: " + ex.Message));
				return;
			}
			try
			{
				teslaGateSpawn = Bundle.LoadAsset<GameObject>("TeslaGateSpawn.prefab");
				teslaGatePrefab = Bundle.LoadAsset<GameObject>("TeslaGate.prefab");
				teslaGatePrefab.AddComponent<TeslaGate>();
				teslaCrack = Bundle.LoadAsset<AudioClip>("Tesla_Crack.ogg");
				teslaBeep = Bundle.LoadAsset<AudioClip>("Tesla_Beeps.ogg");
				teslaWindUp = Bundle.LoadAsset<AudioClip>("Tesla_WindUp.ogg");
				teslaUnderbass = Bundle.LoadAsset<AudioClip>("Tesla_Underbass.ogg");
				teslaClimax = Bundle.LoadAsset<AudioClip>("Tesla_Climax.ogg");
				teslaIdleStart = Bundle.LoadAsset<AudioClip>("Tesla_IdleStarts.ogg");
				teslaIdle = Bundle.LoadAsset<AudioClip>("Tesla_IdleLoop.ogg");
				teslaIdleEnd = Bundle.LoadAsset<AudioClip>("Tesla_IdleEnd.ogg");
				flashlightShake = Bundle.LoadAsset<AudioClip>("FlashlightShake.wav");
				gummylightClick = Bundle.LoadAsset<AudioClip>("GummyFlashlightClick.wav");
				gummylightOutage = Bundle.LoadAsset<AudioClip>("GummylightBatteryOutage.wav");
				flashFlicker = Bundle.LoadAsset<AudioClip>("FlashlightFlicker.ogg");
				flashlightBulb = Bundle.LoadAsset<Material>("FlashlightBulb1.mat");
				blackRubber = Bundle.LoadAsset<Material>("BlackRubber1.mat");
				Plugin.revolverItem = Bundle.LoadAsset<Item>("Revolver.asset");
				revolverAmmoItem = Bundle.LoadAsset<Item>("RevolverAmmo.asset");
				arItem = Bundle.LoadAsset<Item>("M4A1.asset");
				arMagItem = Bundle.LoadAsset<Item>("Magazine.asset");
				Plugin.axeItem = Bundle.LoadAsset<Item>("Axe.asset");
				gummyFlashlight = Bundle.LoadAsset<Item>("GummyFlashlight.asset");
				chemicalItem = Bundle.LoadAsset<Item>("Chemical.asset");
				bulbItem = Bundle.LoadAsset<Item>("Bulb.asset");
				gummylightPrefab = Bundle.LoadAsset<GameObject>("GummylightItem.prefab");
				m4Prefab = Bundle.LoadAsset<GameObject>("M4Item.prefab");
				axePrefab = Bundle.LoadAsset<GameObject>("AxeItem.prefab");
				revolverAmmoInsert = Bundle.LoadAsset<AudioClip>("RevolverReload.wav");
				revolverCylinderOpen = Bundle.LoadAsset<AudioClip>("RevolverCylinderOpen.wav");
				revolverCylinderClose = Bundle.LoadAsset<AudioClip>("RevolverCylinderClose.wav");
				revolverDryFire = Bundle.LoadAsset<AudioClip>("RevolverDryFire.wav");
				revolverBlast1 = Bundle.LoadAsset<AudioClip>("RevolverBlast1.wav");
				revolverBlast2 = Bundle.LoadAsset<AudioClip>("RevolverBlast2.wav");
				m4FireClip = Bundle.LoadAsset<AudioClip>("M4Fire1.wav");
				m4InspectClip = Bundle.LoadAsset<AudioClip>("InspectM4v2.wav");
				m4TriggerClip = Bundle.LoadAsset<AudioClip>("M4Trigger.wav");
				m4ReloadClip = Bundle.LoadAsset<AudioClip>("M4Reload.wav");
				playerAnimator = Bundle.LoadAsset<RuntimeAnimatorController>("PlayerAnimator.controller");
				otherPlayerAnimator = Bundle.LoadAsset<RuntimeAnimatorController>("OtherPlayerAnimator.controller");
				RevolverItem revolverItem = Plugin.revolverItem.spawnPrefab.AddComponent<RevolverItem>();
				((GrabbableObject)revolverItem).grabbable = true;
				((GrabbableObject)revolverItem).grabbableToEnemies = true;
				revolverItem.gunReloadSFX = revolverAmmoInsert;
				revolverItem.cylinderOpenSFX = revolverCylinderOpen;
				revolverItem.cylinderCloseSFX = revolverCylinderClose;
				revolverItem.gunShootSFX.Add(revolverBlast1);
				revolverItem.gunShootSFX.Add(revolverBlast2);
				revolverItem.noAmmoSFX = revolverDryFire;
				revolverItem.gunSafetySFX = revolverDryFire;
				revolverItem.switchSafetyOffSFX = revolverDryFire;
				revolverItem.switchSafetyOnSFX = revolverDryFire;
				revolverItem.gunAudio = ((Component)revolverItem).gameObject.GetComponent<AudioSource>();
				revolverItem.gunShootAudio = ((Component)((Component)revolverItem).gameObject.transform.GetChild(1)).GetComponent<AudioSource>();
				revolverItem.gunBulletsRicochetAudio = ((Component)((Component)revolverItem).gameObject.transform.GetChild(2)).GetComponent<AudioSource>();
				revolverItem.gunAnimator = ((Component)revolverItem).gameObject.GetComponent<Animator>();
				revolverItem.revolverRayPoint = ((Component)revolverItem).gameObject.transform.GetChild(3);
				revolverItem.gunShootParticle = ((Component)((Component)revolverItem).gameObject.transform.GetChild(3).GetChild(0)).GetComponent<ParticleSystem>();
				revolverItem.cylinderTransform = ((Component)revolverItem).gameObject.transform.GetChild(5).GetChild(0).GetChild(0);
				revolverItem.revolverAmmos.Add(((Component)((Component)revolverItem).gameObject.transform.GetChild(5).GetChild(0).GetChild(0)
					.GetChild(0)).GetComponent<MeshRenderer>());
				revolverItem.revolverAmmos.Add(((Component)((Component)revolverItem).gameObject.transform.GetChild(5).GetChild(0).GetChild(0)
					.GetChild(1)).GetComponent<MeshRenderer>());
				revolverItem.revolverAmmos.Add(((Component)((Component)revolverItem).gameObject.transform.GetChild(5).GetChild(0).GetChild(0)
					.GetChild(2)).GetComponent<MeshRenderer>());
				revolverItem.revolverAmmos.Add(((Component)((Component)revolverItem).gameObject.transform.GetChild(5).GetChild(0).GetChild(0)
					.GetChild(3)).GetComponent<MeshRenderer>());
				revolverItem.revolverAmmos.Add(((Component)((Component)revolverItem).gameObject.transform.GetChild(5).GetChild(0).GetChild(0)
					.GetChild(4)).GetComponent<MeshRenderer>());
				revolverItem.revolverAmmos.Add(((Component)((Component)revolverItem).gameObject.transform.GetChild(5).GetChild(0).GetChild(0)
					.GetChild(5)).GetComponent<MeshRenderer>());
				revolverItem.revolverAmmoInHandTransform = ((Component)revolverItem).gameObject.transform.GetChild(0);
				revolverItem.revolverAmmoInHand = ((Component)((Component)revolverItem).gameObject.transform.GetChild(0).GetChild(0)).GetComponent<MeshRenderer>();
				revolverItem.gunCompatibleAmmoID = 500;
				((GrabbableObject)revolverItem).itemProperties = Plugin.revolverItem;
				arItem.spawnPrefab = m4Prefab;
				M4Item m4Item = arItem.spawnPrefab.AddComponent<M4Item>();
				((GrabbableObject)m4Item).grabbable = true;
				((GrabbableObject)m4Item).isInFactory = true;
				((GrabbableObject)m4Item).itemProperties = arItem;
				((GrabbableObject)m4Item).grabbableToEnemies = true;
				m4Item.gunCompatibleAmmoID = 485;
				m4Item.gunAnimator = ((Component)m4Item).gameObject.GetComponent<Animator>();
				m4Item.gunAudio = ((Component)m4Item).gameObject.GetComponent<AudioSource>();
				m4Item.gunShootAudio = ((Component)((Component)m4Item).transform.GetChild(0)).GetComponent<AudioSource>();
				m4Item.gunBulletsRicochetAudio = ((Component)((Component)m4Item).transform.GetChild(1)).GetComponent<AudioSource>();
				m4Item.gunShootSFX = m4FireClip;
				m4Item.gunReloadSFX = m4ReloadClip;
				m4Item.gunInspectSFX = m4InspectClip;
				m4Item.noAmmoSFX = m4TriggerClip;
				m4Item.gunShootParticle = ((Component)((Component)m4Item).transform.GetChild(5).GetChild(0)).GetComponent<ParticleSystem>();
				m4Item.gunRayPoint = ((Component)m4Item).transform.GetChild(5);
				if (twoHandedRifle)
				{
					arItem.twoHanded = true;
				}
				gummyFlashlight.spawnPrefab = gummylightPrefab;
				GummylightItem gummylightItem = gummyFlashlight.spawnPrefab.AddComponent<GummylightItem>();
				((GrabbableObject)gummylightItem).useCooldown = 0.12f;
				((GrabbableObject)gummylightItem).itemProperties = gummyFlashlight;
				((GrabbableObject)gummylightItem).mainObjectRenderer = ((Component)((Component)gummylightItem).transform.GetChild(2)).GetComponent<MeshRenderer>();
				((GrabbableObject)gummylightItem).insertedBattery.charge = 1f;
				((GrabbableObject)gummylightItem).grabbableToEnemies = true;
				gummylightItem.flashlightBulb = ((Component)((Component)gummylightItem).transform.GetChild(0)).GetComponent<Light>();
				gummylightItem.flashlightBulbGlow = ((Component)((Component)gummylightItem).transform.GetChild(1)).GetComponent<Light>();
				gummylightItem.flashlightAudio = ((Component)gummylightItem).GetComponent<AudioSource>();
				gummylightItem.flashlightClips = (AudioClip[])(object)new AudioClip[1] { gummylightClick };
				gummylightItem.outOfBatteriesClip = gummylightOutage;
				gummylightItem.flashlightFlicker = flashFlicker;
				gummylightItem.bulbLight = flashlightBulb;
				gummylightItem.bulbDark = blackRubber;
				gummylightItem.flashlightMesh = ((Component)((Component)gummylightItem).transform.GetChild(2)).GetComponent<MeshRenderer>();
				gummylightItem.changeMaterial = true;
				((GrabbableObject)gummylightItem).isInFactory = true;
				((GrabbableObject)gummylightItem).grabbable = true;
				gummylightItem.flashlightTypeID = 10;
				Object.Destroy((Object)(object)gummyFlashlight.spawnPrefab.GetComponent<FlashlightItem>());
				Plugin.axeItem.spawnPrefab = axePrefab;
				AxeItem axeItem = Plugin.axeItem.spawnPrefab.AddComponent<AxeItem>();
				Shovel component = Plugin.axeItem.spawnPrefab.GetComponent<Shovel>();
				((GrabbableObject)axeItem).itemProperties = Plugin.axeItem;
				((GrabbableObject)axeItem).grabbable = true;
				((GrabbableObject)axeItem).isInFactory = true;
				((GrabbableObject)axeItem).grabbableToEnemies = true;
				axeItem.shovelHitForce = 1;
				axeItem.reelUp = component.reelUp;
				axeItem.swing = component.swing;
				axeItem.hitSFX = component.hitSFX;
				axeItem.shovelAudio = component.shovelAudio;
				Object.Destroy((Object)(object)component);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded assets!");
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Couldn't load assets: " + ex2.Message));
			}
		}

		private void Translate()
		{
			revolverItem.toolTips[0] = "격발 : [RMB]";
			revolverItem.toolTips[1] = "탄약 삽탄하기 : [E]";
			revolverItem.toolTips[2] = "실린더 열기 : [Q]";
			gummyFlashlight.toolTips[0] = "전등 전환하기 : [RMB]";
			gummyFlashlight.toolTips[1] = "손전등 흔들기 : [Q]";
			arItem.toolTips[0] = "격발 : [RMB]";
			arItem.toolTips[1] = "재장전 : [E]";
			arItem.toolTips[2] = "탄약 확인하기 : [Q]";
			axeItem.toolTips[0] = "도끼 휘두르기 : [RMB]";
			revolverItem.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = "리볼버";
			revolverAmmoItem.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = "총알";
			arItem.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = "소총";
			arMagItem.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = "탄창";
			bulbItem.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = "전구";
			chemicalItem.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = "화학 약품";
		}

		private void CreateShopItem()
		{
			if (translateKorean)
			{
				revolverAmmoItem.itemName = "총알";
				revolverItem.itemName = "리볼버";
				gummyFlashlight.itemName = "젤리";
				arMagItem.itemName = "탄창";
				arItem.itemName = "소총";
				axeItem.itemName = "도끼";
				chemicalItem.itemName = "화학 약품";
				bulbItem.itemName = "전구";
			}
			else
			{
				revolverAmmoItem.itemName = "Bullet";
				revolverItem.itemName = "Revolver";
				gummyFlashlight.itemName = "Gummy flashlight";
				arMagItem.itemName = "Magazine";
				arItem.itemName = "Rifle";
				axeItem.itemName = "Axe";
			}
			TerminalNode val = NewTerminalNode("리볼버를 주문하려고 합니다. 수량: [variableAmount]. \r\n아이템의 총 가격: [totalCost].\n\nCONFIRM 또는 DENY를 입력하세요.\n\n", "You have requested to order revolvers. Amount: [variableAmount]. \r\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n");
			TerminalNode val2 = NewTerminalNode("[variableAmount]개의 리볼버를 주문했습니다. 당신의 현재 소지금은 [playerCredits]입니다.\n\n우리의 계약자는 작업 중에도 빠른 무료 배송 혜택을 누릴 수 있습니다! 구매한 모든 상품은 1시간마다 대략적인 위치에 도착합니다.\n\n", "Ordered [variableAmount] revolvers. Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\n\n");
			TerminalNode val3 = NewTerminalNode("\n더욱 강력한 자기 보호를 위해!\n실린더를 열고 리볼버 탄약을 삽탄하여 장전하세요.\n\n", "\nFor more powerful self-defense!\nOpen the cylinder and insert revolver ammo to load it.\n\n");
			TerminalNode val4 = NewTerminalNode("리볼버 탄약을 주문하려고 합니다. 수량: [variableAmount]. \r\n아이템의 총 가격: [totalCost].\n\nCONFIRM 또는 DENY를 입력하세요.\n\n", "You have requested to order revolver ammos. Amount: [variableAmount]. \r\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n");
			TerminalNode val5 = NewTerminalNode("[variableAmount]개의 리볼버 탄약을 주문했습니다. 당신의 현재 소지금은 [playerCredits]입니다.\n\n우리의 계약자는 작업 중에도 빠른 무료 배송 혜택을 누릴 수 있습니다! 구매한 모든 상품은 1시간마다 대략적인 위치에 도착합니다.\n\n", "Ordered [variableAmount] revolver ammos. Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\n\n");
			TerminalNode val6 = NewTerminalNode("\n리볼버에 장전하고 <b>치명적인</b> 순간에 격발하세요!\n\n", "\nLoad to your revolver and fire at LETHAL moments!\n\n");
			TerminalNode val7 = NewTerminalNode("소총을 주문하려고 합니다. 수량: [variableAmount]. \r\n아이템의 총 가격: [totalCost].\n\nCONFIRM 또는 DENY를 입력하세요.\n\n", "You have requested to order rifles. Amount: [variableAmount]. \r\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n");
			TerminalNode val8 = NewTerminalNode("[variableAmount]개의 소총을 주문했습니다. 당신의 현재 소지금은 [playerCredits]입니다.\n\n우리의 계약자는 작업 중에도 빠른 무료 배송 혜택을 누릴 수 있습니다! 구매한 모든 상품은 1시간마다 대략적인 위치에 도착합니다.\n\n", "Ordered [variableAmount] rifles. Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\n\n");
			TerminalNode val9 = NewTerminalNode("\n더욱 강력한 자기 보호를 위해!\n탄창을 장전하여 사용하세요.\n\n", "\nFor more powerful self-defense!\nload magazine to fire it.\n\n");
			TerminalNode val10 = NewTerminalNode("소총 탄창을 주문하려고 합니다. 수량: [variableAmount]. \r\n아이템의 총 가격: [totalCost].\n\nCONFIRM 또는 DENY를 입력하세요.\n\n", "You have requested to order rifle magazines. Amount: [variableAmount]. \r\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n");
			TerminalNode val11 = NewTerminalNode("[variableAmount]개의 소총 탄창을 주문했습니다. 당신의 현재 소지금은 [playerCredits]입니다.\n\n우리의 계약자는 작업 중에도 빠른 무료 배송 혜택을 누릴 수 있습니다! 구매한 모든 상품은 1시간마다 대략적인 위치에 도착합니다.\n\n", "Ordered [variableAmount] rifle magazines. Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\n\n");
			TerminalNode val12 = NewTerminalNode("\n소총에 장전하고 <b>치명적인</b> 순간에 격발하세요!\n\n", "\nLoad to your rifle and fire at LETHAL moments!\n\n");
			TerminalNode val13 = NewTerminalNode("젤리 손전등을 주문하려고 합니다. 수량: [variableAmount]. \r\n아이템의 총 가격: [totalCost].\n\nCONFIRM 또는 DENY를 입력하세요.\n\n", "You have requested to order gummy flashlights. Amount: [variableAmount]. \r\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n");
			TerminalNode val14 = NewTerminalNode("[variableAmount]개의 젤리 손전등을 주문했습니다. 당신의 현재 소지금은 [playerCredits]입니다.\n\n우리의 계약자는 작업 중에도 빠른 무료 배송 혜택을 누릴 수 있습니다! 구매한 모든 상품은 1시간마다 대략적인 위치에 도착합니다.\n\n", "Ordered [variableAmount] gummy flashlights. Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\n\n");
			TerminalNode val15 = NewTerminalNode("\n자가발전 손전등입니다.\n그저 평범한 장난감이지만, 배터리가 다 떨어졌을 때 여러분의 어두운 앞길을 비춰 줄 것입니다!\n\n", "\nA self-powered flashlight.\nIt's just a toy, but it'll light up your dark path when the batteries run out!\n\n");
			if (revolverPrice > -1)
			{
				Items.RegisterShopItem(revolverItem, val, val2, val3, revolverPrice);
			}
			if (revolverAmmoPrice > -1)
			{
				Items.RegisterShopItem(revolverAmmoItem, val4, val5, val6, revolverAmmoPrice);
			}
			if (riflePrice > -1)
			{
				Items.RegisterShopItem(arItem, val7, val8, val9, riflePrice);
			}
			if (rifleMagPrice > -1)
			{
				Items.RegisterShopItem(arMagItem, val10, val11, val12, rifleMagPrice);
			}
		}

		public TerminalNode NewTerminalNode(string korean, string english)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			if (translateKorean)
			{
				val.displayText = korean;
			}
			else
			{
				val.displayText = english;
			}
			val.clearPreviousText = true;
			val.maxCharactersToType = 15;
			val.buyRerouteToMoon = -1;
			val.displayPlanetInfo = -1;
			val.shipUnlockableID = -1;
			val.creatureFileID = -1;
			val.storyLogFileID = -1;
			return val;
		}
	}
}
namespace PiggyVarietyMod.Patches
{
	public class CustomTouchInteractTrigger : MonoBehaviour
	{
		public bool isIdleTrigger;

		public bool isKillTrigger;

		public TeslaGate teslaGate;

		private void OnTriggerEnter(Collider collider)
		{
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB component = ((Component)collider).GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null)
			{
				Plugin.mls.LogInfo((object)("Tesla gate detected player: " + component.playerUsername + ", Idle: " + isIdleTrigger + ", Kill: " + isKillTrigger));
				if (!component.isPlayerDead)
				{
					if (isIdleTrigger)
					{
						teslaGate.activatePlayerList.Add(component);
						teslaGate.activateList.Add(((Component)collider).gameObject);
					}
					else if (!isIdleTrigger && !isKillTrigger)
					{
						teslaGate.engagingPlayerList.Add(component);
						teslaGate.engagingList.Add(((Component)collider).gameObject);
					}
				}
			}
			EnemyAICollisionDetect component2 = ((Component)collider).GetComponent<EnemyAICollisionDetect>();
			IHittable val = default(IHittable);
			if ((Object)(object)component2 != (Object)null && ((Component)((Component)component2).transform).TryGetComponent<IHittable>(ref val))
			{
				Plugin.mls.LogInfo((object)("Tesla gate detected enemy: " + component2.mainScript.enemyType.enemyName + ", Idle: " + isIdleTrigger + ", Kill: " + isKillTrigger));
				if (isIdleTrigger)
				{
				}
				if (isKillTrigger && (Object)(object)component2 != (Object)null && (Object)(object)component2.mainScript != (Object)null && ((NetworkBehaviour)component2.mainScript).IsOwner && component2.mainScript.enemyType.canDie && !component2.mainScript.isEnemyDead)
				{
					val.Hit(5, Vector3.zero, (PlayerControllerB)null, true, -1);
				}
			}
		}

		private void OnTriggerStay(Collider collider)
		{
			//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)
			//IL_0061: 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 (!isKillTrigger)
			{
				return;
			}
			PlayerControllerB component = ((Component)collider).GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController && !component.isPlayerDead)
			{
				GameNetworkManager.Instance.localPlayerController.KillPlayer(Vector3.down * 17f, true, (CauseOfDeath)11, 0, default(Vector3));
				return;
			}
			EnemyAICollisionDetect component2 = ((Component)collider).GetComponent<EnemyAICollisionDetect>();
			if ((Object)(object)component2 != (Object)null && (Object)(object)component2.mainScript != (Object)null && ((NetworkBehaviour)component2.mainScript).IsOwner && component2.mainScript.enemyType.canDie && !component2.mainScript.isEnemyDead)
			{
				component2.mainScript.KillEnemyOnOwnerClient(false);
			}
		}

		private void OnTriggerExit(Collider collider)
		{
			PlayerControllerB component = ((Component)collider).GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null)
			{
				teslaGate.engagingPlayerList.Remove(component);
				teslaGate.engagingList.Remove(((Component)collider).gameObject);
				if (isIdleTrigger)
				{
					teslaGate.activatePlayerList.Remove(component);
					teslaGate.activateList.Remove(((Component)collider).gameObject);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Dungeon))]
	internal class DungeonPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SpawnDoorPrefab")]
		private static void SpawnDoorPrefab_Prefix(Doorway a, Doorway b, RandomStream randomStream)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			for (int i = 0; i < a.ConnectorPrefabWeights.Count; i++)
			{
				GameObjectWeight val = a.ConnectorPrefabWeights[i];
				if (((Object)val.GameObject).name == "TeslaGateSpawn")
				{
					return;
				}
				if (((Object)val.GameObject).name == "BigDoorSpawn")
				{
					GameObjectWeight val2 = new GameObjectWeight();
					a.ConnectorPrefabWeights.Add(val2);
					val2.Weight = 0.05f * Plugin.teslaSpawnWeight;
					val2.GameObject = Plugin.teslaGateSpawn;
					Plugin.mls.LogInfo((object)("added tesla to " + ((Object)((Component)a).gameObject).name));
				}
			}
			for (int j = 0; j < b.ConnectorPrefabWeights.Count; j++)
			{
				GameObjectWeight val3 = b.ConnectorPrefabWeights[j];
				if (((Object)val3.GameObject).name == "TeslaGateSpawn")
				{
					break;
				}
				if (((Object)val3.GameObject).name == "BigDoorSpawn")
				{
					GameObjectWeight val4 = new GameObjectWeight();
					b.ConnectorPrefabWeights.Add(val4);
					val4.Weight = 0.07f * Plugin.teslaSpawnWeight;
					val4.GameObject = Plugin.teslaGateSpawn;
					Plugin.mls.LogInfo((object)("added tesla to " + ((Object)((Component)b).gameObject).name));
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		public static AnimationClip middleFinger;

		public static AnimationClip middleFinger_D;

		public static AnimationClip clap;

		public static AnimationClip clap_D;

		public static AnimationClip shy;

		public static AnimationClip griddy;

		public static AnimationClip twerk;

		public static AnimationClip salute;

		public static AnimationClip prisyadka;

		public static AnimationClip sign;

		public static AnimationClip sign_D;

		private static bool pv_isPlayerFirstFrame;

		private static void UpdateAnimator(PlayerControllerB __instance, Animator ___playerBodyAnimator)
		{
		}

		private static void UpdateMoreEmotesAnimator(PlayerControllerB __instance, Animator ___playerBodyAnimator)
		{
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			if ((Object)(object)middleFinger == (Object)null || (Object)(object)middleFinger_D == (Object)null || (((Object)(object)clap == (Object)null) | ((Object)(object)clap_D == (Object)null)) || (((Object)(object)shy == (Object)null) | ((Object)(object)griddy == (Object)null)) || (Object)(object)twerk == (Object)null || (Object)(object)salute == (Object)null || (Object)(object)prisyadka == (Object)null || (Object)(object)sign == (Object)null || (Object)(object)sign_D == (Object)null)
			{
				GetMoreEmotes(___playerBodyAnimator.runtimeAnimatorController);
			}
			if (!((Object)(object)___playerBodyAnimator.runtimeAnimatorController != (Object)(object)Plugin.playerAnimator) || !((Object)(object)___playerBodyAnimator.runtimeAnimatorController != (Object)(object)Plugin.otherPlayerAnimator))
			{
				return;
			}
			if ((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				if ((Object)(object)middleFinger != (Object)null && (Object)(object)middleFinger_D != (Object)null && (Object)(object)clap != (Object)null && (Object)(object)clap_D != (Object)null && (Object)(object)shy != (Object)null && (Object)(object)griddy != (Object)null && (Object)(object)twerk != (Object)null && (Object)(object)salute != (Object)null && (Object)(object)prisyadka != (Object)null && (Object)(object)sign != (Object)null && (Object)(object)sign_D != (Object)null)
				{
					if (!(__instance.playerBodyAnimator.runtimeAnimatorController is AnimatorOverrideController))
					{
						__instance.playerBodyAnimator.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(__instance.playerBodyAnimator.runtimeAnimatorController);
					}
					__instance.SpawnPlayerAnimation();
					UpdateAnimatorVariable(Plugin.playerAnimator);
					EmotePatch.local = Plugin.playerAnimator;
					Plugin.mls.LogInfo((object)"Replace More Emotes Animator!");
				}
			}
			else if ((Object)(object)middleFinger != (Object)null && (Object)(object)middleFinger_D != (Object)null && (Object)(object)clap != (Object)null && (Object)(object)clap_D != (Object)null && (Object)(object)shy != (Object)null && (Object)(object)griddy != (Object)null && (Object)(object)twerk != (Object)null && (Object)(object)salute != (Object)null && (Object)(object)prisyadka != (Object)null && (Object)(object)sign != (Object)null && (Object)(object)sign_D != (Object)null)
			{
				UpdateAnimatorVariable(Plugin.otherPlayerAnimator);
				EmotePatch.others = Plugin.otherPlayerAnimator;
				Plugin.mls.LogInfo((object)"Replace More Emotes Other Animator!");
				if (!(__instance.playerBodyAnimator.runtimeAnimatorController is AnimatorOverrideController))
				{
					__instance.playerBodyAnimator.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(__instance.playerBodyAnimator.runtimeAnimatorController);
				}
			}
		}

		private static void OnFirstLocalPlayerFrameWithNewAnimator(PlayerControllerB __instance)
		{
			pv_isPlayerFirstFrame = false;
			__instance.SpawnPlayerAnimation();
		}

		private static void GetMoreEmotes(RuntimeAnimatorController animator)
		{
			AnimationClip[] animationClips = animator.animationClips;
			foreach (AnimationClip val in animationClips)
			{
				if ((Object)(object)middleFinger == (Object)null && ((Object)val).name == "Middle_Finger")
				{
					middleFinger = val;
				}
				if ((Object)(object)middleFinger_D == (Object)null && ((Object)val).name == "D_Middle_Finger")
				{
					middleFinger_D = val;
				}
				if ((Object)(object)clap == (Object)null && ((Object)val).name == "Clap")
				{
					clap = val;
				}
				if ((Object)(object)clap_D == (Object)null && ((Object)val).name == "D_Clap")
				{
					clap_D = val;
				}
				if ((Object)(object)shy == (Object)null && ((Object)val).name == "Shy")
				{
					shy = val;
				}
				if ((Object)(object)griddy == (Object)null && ((Object)val).name == "The_Griddy")
				{
					griddy = val;
				}
				if ((Object)(object)twerk == (Object)null && ((Object)val).name == "Twerk")
				{
					twerk = val;
				}
				if ((Object)(object)salute == (Object)null && ((Object)val).name == "Salute")
				{
					salute = val;
				}
				if ((Object)(object)prisyadka == (Object)null && ((Object)val).name == "Prisyadka")
				{
					prisyadka = val;
				}
				if ((Object)(object)sign == (Object)null && ((Object)val).name == "Sign")
				{
					sign = val;
				}
				if ((Object)(object)sign_D == (Object)null && ((Object)val).name == "D_Sign")
				{
					sign_D = val;
				}
			}
		}

		private static void UpdateAnimatorVariable(RuntimeAnimatorController animator)
		{
			AnimationClip[] animationClips = animator.animationClips;
			for (int i = 0; i < animationClips.Length; i++)
			{
				switch (((Object)animationClips[i]).name)
				{
				case "Middle_Finger":
					animationClips[i] = middleFinger;
					break;
				case "D_Middle_Finger":
					animationClips[i] = middleFinger_D;
					break;
				case "Clap":
					animationClips[i] = clap;
					break;
				case "D_Clap":
					animationClips[i] = clap_D;
					break;
				case "Shy":
					animationClips[i] = shy;
					break;
				case "The_Griddy":
					animationClips[i] = griddy;
					break;
				case "Twerk":
					animationClips[i] = twerk;
					break;
				case "Salute":
					animationClips[i] = salute;
					break;
				case "Prisyadka":
					animationClips[i] = prisyadka;
					break;
				case "Sign":
					animationClips[i] = sign;
					break;
				case "D_Sign":
					animationClips[i] = sign_D;
					break;
				}
			}
		}
	}
	public class GummylightItem : GrabbableObject
	{
		[Space(15f)]
		public bool usingPlayerHelmetLight;

		public int flashlightInterferenceLevel;

		public static int globalFlashlightInterferenceLevel;

		public Light flashlightBulb;

		public Light flashlightBulbGlow;

		public AudioSource flashlightAudio;

		public AudioClip[] flashlightClips;

		public AudioClip outOfBatteriesClip;

		public AudioClip flashlightFlicker;

		public Material bulbLight;

		public Material bulbDark;

		public MeshRenderer flashlightMesh;

		public int flashlightTypeID;

		public bool changeMaterial = true;

		private float initialIntensity;

		private PlayerControllerB previousPlayerHeldBy;

		public override void Start()
		{
			base.useCooldown = 0.12f;
			base.itemProperties = Plugin.gummyFlashlight;
			base.mainObjectRenderer = ((Component)((Component)this).transform.GetChild(2)).GetComponent<MeshRenderer>();
			base.insertedBattery.charge = 1f;
			base.grabbableToEnemies = true;
			flashlightBulb = ((Component)((Component)this).transform.GetChild(0)).GetComponent<Light>();
			flashlightBulbGlow = ((Component)((Component)this).transform.GetChild(1)).GetComponent<Light>();
			flashlightAudio = ((Component)this).GetComponent<AudioSource>();
			flashlightClips = (AudioClip[])(object)new AudioClip[1] { Plugin.gummylightClick };
			outOfBatteriesClip = Plugin.gummylightOutage;
			flashlightFlicker = Plugin.flashFlicker;
			bulbLight = Plugin.flashlightBulb;
			bulbDark = Plugin.blackRubber;
			flashlightMesh = ((Component)((Component)this).transform.GetChild(2)).GetComponent<MeshRenderer>();
			changeMaterial = true;
			base.isInFactory = true;
			base.grabbable = true;
			flashlightTypeID = 0;
			Object.Destroy((Object)(object)((Component)this).GetComponent<FlashlightItem>());
			((GrabbableObject)this).Start();
			initialIntensity = flashlightBulb.intensity;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (flashlightInterferenceLevel < 2)
			{
				SwitchFlashlight(used);
			}
			flashlightAudio.PlayOneShot(flashlightClips[Random.Range(0, flashlightClips.Length)]);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 7f, 0.4f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
		}

		public override void UseUpBatteries()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).UseUpBatteries();
			SwitchFlashlight(on: false);
			flashlightAudio.PlayOneShot(outOfBatteriesClip, 1f);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 13f, 0.65f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
		}

		public override void PocketItem()
		{
			previousPlayerHeldBy.equippedUsableItemQE = false;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				((GrabbableObject)this).PocketItem();
				return;
			}
			if ((Object)(object)previousPlayerHeldBy != (Object)null)
			{
				((Behaviour)flashlightBulb).enabled = false;
				((Behaviour)flashlightBulbGlow).enabled = false;
				if (base.isBeingUsed && ((Object)(object)previousPlayerHeldBy.ItemSlots[previousPlayerHeldBy.currentItemSlot] == (Object)null || previousPlayerHeldBy.ItemSlots[previousPlayerHeldBy.currentItemSlot].itemProperties.itemId != 1 || previousPlayerHeldBy.ItemSlots[previousPlayerHeldBy.currentItemSlot].itemProperties.itemId != 6))
				{
					((Behaviour)previousPlayerHeldBy.helmetLight).enabled = true;
					previousPlayerHeldBy.pocketedFlashlight = (GrabbableObject)(object)this;
					usingPlayerHelmetLight = true;
					PocketFlashlightServerRpc(stillUsingFlashlight: true);
				}
				else
				{
					base.isBeingUsed = false;
					usingPlayerHelmetLight = false;
					((Behaviour)flashlightBulbGlow).enabled = false;
					SwitchFlashlight(on: false);
					PocketFlashlightServerRpc();
				}
			}
			else
			{
				Debug.Log((object)"Could not find what player was holding this flashlight item");
			}
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.equippedUsableItemQE = false;
			}
			((GrabbableObject)this).PocketItem();
		}

		[ServerRpc]
		public void PocketFlashlightServerRpc(bool stillUsingFlashlight = false)
		{
			PocketFlashlightClientRpc(stillUsingFlashlight);
		}

		[ClientRpc]
		public void PocketFlashlightClientRpc(bool stillUsingFlashlight)
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			((Behaviour)flashlightBulb).enabled = false;
			((Behaviour)flashlightBulbGlow).enabled = false;
			if (stillUsingFlashlight)
			{
				if (!((Object)(object)previousPlayerHeldBy == (Object)null))
				{
					((Behaviour)previousPlayerHeldBy.helmetLight).enabled = true;
					previousPlayerHeldBy.pocketedFlashlight = (GrabbableObject)(object)this;
					usingPlayerHelmetLight = true;
				}
			}
			else
			{
				base.isBeingUsed = false;
				usingPlayerHelmetLight = false;
				((Behaviour)flashlightBulbGlow).enabled = false;
				SwitchFlashlight(on: false);
			}
		}

		public override void DiscardItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.equippedUsableItemQE = false;
			}
			if ((Object)(object)previousPlayerHeldBy != (Object)null)
			{
				((Behaviour)previousPlayerHeldBy.helmetLight).enabled = false;
				((Behaviour)flashlightBulb).enabled = base.isBeingUsed;
				((Behaviour)flashlightBulbGlow).enabled = base.isBeingUsed;
			}
			((GrabbableObject)this).DiscardItem();
		}

		public override void EquipItem()
		{
			previousPlayerHeldBy = base.playerHeldBy;
			base.playerHeldBy.equippedUsableItemQE = true;
			base.playerHeldBy.ChangeHelmetLight(flashlightTypeID, true);
			((Behaviour)base.playerHeldBy.helmetLight).enabled = false;
			usingPlayerHelmetLight = false;
			if (base.isBeingUsed)
			{
				SwitchFlashlight(on: true);
			}
			((GrabbableObject)this).EquipItem();
		}

		public void SwitchFlashlight(bool on)
		{
			base.isBeingUsed = on;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				Debug.Log((object)$"Flashlight click. playerheldby null?: {(Object)(object)base.playerHeldBy != (Object)null}");
				Debug.Log((object)$"Flashlight being disabled or enabled: {on}");
				if ((Object)(object)base.playerHeldBy != (Object)null)
				{
					base.playerHeldBy.ChangeHelmetLight(flashlightTypeID, on);
				}
				((Behaviour)flashlightBulb).enabled = false;
				((Behaviour)flashlightBulbGlow).enabled = false;
			}
			else
			{
				((Behaviour)flashlightBulb).enabled = on;
				((Behaviour)flashlightBulbGlow).enabled = on;
			}
			if (usingPlayerHelmetLight && (Object)(object)base.playerHeldBy != (Object)null)
			{
				((Behaviour)base.playerHeldBy.helmetLight).enabled = on;
			}
			if (changeMaterial)
			{
				Material[] sharedMaterials = ((Renderer)flashlightMesh).sharedMaterials;
				if (on)
				{
					sharedMaterials[1] = bulbLight;
				}
				else
				{
					sharedMaterials[1] = bulbDark;
				}
				((Renderer)flashlightMesh).sharedMaterials = sharedMaterials;
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			int num = ((flashlightInterferenceLevel <= globalFlashlightInterferenceLevel) ? globalFlashlightInterferenceLevel : flashlightInterferenceLevel);
			if (num >= 2)
			{
				flashlightBulb.intensity = 0f;
			}
			else if (num == 1)
			{
				flashlightBulb.intensity = Random.Range(0f, 200f);
			}
			else
			{
				flashlightBulb.intensity = initialIntensity;
			}
		}

		public override void ItemInteractLeftRight(bool right)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"r/l activate: {right}");
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (!right && (Object)(object)base.playerHeldBy != (Object)null)
			{
				flashlightAudio.PlayOneShot(Plugin.flashlightShake);
				WalkieTalkie.TransmitOneShotAudio(flashlightAudio, Plugin.flashlightShake, 1f);
				base.playerHeldBy.playerBodyAnimator.SetTrigger("shakeItem");
				float num = base.insertedBattery.charge * 100f + 8f;
				if (num <= 100f)
				{
					base.insertedBattery = new Battery(false, num * 0.01f);
					((GrabbableObject)this).SyncBatteryServerRpc((int)num);
				}
				else
				{
					base.insertedBattery = new Battery(false, num * 0.01f);
					((GrabbableObject)this).SyncBatteryServerRpc(100);
				}
				if (((NetworkBehaviour)this).IsOwner)
				{
					RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 5f, 0.2f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 941);
				}
			}
		}
	}
	public class M4Item : GrabbableObject
	{
		public static Dictionary<ulong, RuntimeAnimatorController> playerAnimatorDictionary = new Dictionary<ulong, RuntimeAnimatorController>();

		private bool isCrouching;

		private bool isJumping;

		private bool isWalking;

		private bool isSprinting;

		private AnimatorStateInfo currentStateInfo;

		private float currentAnimationTime;

		public int gunCompatibleAmmoID = 1410;

		public bool isReloading;

		public bool isInspecting;

		public bool cantFire;

		public bool isFiring;

		public int ammosLoaded;

		public Animator gunAnimator;

		public AudioSource gunAudio;

		public AudioSource gunShootAudio;

		public AudioSource gunBulletsRicochetAudio;

		private Coroutine gunCoroutine;

		public AudioClip gunShootSFX;

		public AudioClip gunReloadSFX;

		public AudioClip gunInspectSFX;

		public AudioClip noAmmoSFX;

		private bool hasHitGroundWithSafetyOff = true;

		private int ammoSlotToUse = -1;

		private bool localClientSendingShootGunRPC;

		private PlayerControllerB previousPlayerHeldBy;

		public ParticleSystem gunShootParticle;

		public Transform gunRayPoint;

		private RaycastHit[] enemyColliders;

		private RaycastHit[] playerColliders;

		private EnemyAI heldByEnemy;

		public override void Start()
		{
			((GrabbableObject)this).Start();
		}

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			return ammosLoaded;
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			ammosLoaded = saveData;
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (!isInspecting && isFiring && !isReloading && !cantFire && (Object)(object)base.playerHeldBy != (Object)null && !base.playerHeldBy.playerBodyAnimator.GetBool("ReloadM4") && ammosLoaded > 0)
			{
				ShootGunAndSync(heldByPlayer: true);
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			previousPlayerHeldBy = base.playerHeldBy;
			previousPlayerHeldBy.equippedUsableItemQE = true;
			hasHitGroundWithSafetyOff = false;
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				UpdateAnimator(base.playerHeldBy, base.playerHeldBy.playerBodyAnimator, restore: false);
			}
			if (Plugin.translateKorean)
			{
				KR_SetAmmoControlTip(isChecking: false);
			}
			else
			{
				SetAmmoControlTip(isChecking: false);
			}
		}

		public override void GrabItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				UpdateAnimator(base.playerHeldBy, base.playerHeldBy.playerBodyAnimator, restore: false);
			}
			((GrabbableObject)this).GrabItem();
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
			heldByEnemy = enemy;
			hasHitGroundWithSafetyOff = false;
		}

		public override void DiscardItemFromEnemy()
		{
			((GrabbableObject)this).DiscardItemFromEnemy();
			heldByEnemy = null;
		}

		public override void ItemActivate(bool used, bool buttonDown = false)
		{
			Debug.Log((object)buttonDown);
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			isFiring = buttonDown;
			if (!isInspecting && !isReloading && !cantFire && !base.playerHeldBy.playerBodyAnimator.GetBool("ReloadM4") && ammosLoaded <= 0)
			{
				gunAudio.PlayOneShot(noAmmoSFX);
			}
		}

		public void ShootGunAndSync(bool heldByPlayer)
		{
			//IL_003a: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			Vector3 gunPosition;
			Vector3 forward;
			if (!heldByPlayer)
			{
				gunPosition = gunRayPoint.position;
				forward = gunRayPoint.forward;
			}
			else
			{
				gunPosition = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position - ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.up * 0.45f;
				forward = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.forward;
			}
			ShootGun(gunPosition, forward);
		}

		[ServerRpc(RequireOwnership = false)]
		public void ShootGunServerRpc(Vector3 gunPosition, Vector3 gunForward)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			ShootGunClientRpc(gunPosition, gunForward);
		}

		[ClientRpc]
		public void ShootGunClientRpc(Vector3 gunPosition, Vector3 gunForward)
		{
			//IL_002e: 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)
			Debug.Log((object)"Shoot gun client rpc received");
			if (localClientSendingShootGunRPC)
			{
				localClientSendingShootGunRPC = false;
				Debug.Log((object)"localClientSendingShootGunRPC was true");
			}
			else
			{
				ShootGun(gunPosition, gunForward);
			}
		}

		public IEnumerator FireDelay()
		{
			cantFire = true;
			yield return (object)new WaitForSeconds(0.07f);
			cantFire = false;
		}

		public void ShootGun(Vector3 gunPosition, Vector3 gunForward)
		{
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Unknown result type (might be due to invalid IL or missing references)
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.translateKorean)
			{
				KR_SetAmmoControlTip(isChecking: false);
			}
			else
			{
				SetAmmoControlTip(isChecking: false);
			}
			CentipedeAI[] array = Object.FindObjectsByType<CentipedeAI>((FindObjectsSortMode)0);
			FlowerSnakeEnemy[] array2 = Object.FindObjectsByType<FlowerSnakeEnemy>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i].clingingToPlayer == (Object)(object)base.playerHeldBy)
				{
					((EnemyAI)array[i]).HitEnemy(2, base.playerHeldBy, true, -1);
				}
			}
			for (int j = 0; j < array2.Length; j++)
			{
				if ((Object)(object)array2[j].clingingToPlayer == (Object)(object)base.playerHeldBy)
				{
					((EnemyAI)array2[j]).HitEnemy(2, base.playerHeldBy, true, -1);
				}
			}
			((MonoBehaviour)this).StartCoroutine(FireDelay());
			bool flag = false;
			if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				base.playerHeldBy.playerBodyAnimator.SetTrigger("ShootM4");
				flag = true;
			}
			gunAnimator.SetTrigger("Fire");
			gunShootAudio.PlayOneShot(gunShootSFX);
			WalkieTalkie.TransmitOneShotAudio(gunShootAudio, gunShootSFX, 1f);
			gunShootParticle.Play(true);
			ammosLoaded = Mathf.Clamp(ammosLoaded - 1, 0, 30);
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				return;
			}
			float num = Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)gunRayPoint).transform.position);
			bool flag2 = false;
			int num2 = 0;
			float num3 = 0f;
			Vector3 val = localPlayerController.playerCollider.ClosestPoint(gunPosition);
			if (!flag && !Physics.Linecast(gunPosition, val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && Vector3.Angle(gunForward, val - gunPosition) < 30f)
			{
				flag2 = true;
			}
			if (num < 12f)
			{
				num3 = 0.25f;
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
				num2 = 100;
			}
			Ray val2 = default(Ray);
			((Ray)(ref val2))..ctor(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((Component)base.playerHeldBy.gameplayCamera).transform.forward);
			if (enemyColliders == null)
			{
				enemyColliders = (RaycastHit[])(object)new RaycastHit[35];
			}
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((Component)base.playerHeldBy.gameplayCamera).transform.forward, ref val3, float.PositiveInfinity, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				((Component)gunBulletsRicochetAudio).transform.position = ((Ray)(ref val2)).GetPoint(((RaycastHit)(ref val3)).distance - 0.5f);
				gunBulletsRicochetAudio.Play();
			}
			if ((Object)(object)base.playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				int num4 = Physics.SphereCastNonAlloc(val2, 0.25f, enemyColliders, float.PositiveInfinity, 524288, (QueryTriggerInteraction)2);
				IHittable val4 = default(IHittable);
				for (int k = 0; k < num4; k++)
				{
					Debug.Log((object)"Raycasting enemy");
					if (!Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref enemyColliders[k])).transform).GetComponent<EnemyAICollisionDetect>()))
					{
						continue;
					}
					EnemyAI mainScript = ((Component)((RaycastHit)(ref enemyColliders[k])).transform).GetComponent<EnemyAICollisionDetect>().mainScript;
					if ((Object)(object)heldByEnemy != (Object)null && (Object)(object)heldByEnemy == (Object)(object)mainScript)
					{
						Debug.Log((object)"Rifle is held by enemy, skipping enemy raycast");
						continue;
					}
					Debug.Log((object)("Hit enemy " + mainScript.enemyType.enemyName));
					if (((RaycastHit)(ref enemyColliders[k])).distance == 0f)
					{
						Debug.Log((object)"Spherecast started inside enemy collider");
					}
					else if (Physics.Linecast(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((RaycastHit)(ref enemyColliders[k])).point, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
					{
						Debug.DrawRay(((RaycastHit)(ref val3)).point, Vector3.up, Color.red, 15f);
						Debug.DrawLine(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((RaycastHit)(ref enemyColliders[k])).point, Color.cyan, 15f);
						Plugin.mls.LogInfo((object)("Raycast hit wall: " + ((Object)((Component)((RaycastHit)(ref val3)).collider).gameObject).name + ", distance: " + ((RaycastHit)(ref val3)).distance));
					}
					else if (((Component)((RaycastHit)(ref enemyColliders[k])).transform).TryGetComponent<IHittable>(ref val4))
					{
						Vector3 forward = ((Component)base.playerHeldBy.gameplayCamera).transform.forward;
						float num5 = Vector3.Distance(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((RaycastHit)(ref enemyColliders[k])).point);
						Plugin.mls.LogInfo((object)("Damage to enemy, damage: " + Plugin.rifleMonsterDamage + ", distance:" + num5));
						val4.Hit(Plugin.rifleMonsterDamage, forward, base.playerHeldBy, true, -1);
					}
					else
					{
						Plugin.mls.LogInfo((object)("Could not get hittable script from collider, transform: " + ((Object)((RaycastHit)(ref enemyColliders[k])).transform).name));
					}
				}
			}
			if (playerColliders == null)
			{
				playerColliders = (RaycastHit[])(object)new RaycastHit[10];
			}
			int num6 = Physics.SphereCastNonAlloc(val2, 0.3f, playerColliders, float.PositiveInfinity, StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers, (QueryTriggerInteraction)2);
			for (int l = 0; l < num6; l++)
			{
				if ((Object)(object)((Component)((RaycastHit)(ref playerColliders[l])).transform).GetComponent<PlayerControllerB>() != (Object)null && (Object)(object)((Component)((RaycastHit)(ref playerColliders[l])).transform).GetComponent<PlayerControllerB>() != (Object)(object)base.playerHeldBy)
				{
					float num7 = Vector3.Distance(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((RaycastHit)(ref playerColliders[l])).point);
					if (num7 < 10f)
					{
						((Component)((RaycastHit)(ref playerColliders[l])).transform).GetComponent<PlayerControllerB>().DamagePlayer(Plugin.rifleMaxPlayerDamage, true, true, (CauseOfDeath)7, 0, false, ((Component)base.playerHeldBy.gameplayCamera).transform.forward * 30f);
					}
					else if (num7 < 25f)
					{
						((Component)((RaycastHit)(ref playerColliders[l])).transform).GetComponent<PlayerControllerB>().DamagePlayer(Mathf.RoundToInt((float)(Plugin.rifleMaxPlayerDamage - Plugin.rifleMaxPlayerDamage / 3)), true, true, (CauseOfDeath)7, 0, false, ((Component)base.playerHeldBy.gameplayCamera).transform.forward * 30f);
					}
					else
					{
						((Component)((RaycastHit)(ref playerColliders[l])).transform).GetComponent<PlayerControllerB>().DamagePlayer(Mathf.RoundToInt((float)(Plugin.rifleMaxPlayerDamage / 3)), true, true, (CauseOfDeath)7, 0, false, ((Component)base.playerHeldBy.gameplayCamera).transform.forward * 30f);
					}
					Debug.Log((object)"Rifle vs Player why COD");
				}
			}
		}

		private IEnumerator delayedEarsRinging(float effectSeverity)
		{
			yield return (object)new WaitForSeconds(0.25f);
			SoundManager.Instance.earsRingingTimer = effectSeverity;
		}

		public override void ItemInteractLeftRight(bool right)
		{
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (!((Object)(object)base.playerHeldBy == (Object)null))
			{
				Debug.Log((object)$"r/l activate: {right}");
				if (!right)
				{
					StartCheckMagazine();
				}
				else if (!isInspecting && !isReloading && ammosLoaded < 30)
				{
					StartReloadGun();
				}
			}
		}

		private void StartReloadGun()
		{
			if ((Plugin.customGunInfinityAmmo || ReloadedGun()) && !isReloading)
			{
				((MonoBehaviour)this).StartCoroutine(ReloadGunAnimation());
			}
			else
			{
				gunAudio.PlayOneShot(noAmmoSFX);
			}
		}

		private void StartCheckMagazine()
		{
			if (!isInspecting)
			{
				((MonoBehaviour)this).StartCoroutine(CheckAmmoGunAnimation());
			}
			else
			{
				gunAudio.PlayOneShot(noAmmoSFX);
			}
		}

		private IEnumerator CheckAmmoGunAnimation()
		{
			base.playerHeldBy.playerBodyAnimator.SetTrigger("InspectM4");
			isInspecting = true;
			gunAudio.PlayOneShot(gunInspectSFX);
			if ((Object)(object)base.playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				WalkieTalkie.TransmitOneShotAudio(gunAudio, gunInspectSFX, 1f);
			}
			yield return (object)new WaitForSeconds(1f);
			if (Plugin.translateKorean)
			{
				KR_SetAmmoControlTip(isChecking: true);
			}
			else
			{
				SetAmmoControlTip(isChecking: true);
			}
			yield return (object)new WaitForSeconds(1f);
			isInspecting = false;
		}

		private void SetAmmoControlTip(bool isChecking)
		{
			string text = "Check ammo : [Q]";
			if (ammosLoaded == 30)
			{
				text = (isChecking ? "Check ammo : [Q] [Full]" : "Check ammo : [Q] [??]");
			}
			else if (ammosLoaded >= 20 && 30 > ammosLoaded)
			{
				text = (isChecking ? "Check ammo : [Q] [<30]" : "Check ammo : [Q] [??]");
			}
			else if (ammosLoaded >= 10 && 20 > ammosLoaded)
			{
				text = (isChecking ? "Check ammo : [Q] [<20]" : "Check ammo : [Q] [??]");
			}
			else if (ammosLoaded >= 1 && 10 > ammosLoaded)
			{
				text = (isChecking ? "Check ammo : [Q] [<10]" : "Check ammo : [Q] [??]");
			}
			else if (ammosLoaded <= 0)
			{
				text = (isChecking ? "Check ammo : [Q] [Empty]" : "Check ammo : [Q] [??]");
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				HUDManager.Instance.ChangeControlTip(3, text, false);
			}
		}

		private void KR_SetAmmoControlTip(bool isChecking)
		{
			string text = "탄약 확인하기 : [Q]";
			if (ammosLoaded == 30)
			{
				text = (isChecking ? "탄약 확인하기 : [Q] [가득 참]" : "탄약 확인하기 : [Q] [??]");
			}
			else if (ammosLoaded >= 20 && 30 > ammosLoaded)
			{
				text = (isChecking ? "탄약 확인하기 : [Q] [<30]" : "탄약 확인하기 : [Q] [??]");
			}
			else if (ammosLoaded >= 10 && 20 > ammosLoaded)
			{
				text = (isChecking ? "탄약 확인하기 : [Q] [<20]" : "탄약 확인하기 : [Q] [??]");
			}
			else if (ammosLoaded >= 1 && 10 > ammosLoaded)
			{
				text = (isChecking ? "탄약 확인하기 : [Q] [<10]" : "탄약 확인하기 : [Q] [??]");
			}
			else if (ammosLoaded <= 0)
			{
				text = (isChecking ? "탄약 확인하기 : [Q] [비어 있음]" : "탄약 확인하기 : [Q] [??]");
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				HUDManager.Instance.ChangeControlTip(3, text, false);
			}
		}

		private IEnumerator ReloadGunAnimation()
		{
			base.playerHeldBy.playerBodyAnimator.SetTrigger("ReloadM4");
			gunAnimator.SetTrigger("Reloading");
			isReloading = true;
			gunAudio.PlayOneShot(gunReloadSFX);
			if ((Object)(object)base.playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				WalkieTalkie.TransmitOneShotAudio(gunAudio, gunReloadSFX, 1f);
			}
			yield return (object)new WaitForSeconds(2f);
			if (isReloading)
			{
				if ((Object)(object)base.playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController && !Plugin.customGunInfinityAmmo)
				{
					base.playerHeldBy.DestroyItemInSlotAndSync(ammoSlotToUse);
				}
				ammoSlotToUse = -1;
				ammosLoaded = 30;
				if (Plugin.translateKorean)
				{
					KR_SetAmmoControlTip(isChecking: true);
				}
				else
				{
					SetAmmoControlTip(isChecking: true);
				}
			}
			yield return (object)new WaitForSeconds(0.55f);
			isReloading = false;
		}

		private bool ReloadedGun()
		{
			int num = FindAmmoInInventory();
			if (num == -1)
			{
				Debug.Log((object)"not reloading");
				return false;
			}
			Debug.Log((object)"reloading!");
			ammoSlotToUse = num;
			return true;
		}

		private int FindAmmoInInventory()
		{
			for (int i = 0; i < base.playerHeldBy.ItemSlots.Length; i++)
			{
				if (!((Object)(object)base.playerHeldBy.ItemSlots[i] == (Object)null))
				{
					GrabbableObject obj = base.playerHeldBy.ItemSlots[i];
					GunAmmo val = (GunAmmo)(object)((obj is GunAmmo) ? obj : null);
					Debug.Log((object)$"Ammo null in slot #{i}?: {(Object)(object)val == (Object)null}");
					if ((Object)(object)val != (Object)null)
					{
						Debug.Log((object)$"Ammo in slot #{i} id: {val.ammoType}");
					}
					if ((Object)(object)val != (Object)null && val.ammoType == gunCompatibleAmmoID)
					{
						return i;
					}
				}
			}
			return -1;
		}

		public override void PocketItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				UpdateAnimator(base.playerHeldBy, base.playerHeldBy.playerBodyAnimator, restore: true);
			}
			((GrabbableObject)this).PocketItem();
			StopUsingGun();
		}

		public override void DiscardItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				UpdateAnimator(base.playerHeldBy, base.playerHeldBy.playerBodyAnimator, restore: true);
			}
			((GrabbableObject)this).DiscardItem();
			StopUsingGun();
		}

		private void StopUsingGun()
		{
			previousPlayerHeldBy.equippedUsableItemQE = false;
			if (gunCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(gunCoroutine);
			}
			gunAudio.Stop();
			isReloading = false;
			previousPlayerHeldBy.playerBodyAnimator.SetTrigger("SwitchHoldAnimation");
			gunAnimator.SetTrigger("Reset");
			isInspecting = false;
		}

		private void UpdateAnimator(PlayerControllerB player, Animator playerBodyAnimator, bool restore)
		{
			if (!restore)
			{
				if ((Object)(object)playerBodyAnimator.runtimeAnimatorController != (Object)(object)Plugin.playerAnimator && (Object)(object)playerBodyAnimator.runtimeAnimatorController != (Object)(object)Plugin.otherPlayerAnimator)
				{
					if ((Object)(object)player == (Object)(object)StartOfRound.Instance.localPlayerController)
					{
						SaveAnimatorStates(playerBodyAnimator);
						playerBodyAnimator.runtimeAnimatorController = Plugin.playerAnimator;
						RestoreAnimatorStates(playerBodyAnimator);
						Plugin.mls.LogInfo((object)"Replace Player Animator!");
					}
					else
					{
						SaveAnimatorStates(playerBodyAnimator);
						playerBodyAnimator.runtimeAnimatorController = Plugin.otherPlayerAnimator;
						RestoreAnimatorStates(playerBodyAnimator);
						Plugin.mls.LogInfo((object)"Replace Other Player Animator!");
					}
				}
			}
			else if (playerAnimatorDictionary.ContainsKey(player.playerClientId))
			{
				playerBodyAnimator.runtimeAnimatorController = playerAnimatorDictionary[player.playerClientId];
				playerAnimatorDictionary.Remove(player.playerClientId);
				Plugin.mls.LogInfo((object)"Restored Player Animator!");
			}
		}

		private void SaveAnimatorStates(Animator animator)
		{
			//IL_0048: 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)
			isCrouching = animator.GetBool("crouching");
			isJumping = animator.GetBool("Jumping");
			isWalking = animator.GetBool("Walking");
			isSprinting = animator.GetBool("Sprinting");
			currentStateInfo = animator.GetCurrentAnimatorStateInfo(0);
			currentAnimationTime = ((AnimatorStateInfo)(ref currentStateInfo)).normalizedTime;
		}

		public void RestoreAnimatorStates(Animator animator)
		{
			animator.Play(((AnimatorStateInfo)(ref currentStateInfo)).fullPathHash, 0, currentAnimationTime);
			animator.SetBool("crouching", isCrouching);
			animator.SetBool("Jumping", isJumping);
			animator.SetBool("Walking", isWalking);
			animator.SetBool("Sprinting", isSprinting);
		}
	}
	public class RevolverItem : GrabbableObject
	{
		public static Dictionary<ulong, RuntimeAnimatorController> playerAnimatorDictionary = new Dictionary<ulong, RuntimeAnimatorController>();

		private bool isCrouching;

		private bool isJumping;

		private bool isWalking;

		private bool isSprinting;

		private AnimatorStateInfo currentStateInfo;

		private float currentAnimationTime;

		public int gunCompatibleAmmoID = 1410;

		public bool isReloading;

		public bool cantFire;

		public Transform cylinderTransform;

		public bool isCylinderMoving;

		public int ammosLoaded;

		public Animator gunAnimator;

		public AudioSource gunAudio;

		public AudioSource gunShootAudio;

		public AudioSource gunBulletsRicochetAudio;

		private Coroutine gunCoroutine;

		public List<AudioClip> gunShootSFX = new List<AudioClip>();

		public AudioClip gunReloadSFX;

		public AudioClip cylinderOpenSFX;

		public AudioClip cylinderCloseSFX;

		public AudioClip gunReloadFinishSFX;

		public AudioClip noAmmoSFX;

		public AudioClip gunSafetySFX;

		public AudioClip switchSafetyOnSFX;

		public AudioClip switchSafetyOffSFX;

		private bool hasHitGroundWithSafetyOff = true;

		private int ammoSlotToUse = -1;

		private bool localClientSendingShootGunRPC;

		private PlayerControllerB previousPlayerHeldBy;

		public ParticleSystem gunShootParticle;

		public Transform revolverRayPoint;

		public List<MeshRenderer> revolverAmmos = new List<MeshRenderer>();

		public MeshRenderer revolverAmmoInHand;

		public Transform revolverAmmoInHandTransform;

		private RaycastHit[] enemyColliders;

		private RaycastHit[] playerColliders;

		private EnemyAI heldByEnemy;

		public override void Start()
		{
			((GrabbableObject)this).Start();
		}

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			return ammosLoaded;
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			ammosLoaded = saveData;
		}

		public override void Update()
		{
			//IL_0055: 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)
			//IL_006e: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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)
			//IL_00df: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (!isReloading)
			{
				switch (ammosLoaded)
				{
				case 0:
					cylinderTransform.localRotation = Quaternion.Lerp(cylinderTransform.localRotation, Quaternion.Euler(new Vector3(0f, 0f, 0f)), Time.deltaTime * 25f);
					break;
				case 1:
					cylinderTransform.localRotation = Quaternion.Lerp(cylinderTransform.localRotation, Quaternion.Euler(new Vector3(0f, 60f, 0f)), Time.deltaTime * 25f);
					break;
				case 2:
					cylinderTransform.localRotation = Quaternion.Lerp(cylinderTransform.localRotation, Quaternion.Euler(new Vector3(0f, 120f, 0f)), Time.deltaTime * 25f);
					break;
				case 3:
					cylinderTransform.localRotation = Quaternion.Lerp(cylinderTransform.localRotation, Quaternion.Euler(new Vector3(0f, 180f, 0f)), Time.deltaTime * 25f);
					break;
				case 4:
					cylinderTransform.localRotation = Quaternion.Lerp(cylinderTransform.localRotation, Quaternion.Euler(new Vector3(0f, 240f, 0f)), Time.deltaTime * 25f);
					break;
				case 5:
					cylinderTransform.localRotation = Quaternion.Lerp(cylinderTransform.localRotation, Quaternion.Euler(new Vector3(0f, 300f, 0f)), Time.deltaTime * 25f);
					break;
				case 6:
					cylinderTransform.localRotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));
					break;
				}
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			SyncRevolverAmmoServerRpc(ammosLoaded);
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				UpdateAnimator(base.playerHeldBy, base.playerHeldBy.playerBodyAnimator, restore: false);
			}
			base.playerHeldBy.playerBodyAnimator.SetBool("ReloadRevolver", false);
			gunAnimator.SetBool("Reloading", false);
			((Renderer)revolverAmmoInHand).enabled = false;
			previousPlayerHeldBy = base.playerHeldBy;
			previousPlayerHeldBy.equippedUsableItemQE = true;
			isCylinderMoving = false;
			hasHitGroundWithSafetyOff = false;
			foreach (MeshRenderer revolverAmmo in revolverAmmos)
			{
				((Renderer)revolverAmmo).enabled = false;
			}
			if (ammosLoaded > 0)
			{
				for (int i = 0; i <= ammosLoaded - 1; i++)
				{
					((Renderer)revolverAmmos[i]).enabled = true;
				}
			}
		}

		public override void GrabItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				UpdateAnimator(base.playerHeldBy, base.playerHeldBy.playerBodyAnimator, restore: false);
			}
			((GrabbableObject)this).GrabItem();
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
			heldByEnemy = enemy;
			hasHitGroundWithSafetyOff = false;
		}

		public override void DiscardItemFromEnemy()
		{
			((GrabbableObject)this).DiscardItemFromEnemy();
			heldByEnemy = null;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			SyncRevolverAmmoServerRpc(ammosLoaded);
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!isReloading && !cantFire && !gunAnimator.GetBool("Reloading"))
			{
				if (ammosLoaded > 0)
				{
					gunAnimator.SetBool("Reloading", false);
					ShootGunAndSync(heldByPlayer: true);
				}
				else
				{
					((MonoBehaviour)this).StartCoroutine(FireDelay());
					gunAnimator.SetTrigger("Fire");
					gunAudio.PlayOneShot(noAmmoSFX);
				}
			}
		}

		public void ShootGunAndSync(bool heldByPlayer)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			Vector3 revolverPosition;
			Vector3 forward;
			if (!heldByPlayer)
			{
				revolverPosition = revolverRayPoint.position;
				forward = revolverRayPoint.forward;
			}
			else
			{
				revolverPosition = ((Component)base.playerHeldBy.gameplayCamera).transform.position - ((Component)base.playerHeldBy.gameplayCamera).transform.up * 0.45f;
				forward = ((Component)base.playerHeldBy.gameplayCamera).transform.forward;
			}
			ShootGun(revolverPosition, forward);
		}

		public IEnumerator FireDelay()
		{
			cantFire = true;
			yield return (object)new WaitForSeconds(0.2f);
			cantFire = false;
		}

		public void ShootGun(Vector3 revolverPosition, Vector3 revolverForward)
		{
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_080d: Unknown result type (might be due to invalid IL or missing references)
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0876: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0928: Unknown result type (might be due to invalid IL or missing references)
			//IL_0932: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			CentipedeAI[] array = Object.FindObjectsByType<CentipedeAI>((FindObjectsSortMode)0);
			FlowerSnakeEnemy[] array2 = Object.FindObjectsByType<FlowerSnakeEnemy>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i].clingingToPlayer == (Object)(object)base.playerHeldBy)
				{
					((EnemyAI)array[i]).HitEnemy(5, base.playerHeldBy, true, -1);
				}
			}
			for (int j = 0; j < array2.Length; j++)
			{
				if ((Object)(object)array2[j].clingingToPlayer == (Object)(object)base.playerHeldBy)
				{
					((EnemyAI)array2[j]).HitEnemy(5, base.playerHeldBy, true, -1);
				}
			}
			((MonoBehaviour)this).StartCoroutine(FireDelay());
			bool flag = false;
			if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				base.playerHeldBy.playerBodyAnimator.SetTrigger("ShootRevolver");
				flag = true;
			}
			gunAnimator.SetTrigger("Fire");
			RoundManager.PlayRandomClip(gunShootAudio, gunShootSFX.ToArray(), true, 1f, 1840, 1000);
			WalkieTalkie.TransmitOneShotAudio(gunShootAudio, gunShootSFX[0], 1f);
			gunShootParticle.Play(true);
			ammosLoaded = Mathf.Clamp(ammosLoaded - 1, 0, 6);
			foreach (MeshRenderer revolverAmmo in revolverAmmos)
			{
				((Renderer)revolverAmmo).enabled = false;
			}
			if (ammosLoaded > 0)
			{