Decompiled source of Piggys Variety Mod v1.4.1

PiggyVarietyMod.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using PiggyVarietyMod.NetcodePatcher;
using PiggyVarietyMod.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PiggyVarietyMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PiggyVarietyMod")]
[assembly: AssemblyTitle("PiggyVarietyMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PiggyVarietyMod
{
	[BepInPlugin("Piggy.PiggyVarietyMod", "PiggyVarietyMod", "1.3.19")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Piggy.PiggyVarietyMod";

		private const string modName = "PiggyVarietyMod";

		private const string modVersion = "1.3.19";

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

		private static Plugin Instance;

		public static ManualLogSource mls;

		public static AssetBundle Bundle;

		internal static PVInputActions InputActionInstance = new PVInputActions();

		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 axeRarity;

		public static int axePrice;

		public static int bulbRarity;

		public static int chemicalRarity;

		public static int gummyLightRarity;

		public static int gummyLightPrice;

		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 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;
			gummyLightRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "GummylightAmmoRarity", 0, "(Default 0) Sets the spawn rarity for the Gummy flashlight.").Value;
			axeRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "AxeRarity", 0, "(Default 0) Sets the spawn rarity for the Axe.").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;
			gummyLightPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "GummylightAmmoPrice", 30, "(Recommended 30) Set the price of the Gummy flashlight. 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;
			axePrice = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "AxePrice", 45, "(Recommended 45) Set the price of the Axe. If -1, removes the item from the store list.").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);
			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));
			Items.RegisterScrap(gummyFlashlight, gummyLightRarity, (LevelTypes)(-1));
			Items.RegisterScrap(axeItem, axeRarity, (LevelTypes)(-1));
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				try
				{
					MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					MethodInfo[] array = methods;
					foreach (MethodInfo methodInfo in array)
					{
						object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
						if (customAttributes.Length != 0)
						{
							methodInfo.Invoke(null, null);
						}
					}
				}
				catch
				{
					mls.LogInfo((object)"Skipping Netcode Class");
				}
			}
			mls.LogInfo((object)"Netcode Successfully Patched!");
		}

		private void LoadAssets()
		{
			//IL_0788: Unknown result type (might be due to invalid IL or missing references)
			//IL_0792: Expected O, but got Unknown
			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 = new Battery(false, 1f);
				((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.axeHitForce = 2;
				axeItem.reelUp = component.reelUp;
				axeItem.swing = component.swing;
				axeItem.hitSFX = component.hitSFX;
				axeItem.axeAudio = 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");
			TerminalNode val16 = NewTerminalNode("도끼 주문을 요청하셨습니다. 수량: [variableAmount]. \r\n아이템의 총 가격: [totalCost].\n\nCONFIRM 또는 DENY를 입력하세요.\n\n", "You have requested to order Axe. Amount: [variableAmount]. \r\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n");
			TerminalNode val17 = NewTerminalNode("[variableAmount] 도끼를 주문했습니다. 새 잔액은 [playerCredits]입니다.\n\n우리의 계약자는 작업 중에도 빠른 무료 배송 혜택을 누릴 수 있습니다! 구매한 모든 상품은 1시간마다 대략적인 위치에 도착합니다.\n\n", "Ordered [variableAmount] Axe. 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 val18 = NewTerminalNode("\n그냥 도끼입니다.\n방어 도구로 사용 가능\n\n", "\nJust an Axe.\nUsable as a defense tool\n\n");
			if (revolverPrice > -1)
			{
				Items.RegisterShopItem(revolverItem, val, val2, val3, revolverPrice);
			}
			if (revolverAmmoPrice > -1)
			{
				Items.RegisterShopItem(revolverAmmoItem, val4, val5, val6, revolverAmmoPrice);
			}
			if (gummyLightPrice > -1)
			{
				Items.RegisterShopItem(gummyFlashlight, val13, val14, val15, gummyLightPrice);
			}
			if (riflePrice > -1)
			{
				Items.RegisterShopItem(arItem, val7, val8, val9, riflePrice);
			}
			if (rifleMagPrice > -1)
			{
				Items.RegisterShopItem(arMagItem, val10, val11, val12, rifleMagPrice);
			}
			if (rifleMagPrice > -1)
			{
				Items.RegisterShopItem(arMagItem, val10, val11, val12, rifleMagPrice);
			}
			if (axePrice > -1)
			{
				Items.RegisterShopItem(axeItem, val16, val17, val18, axePrice);
			}
		}

		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;
		}
	}
	public class PVInputActions : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction RifleReloadKey { get; set; }
	}
}
namespace PiggyVarietyMod.Patches
{
	public class AxeItem : GrabbableObject
	{
		public int axeHitForce = 2;

