Decompiled source of LethalClimbers v1.2.0

LethalClimbers.dll

Decompiled 7 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 BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalClimbers.NetcodePatcher;
using LethalClimbers.Patches;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LethalClimbers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalClimbers")]
[assembly: AssemblyTitle("LethalClimbers")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace LethalClimbers
{
	[BepInPlugin("jarediscoding.lethalclimbers", "Lethal Climbers", "1.2.0")]
	public class BasePlugin : BaseUnityPlugin
	{
		private static BasePlugin Instance;

		private const string ModGUID = "jarediscoding.lethalclimbers";

		private const string ModName = "Lethal Climbers";

		private const string ModVersion = "1.2.0";

		public static ManualLogSource LogSource;

		private readonly Harmony harmony = new Harmony("jarediscoding.lethalclimbers");

		public static AssetBundle ItemAssetBundle;

		public static List<AudioClip> MouthDogAIAudioClips = new List<AudioClip>();

		public static List<AudioClip> BoomBoxItemAudioClips = new List<AudioClip>();

		private static readonly Type[] PatchList = new Type[3]
		{
			typeof(PlayerControllerBPatch),
			typeof(MouthDogAIPatch),
			typeof(BoomBoxItemPatch)
		};

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			LogSource = Logger.CreateLogSource("jarediscoding.lethalclimbers");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "customitems");
			ItemAssetBundle = AssetBundle.LoadFromFile(text);
			ItemPatch.Start();
			LogSource.LogInfo((object)"Custom items patch complete");
			MouthDogAIAudioClips.Add(ItemAssetBundle.LoadAsset<AudioClip>("Assets/Sounds/Enemies/MouthDog/OndraYell1.wav"));
			BoomBoxItemAudioClips.Add(ItemAssetBundle.LoadAsset<AudioClip>("Assets/Sounds/BoomBox/RappSnitch.wav"));
			BoomBoxItemAudioClips.Add(ItemAssetBundle.LoadAsset<AudioClip>("Assets/Sounds/BoomBox/MorgIce.wav"));
			BoomBoxItemAudioClips.Add(ItemAssetBundle.LoadAsset<AudioClip>("Assets/Sounds/BoomBox/FeelGood.wav"));
			BoomBoxItemAudioClips.Add(ItemAssetBundle.LoadAsset<AudioClip>("Assets/Sounds/BoomBox/BoyLiarPt2.wav"));
			Type[] patchList = PatchList;
			foreach (Type type in patchList)
			{
				harmony.PatchAll(type);
				LogSource.LogDebug((object)$"{type} complete");
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type2 in array)
			{
				MethodInfo[] methods = type2.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			LogSource.LogInfo((object)"Load complete");
		}
	}
}
namespace LethalClimbers.Patches
{
	[HarmonyPatch(typeof(BoomboxItem))]
	internal class BoomBoxItemPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPatch(BoomboxItem __instance)
		{
			int count = BasePlugin.BoomBoxItemAudioClips.Count;
			AudioClip[] musicAudios = __instance.musicAudios;
			__instance.musicAudios = (AudioClip[])(object)new AudioClip[musicAudios.Length + count];
			int num = 0;
			AudioClip[] array = musicAudios;
			foreach (AudioClip val in array)
			{
				__instance.musicAudios[num] = val;
				num++;
			}
			foreach (AudioClip boomBoxItemAudioClip in BasePlugin.BoomBoxItemAudioClips)
			{
				__instance.musicAudios[num] = boomBoxItemAudioClip;
				num++;
				BasePlugin.LogSource.LogDebug((object)$"{__instance} - Added new music track: {boomBoxItemAudioClip}");
			}
		}
	}
	internal class ItemPatch
	{
		private class MoonTypes
		{
			public static readonly LevelTypes IndustrialMoons = (LevelTypes)4;

			public static readonly LevelTypes ForestMoons = (LevelTypes)0;

			public static readonly LevelTypes DesertMoons = (LevelTypes)0;

			public static readonly LevelTypes IceMoons = (LevelTypes)0;
		}

		private class ItemData
		{
			private Item ItemRef;

			private string Path;

			private string Name;

			private LevelTypes ValidMoons;

			private int Rarity;

			private bool IsStoreItem;

			private string StoreDescription;

			private int StoreValue;

			private void WriteItemData(string path, int rarity, LevelTypes validMoons, bool isStoreItem, string storeDescription, int storeValue)
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				Path = "Assets/Items/" + path + "/" + path + ".asset";
				Name = path.Split(".")[0];
				Rarity = rarity;
				ValidMoons = validMoons;
				IsStoreItem = isStoreItem;
				StoreDescription = storeDescription;
				StoreValue = storeValue;
			}

			public ItemData(string path, int rarity)
			{
				WriteItemData(path, rarity, (LevelTypes)(-1), isStoreItem: false, string.Empty, 0);
			}

			public ItemData(string path, int rarity, LevelTypes validMoons)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				WriteItemData(path, rarity, validMoons, isStoreItem: false, string.Empty, 0);
			}

			public ItemData(string path, int rarity, LevelTypes validMoons, bool isStoreItem, string storeDescription, int storeValue)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				WriteItemData(path, rarity, validMoons, isStoreItem, storeDescription, storeValue);
			}

			public string GetPath()
			{
				return Path;
			}

			public string GetName()
			{
				return Name;
			}

			public int GetRarity()
			{
				return Rarity;
			}

			public LevelTypes GetValidMoons()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				return ValidMoons;
			}

			public bool GetIsStoreItem()
			{
				return IsStoreItem;
			}

			public string GetStoreDescription()
			{
				return StoreDescription;
			}

			public int GetStoreValue()
			{
				return StoreValue;
			}

			public void SetItem(Item ItemToSet)
			{
				ItemRef = ItemToSet;
			}

			public Item GetItem()
			{
				return ItemRef;
			}
		}

		private static readonly ItemData[] ItemList = new ItemData[8]
		{
			new ItemData("Chalk Brush", 40),
			new ItemData("Chalk Bucket", 40),
			new ItemData("Climbing Hold", 40),
			new ItemData("Grigri", 40),
			new ItemData("Helmet", 40),
			new ItemData("Ice Axe", 30, MoonTypes.IceMoons),
			new ItemData("Quickdraw", 40),
			new ItemData("Rope", 30)
		};

		public static void Start()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			ItemData[] itemList = ItemList;
			foreach (ItemData itemData in itemList)
			{
				Item val = BasePlugin.ItemAssetBundle.LoadAsset<Item>(itemData.GetPath());
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, itemData.GetRarity(), itemData.GetValidMoons());
				Utilities.FixMixerGroups(val.spawnPrefab);
				itemData.SetItem(val);
				if (itemData.GetIsStoreItem())
				{
					TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
					val2.clearPreviousText = true;
					val2.displayText = "Here's some info about a " + itemData.GetName() + ":\n\n" + itemData.GetStoreDescription();
					Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, itemData.GetStoreValue());
				}
				BasePlugin.LogSource.LogDebug((object)("Climbing item loaded: " + ((Object)val).name));
			}
		}
	}
	[HarmonyPatch(typeof(MouthDogAI))]
	internal class MouthDogAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void AudioStartPatch(MouthDogAI __instance)
		{
			__instance.screamSFX = BasePlugin.MouthDogAIAudioClips.OrderBy((AudioClip x) => Guid.NewGuid()).FirstOrDefault();
			BasePlugin.LogSource.LogDebug((object)$"{__instance} - Cycled to next audio file.");
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void LadderSprintPatch(ref float ___sprintMeter, ref float ___sprintTime, ref bool ___isClimbingLadder)
		{
			if (___isClimbingLadder)
			{
				___sprintMeter = Mathf.Clamp(___sprintMeter + 0.002f + Time.deltaTime / ___sprintTime, 0f, 1f);
				BasePlugin.LogSource.LogDebug((object)$"Climber is resting. Sprint meter: {___sprintMeter}");
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void AudioOnStartPatch(StartOfRound __instance)
		{
			__instance.shipIntroSpeechSFX = BasePlugin.ItemAssetBundle.LoadAsset<AudioClip>("Assets/Sounds/vlad_likes_climbing.wav");
		}
	}
}
namespace LethalClimbers.CustomItems
{
	public class LcNoisyObject : GrabbableObject
	{
		[Header("Audio Sources")]
		[Space(1f)]
		public AudioSource audioSource;

		public AudioSource audioSourceFar;

		[Space(3f)]
		[Header("Sound Effects")]
		[Space(1f)]
		public AudioClip[] noiseSFX;

		public AudioClip[] noiseSFXFar;

		[Space(3f)]
		[Header("Sound Settings")]
		[Space(1f)]
		public float noiseRange;

		public float maxLoudness;

		public float minLoudness;

		public float minPitch;

		public float maxPitch;

		[HideInInspector]
		private Random noisemakerRandom;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			noisemakerRandom = new Random(StartOfRound.Instance.randomMapSeed + 85);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (((NetworkBehaviour)this).IsOwner && !audioSource.isPlaying)
			{
				int randomNoisePosition = noisemakerRandom.Next(0, noiseSFX.Length);
				float volumeScale = (float)noisemakerRandom.Next((int)(minLoudness * 100f), (int)(maxLoudness * 100f)) / 100f;
				float pitch = (float)noisemakerRandom.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
				PlaySoundServerRpc(randomNoisePosition, volumeScale, pitch);
			}
		}

		[ServerRpc]
		public void PlaySoundServerRpc(int randomNoisePosition, float volumeScale, float pitch)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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(3894495466u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, randomNoisePosition);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref volumeScale, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref pitch, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3894495466u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				PlaySoundClientRpc(randomNoisePosition, volumeScale, pitch);
			}
		}

		[ClientRpc]
		public void PlaySoundClientRpc(int randomNoisePosition, float volumeScale, float pitch)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_008a: 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_00a5: 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_00bf: 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(2066566681u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, randomNoisePosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref volumeScale, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref pitch, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2066566681u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlaySoundFile(randomNoisePosition, volumeScale, pitch);
				}
			}
		}

		public void PlaySoundFile(int randomNoisePosition, float volumeScale, float pitch)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (!audioSource.isPlaying)
			{
				audioSource.pitch = pitch;
				audioSource.PlayOneShot(noiseSFX[randomNoisePosition], volumeScale);
				if ((Object)(object)audioSourceFar != (Object)null && !audioSourceFar.isPlaying)
				{
					audioSourceFar.pitch = pitch;
					audioSourceFar.PlayOneShot(noiseSFXFar[randomNoisePosition], volumeScale);
				}
				WalkieTalkie.TransmitOneShotAudio(audioSource, noiseSFX[randomNoisePosition], volumeScale);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, volumeScale, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LcNoisyObject()
		{
			//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(3894495466u, new RpcReceiveHandler(__rpc_handler_3894495466));
			NetworkManager.__rpc_func_table.Add(2066566681u, new RpcReceiveHandler(__rpc_handler_2066566681));
		}

		private static void __rpc_handler_3894495466(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_0089: 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_00a4: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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!");
				}
				return;
			}
			int randomNoisePosition = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref randomNoisePosition);
			float volumeScale = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref volumeScale, default(ForPrimitives));
			float pitch = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref pitch, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((LcNoisyObject)(object)target).PlaySoundServerRpc(randomNoisePosition, volumeScale, pitch);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}

		private static void __rpc_handler_2066566681(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int randomNoisePosition = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref randomNoisePosition);
				float volumeScale = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref volumeScale, default(ForPrimitives));
				float pitch = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref pitch, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LcNoisyObject)(object)target).PlaySoundClientRpc(randomNoisePosition, volumeScale, pitch);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "LcNoisyObject";
		}
	}
	public class LcWeaponObject : GrabbableObject
	{
		[Space(3f)]
		[Header("Weapon Settings")]
		[Space(1f)]
		public int weaponHitForce = 1;

		[HideInInspector]
		public bool reelingUp;

		[HideInInspector]
		public bool isHoldingButton;

		[HideInInspector]
		private RaycastHit rayHit;

		[HideInInspector]
		private Coroutine reelingUpCoroutine;

		[HideInInspector]
		private RaycastHit[] objectsHitByWeapon;

		[HideInInspector]
		private List<RaycastHit> objectsHitByWeaponList = new List<RaycastHit>();

		[HideInInspector]
		private PlayerControllerB previousPlayerHeldBy;

		private readonly int weaponMask = 11012424;

		[Space(3f)]
		[Header("Sound Settings")]
		[Space(1f)]
		public AudioSource audioSource;

		[Space(3f)]
		[Header("Sound Effects")]
		[Space(1f)]
		public AudioClip reelUpSfx;

		public AudioClip swingSfx;

		public AudioClip[] hitSfx;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			BasePlugin.LogSource.LogDebug((object)$"{((Object)this).GetInstanceID()} Start()");
		}

		public override void DiscardItem()
		{
			BasePlugin.LogSource.LogDebug((object)$"{((Object)this).GetInstanceID()} DiscardItem()");
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.activatingItem = false;
			}
			((GrabbableObject)this).DiscardItem();
		}

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

		private IEnumerator reelUpWeapon()
		{
			base.playerHeldBy.activatingItem = true;
			base.playerHeldBy.twoHanded = true;
			base.playerHeldBy.playerBodyAnimator.ResetTrigger("weaponHit");
			base.playerHeldBy.playerBodyAnimator.SetBool("reelingUp", true);
			audioSource.PlayOneShot(reelUpSfx);
			ReelUpSFXServerRpc();
			yield return (object)new WaitForSeconds(0.35f);
			yield return (object)new WaitUntil((Func<bool>)(() => !isHoldingButton || !base.isHeld));
			SwingWeapon(!base.isHeld);
			yield return (object)new WaitForSeconds(0.13f);
			yield return (object)new WaitForEndOfFrame();
			HitWeapon(!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(3290244716u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3290244716u, 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(3204628915u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3204628915u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					audioSource.PlayOneShot(reelUpSfx);
				}
			}
		}

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

		public void HitWeapon(bool cancel = false)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: 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_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: 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_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)previousPlayerHeldBy == (Object)null)
			{
				BasePlugin.LogSource.LogDebug((object)"Previousplayerheldby is null on this client when HitWeapon is called.");
				return;
			}
			previousPlayerHeldBy.activatingItem = false;
			bool flag = false;
			bool flag2 = false;
			int num = -1;
			if (!cancel)
			{
				previousPlayerHeldBy.twoHanded = false;
				objectsHitByWeapon = Physics.SphereCastAll(((Component)previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)previousPlayerHeldBy.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward, 1.5f, weaponMask, (QueryTriggerInteraction)2);
				objectsHitByWeaponList = objectsHitByWeapon.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
				IHittable val2 = default(IHittable);
				RaycastHit val3 = default(RaycastHit);
				for (int i = 0; i < objectsHitByWeaponList.Count; i++)
				{
					RaycastHit val = objectsHitByWeaponList[i];
					if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 8)
					{
						val = objectsHitByWeaponList[i];
						if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 11)
						{
							val = objectsHitByWeaponList[i];
							if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
							{
								continue;
							}
							val = objectsHitByWeaponList[i];
							if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform)
							{
								continue;
							}
							val = objectsHitByWeaponList[i];
							if (!(((RaycastHit)(ref val)).point == Vector3.zero))
							{
								Vector3 position = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
								val = objectsHitByWeaponList[i];
								if (Physics.Linecast(position, ((RaycastHit)(ref val)).point, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
								{
									continue;
								}
							}
							flag = true;
							Vector3 forward = ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward;
							val = objectsHitByWeaponList[i];
							Debug.DrawRay(((RaycastHit)(ref val)).point, Vector3.up * 0.25f, Color.green, 5f);
							try
							{
								val2.Hit(weaponHitForce, forward, previousPlayerHeldBy, true, -1);
								flag2 = true;
							}
							catch (Exception arg)
							{
								BasePlugin.LogSource.LogDebug((object)$"Exception caught when hitting object with weapon from player #{previousPlayerHeldBy.playerClientId}: {arg}");
							}
							continue;
						}
					}
					flag = true;
					val = objectsHitByWeaponList[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(audioSource, hitSfx, true, 1f, 0, 1000);
				Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)this).transform.position, 17f, 0.8f, 0, false, 0);
				if (!flag2 && num != -1)
				{
					audioSource.PlayOneShot(StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX);
					WalkieTalkie.TransmitOneShotAudio(audioSource, StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX, 1f);
				}
				base.playerHeldBy.playerBodyAnimator.SetTrigger("weaponHit");
				HitWeaponServerRpc(num);
			}
		}

		[ServerRpc]
		public void HitWeaponServerRpc(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(3177588695u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hitSurfaceID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3177588695u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				HitWeaponClientRpc(hitSurfaceID);
			}
		}

		[ClientRpc]
		public void HitWeaponClientRpc(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(691834286u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hitSurfaceID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 691834286u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				RoundManager.PlayRandomClip(audioSource, hitSfx, true, 1f, 0, 1000);
				if (hitSurfaceID != -1)
				{
					HitSurfaceWithWeapon(hitSurfaceID);
				}
			}
		}

		private void HitSurfaceWithWeapon(int hitSurfaceID)
		{
			if (!((NetworkBehaviour)this).IsOwner)
			{
				audioSource.PlayOneShot(StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX);
			}
			WalkieTalkie.TransmitOneShotAudio(audioSource, StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX, 1f);
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LcWeaponObject()
		{
			//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(3290244716u, new RpcReceiveHandler(__rpc_handler_3290244716));
			NetworkManager.__rpc_func_table.Add(3204628915u, new RpcReceiveHandler(__rpc_handler_3204628915));
			NetworkManager.__rpc_func_table.Add(3177588695u, new RpcReceiveHandler(__rpc_handler_3177588695));
			NetworkManager.__rpc_func_table.Add(691834286u, new RpcReceiveHandler(__rpc_handler_691834286));
		}

		private static void __rpc_handler_3290244716(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;
				((LcWeaponObject)(object)target).ReelUpSFXServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3204628915(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;
				((LcWeaponObject)(object)target).ReelUpSFXClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3177588695(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;
				((LcWeaponObject)(object)target).HitWeaponServerRpc(hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_691834286(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;
				((LcWeaponObject)(object)target).HitWeaponClientRpc(hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "LcWeaponObject";
		}
	}
}
namespace LethalClimbers.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}