		public bool reelingUp;

		public bool isHoldingButton;

		private Coroutine reelingUpCoroutine;

		private RaycastHit[] objectsHitByAxe;

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

		public AudioClip reelUp;

		public AudioClip swing;

		public AudioClip[] hitSFX;

		public AudioSource axeAudio;

		private PlayerControllerB previousPlayerHeldBy;

		private int axeMask = 11012424;

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

		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 AXE. 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(reelUpAxe());
			}
		}

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

		[ServerRpc]
		public void ReelUpSFXServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3261452617u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3261452617u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ReelUpSFXClientRpc();
			}
		}

		[ClientRpc]
		public void ReelUpSFXClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1978901185u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1978901185u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
				{
					axeAudio.PlayOneShot(reelUp);
				}
			}
		}

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

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

		public void HitAxe(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 HitAxe is called.");
				return;
			}
			previousPlayerHeldBy.activatingItem = false;
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			int num = -1;
			if (!cancel)
			{
				previousPlayerHeldBy.twoHanded = false;
				objectsHitByAxe = Physics.SphereCastAll(((Component)previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)previousPlayerHeldBy.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward, 1.5f, axeMask, (QueryTriggerInteraction)2);
				objectsHitByAxeList = objectsHitByAxe.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 < objectsHitByAxeList.Count; i++)
				{
					Vector3 forward = ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward;
					RaycastHit val = objectsHitByAxeList[i];
					if (((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
					{
						val = objectsHitByAxeList[i];
						if (!((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform))
						{
							val = objectsHitByAxeList[i];
							if (!(((RaycastHit)(ref val)).point == Vector3.zero))
							{
								Vector3 position = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
								val = objectsHitByAxeList[i];
								if (Physics.Linecast(position, ((RaycastHit)(ref val)).point, ref val3, StartOfRound.Instance.walkableSurfacesMask, (QueryTriggerInteraction)1))
								{
									goto IL_0221;
								}
							}
							val = objectsHitByAxeList[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 = objectsHitByAxeList[i];
					if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 8)
					{
						val = objectsHitByAxeList[i];
						if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 11)
						{
							val = objectsHitByAxeList[i];
							if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
							{
								continue;
							}
							val = objectsHitByAxeList[i];
							if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform)
							{
								continue;
							}
							val = objectsHitByAxeList[i];
							if (!(((RaycastHit)(ref val)).point == Vector3.zero))
							{
								Vector3 position2 = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
								val = objectsHitByAxeList[i];
								if (Physics.Linecast(position2, ((RaycastHit)(ref val)).point, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
								{
									continue;
								}
							}
							flag = true;
							try
							{
								val = objectsHitByAxeList[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 = objectsHitByAxeList[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(axeHitForce, 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 axe from player #{previousPlayerHeldBy.playerClientId}: {arg}");
							}
							continue;
						}
					}
					val = objectsHitByAxeList[i];
					if (((RaycastHit)(ref val)).collider.isTrigger)
					{
						continue;
					}
					flag = true;
					val = objectsHitByAxeList[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(axeAudio, hitSFX, true, 1f, 0, 1000);
				Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)this).transform.position, 17f, 0.8f, 0, false, 0);
				if (!flag2 && num != -1)
				{
					axeAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX);
					WalkieTalkie.TransmitOneShotAudio(axeAudio, StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX, 1f);
				}
				base.playerHeldBy.playerBodyAnimator.SetTrigger("axeHit");
				HitAxeServerRpc(num);
			}
		}

		[ServerRpc]
		public void HitAxeServerRpc(int hitSurfaceID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_00a5: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(322746160u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hitSurfaceID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 322746160u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				HitAxeClientRpc(hitSurfaceID);
			}
		}

		[ClientRpc]
		public void HitAxeClientRpc(int hitSurfaceID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4035109638u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hitSurfaceID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4035109638u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
			{
				RoundManager.PlayRandomClip(axeAudio, hitSFX, true, 1f, 0, 1000);
				if (hitSurfaceID != -1)
				{
					HitSurfaceWithAxe(hitSurfaceID);
				}
			}
		}

		private void HitSurfaceWithAxe(int hitSurfaceID)
		{
			axeAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX);
			WalkieTalkie.TransmitOneShotAudio(axeAudio, StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX, 1f);
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_AxeItem()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3261452617u, new RpcReceiveHandler(__rpc_handler_3261452617));
			NetworkManager.__rpc_func_table.Add(1978901185u, new RpcReceiveHandler(__rpc_handler_1978901185));
			NetworkManager.__rpc_func_table.Add(322746160u, new RpcReceiveHandler(__rpc_handler_322746160));
			NetworkManager.__rpc_func_table.Add(4035109638u, new RpcReceiveHandler(__rpc_handler_4035109638));
		}

		private static void __rpc_handler_3261452617(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AxeItem)(object)target).ReelUpSFXServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1978901185(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((AxeItem)(object)target).ReelUpSFXClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_322746160(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				int hitSurfaceID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AxeItem)(object)target).HitAxeServerRpc(hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4035109638(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int hitSurfaceID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((AxeItem)(object)target).HitAxeClientRpc(hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "AxeItem";
		}
	}
	public class CustomTouchInteractTrigger : MonoBehaviour
	{
		public bool isIdleTrigger;

		public bool isKillTrigger;

		public TeslaGate teslaGate;

		private void OnTriggerEnter(Collider collider)
		{
			//IL_01e5: 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 (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));
				}
			}
		}
	}
	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;
			base.itemProperties.batteryUsage = 60f;
			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)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Invalid comparison between Unknown and I4
			//IL_00a5: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(818730744u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref stillUsingFlashlight, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 818730744u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				PocketFlashlightClientRpc(stillUsingFlashlight);
			}
		}

		[ClientRpc]
		public void PocketFlashlightClientRpc(bool stillUsingFlashlight)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3584853246u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref stillUsingFlashlight, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3584853246u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || ((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()
		{
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			if (base.currentUseCooldown >= 0f)
			{
				base.currentUseCooldown -= Time.deltaTime;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				if ((base.isBeingUsed && base.itemProperties.requiresBattery) || ((Behaviour)flashlightBulb).enabled)
				{
					base.isBeingUsed = true;
					if (base.insertedBattery.charge > 0f)
					{
						if (!base.itemProperties.itemIsTrigger)
						{
							Battery insertedBattery = base.insertedBattery;
							insertedBattery.charge -= Time.deltaTime / base.itemProperties.batteryUsage;
						}
					}
					else if (!base.insertedBattery.empty)
					{
						base.insertedBattery.empty = true;
						if (base.isBeingUsed)
						{
							Debug.Log((object)"Use up batteries local");
							base.isBeingUsed = false;
							((GrabbableObject)this).UseUpBatteries();
							base.isSendingItemRPC++;
							((GrabbableObject)this).UseUpItemBatteriesServerRpc();
						}
					}
				}
				if (!base.wasOwnerLastFrame)
				{
					base.wasOwnerLastFrame = true;
				}
			}
			else if (base.wasOwnerLastFrame)
			{
				base.wasOwnerLastFrame = false;
			}
			if (!base.isHeld && (Object)(object)base.parentObject == (Object)null)
			{
				if (base.fallTime >= 1f)
				{
					if (!base.reachedFloorTarget)
					{
						if (!base.hasHitGround)
						{
							((GrabbableObject)this).PlayDropSFX();
							((GrabbableObject)this).OnHitGround();
						}
						base.reachedFloorTarget = true;
						if (base.floorYRot == -1)
						{
							((Component)this).transform.rotation = Quaternion.Euler(base.itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, base.itemProperties.restingRotation.z);
						}
						else
						{
							((Component)this).transform.rotation = Quaternion.Euler(base.itemProperties.restingRotation.x, (float)(base.floorYRot + base.itemProperties.floorYOffset) + 90f, base.itemProperties.restingRotation.z);
						}
					}
					((Component)this).transform.localPosition = base.targetFloorPosition;
					return;
				}
				base.reachedFloorTarget = false;
				((GrabbableObject)this).FallWithCurve();
				if (((Component)this).transform.localPosition.y - base.targetFloorPosition.y < 0.05f && !base.hasHitGround)
				{
					((GrabbableObject)this).PlayDropSFX();
					((GrabbableObject)this).OnHitGround();
					return;
				}
			}
			else if (base.isHeld || base.isHeldByEnemy)
			{
				base.reachedFloorTarget = false;
			}
			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_00c3: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"r/l activate: {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)
				{
					((GrabbableObject)this).SyncBatteryServerRpc((int)num);
				}
				else
				{
					((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);
				}
				base.isBeingUsed = false;
			}
		}

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

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

		private static void __rpc_handler_818730744(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				bool stillUsingFlashlight = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref stillUsingFlashlight, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((GummylightItem)(object)target).PocketFlashlightServerRpc(stillUsingFlashlight);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3584853246(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool stillUsingFlashlight = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref stillUsingFlashlight, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((GummylightItem)(object)target).PocketFlashlightClientRpc(stillUsingFlashlight);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "GummylightItem";
		}
	}
	public class M4Item : GrabbableObject
	{
		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;

		public AudioClip gunShootSFX;

		public AudioClip gunReloadSFX;

		public AudioClip gunInspectSFX;

		public AudioClip noAmmoSFX;

		private int ammoSlotToUse = -1;

		private bool localClientSendingShootGunRPC;

		private bool localClientSendingReloadGunRPC;

		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 (!((Object)(object)base.playerHeldBy == (Object)null))
			{
				if (!isInspecting && isFiring && !isReloading && !cantFire && !base.playerHeldBy.playerBodyAnimator.GetBool("ReloadM4") && ammosLoaded > 0)
				{
					ShootGunAndSync(heldByPlayer: true);
				}
				if (Plugin.InputActionInstance.RifleReloadKey.triggered && !isReloading && ammosLoaded < 30)
				{
					StartReloadGunAndSync();
				}
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			previousPlayerHeldBy = base.playerHeldBy;
			previousPlayerHeldBy.equippedUsableItemQE = true;
			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;
		}

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

		public override void ItemActivate(bool used, bool buttonDown = false)
		{
			Debug.Log((object)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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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;
			}
			Debug.Log((object)"Calling shoot gun....");
			ShootGun(gunPosition, forward);
			Debug.Log((object)"Calling shoot gun and sync");
			localClientSendingShootGunRPC = true;
			ShootGunServerRpc(gunPosition, forward);
		}

		[ServerRpc(RequireOwnership = false)]
		public void ShootGunServerRpc(Vector3 gunPosition, Vector3 gunForward)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3531625446u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref gunPosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref gunForward);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3531625446u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ShootGunClientRpc(gunPosition, gunForward);
				}
			}
		}

		[ClientRpc]
		public void ShootGunClientRpc(Vector3 gunPosition, Vector3 gunForward)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4285081824u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref gunPosition);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref gunForward);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4285081824u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_075c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0700: 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)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: 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());
			if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				base.playerHeldBy.playerBodyAnimator.SetTrigger("ShootM4");
			}
			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);
			Vector3 val = localPlayerController.playerCollider.ClosestPoint(gunPosition);
			if (num < 12f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			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 num2 = Physics.SphereCastNonAlloc(val2, 0.25f, enemyColliders, float.PositiveInfinity, 524288, (QueryTriggerInteraction)2);
				IHittable val4 = default(IHittable);
				for (int k = 0; k < num2; 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 num3 = Vector3.Distance(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((RaycastHit)(ref enemyColliders[k])).point);
						Plugin.mls.LogInfo((object)("Damage to enemy, damage: " + Plugin.rifleMonsterDamage + ", distance:" + num3));
						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 num4 = Physics.SphereCastNonAlloc(val2, 0.3f, playerColliders, float.PositiveInfinity, StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers, (QueryTriggerInteraction)2);
			for (int l = 0; l < num4; 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 num5 = Vector3.Distance(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((RaycastHit)(ref playerColliders[l])).point);
					if (num5 < 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 (num5 < 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)"Player ouch");
				}
			}
		}

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

		private void StartReloadGunAndSync()
		{
			if ((Plugin.customGunInfinityAmmo || ReloadedGun()) && !isReloading)
			{
				Debug.Log((object)"Calling reload gun....");
				((MonoBehaviour)this).StartCoroutine(ReloadGunAnimation());
				Debug.Log((object)"Calling reload gun and sync");
				localClientSendingReloadGunRPC = true;
				ReloadGunServerRpc();
			}
			else
			{
				gunAudio.PlayOneShot(noAmmoSFX);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ReloadGunServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1116130421u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1116130421u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ReloadGunClientRpc();
				}
			}
		}

		[ClientRpc]
		public void ReloadGunClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((Net