Decompiled source of ShitpostMod v1.3.4

ShitpostMod.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using ShitpostMod.Patches;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ShitpostMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShitpostMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4004d936-9773-4ba0-9794-18e59dae3d83")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ShitpostMod
{
	[BepInPlugin("plogin.ShitpostMod", "Shitpost mod", "1.0.2")]
	public class ShitpostModBase : BaseUnityPlugin
	{
		private const string modGUID = "plogin.ShitpostMod";

		private const string modName = "Shitpost mod";

		private const string modVersion = "1.0.2";

		private readonly Harmony harmony = new Harmony("plogin.ShitpostMod");

		private static ShitpostModBase Instance;

		internal ManualLogSource mls;

		internal static AudioClip soundShipStart;

		internal static AudioClip soundJesterWind;

		internal static AudioClip soundJeterChase;

		internal static AudioClip[] soundsLootbugChitter;

		internal static AudioClip[] soundsLootbugAngry;

		internal static AudioClip soundsCompanyAngry;

		internal static AudioClip soundsNword;

		internal static AudioClip soundSonic;

		internal static AudioClip soundSandvichEat;

		internal static AudioClip soundSandvichHeal;

		internal static AudioClip soundSandvichDed;

		internal static AudioClip soundHardkor;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("plogin.ShitpostMod");
			mls.LogInfo((object)"The ShitpostMod has awoken.");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("ShitpostMod.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "/modsounds");
			if ((Object)(object)val != (Object)null)
			{
				soundShipStart = val.LoadAsset<AudioClip>("koczkodan.wav");
				soundJesterWind = val.LoadAsset<AudioClip>("jester_wind.wav");
				soundJeterChase = val.LoadAsset<AudioClip>("jester_chase.wav");
				List<AudioClip> list = new List<AudioClip>();
				list.Add(val.LoadAsset<AudioClip>("bazarek.wav"));
				list.Add(val.LoadAsset<AudioClip>("pedator.wav"));
				list.Add(val.LoadAsset<AudioClip>("zlomiarze.wav"));
				list.Add(val.LoadAsset<AudioClip>("sumo.wav"));
				list.Add(val.LoadAsset<AudioClip>("odwolaj.wav"));
				soundsLootbugChitter = list.ToArray();
				list = new List<AudioClip>();
				list.Add(val.LoadAsset<AudioClip>("chlop.wav"));
				list.Add(val.LoadAsset<AudioClip>("oddawaj_pieniadze.wav"));
				list.Add(val.LoadAsset<AudioClip>("dawac_hajs.wav"));
				list.Add(val.LoadAsset<AudioClip>("solowa.wav"));
				soundsLootbugAngry = list.ToArray();
				soundsCompanyAngry = val.LoadAsset<AudioClip>("gipsowanie.wav");
				soundsNword = val.LoadAsset<AudioClip>("nword.wav");
				soundSonic = val.LoadAsset<AudioClip>("sonic.wav");
				soundSandvichEat = val.LoadAsset<AudioClip>("sandvich.wav");
				soundSandvichHeal = val.LoadAsset<AudioClip>("sandvich_delicious.wav");
				soundSandvichDed = val.LoadAsset<AudioClip>("sandvich_ded.wav");
				soundHardkor = val.LoadAsset<AudioClip>("hardkor.wav");
				mls.LogInfo((object)"Succesfully loaded asset bundle.");
			}
			else
			{
				mls.LogError((object)"Failed to load asset bundle.");
			}
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(JesterAIPatch));
			harmony.PatchAll(typeof(HoarderBugAIPatch));
			harmony.PatchAll(typeof(DepositItemsDeskPatch));
			harmony.PatchAll(typeof(NoisemakerPropPatch));
			harmony.PatchAll(typeof(GrabbableObjectPatch));
			harmony.PatchAll(typeof(LandminePatch));
			harmony.PatchAll(typeof(TurretPatch));
		}
	}
}
namespace ShitpostMod.Patches
{
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class DepositItemsDeskPatch
	{
		private static float companySoundTimer;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdateTimer(DepositItemsDesk __instance)
		{
			if (companySoundTimer > 0f)
			{
				companySoundTimer -= Time.deltaTime;
			}
		}

		[HarmonyPatch("MakeLoudNoise")]
		[HarmonyPostfix]
		private static void PlayAngryAudio(DepositItemsDesk __instance)
		{
			if (companySoundTimer <= 0f)
			{
				__instance.wallAudio.PlayOneShot(ShitpostModBase.soundsCompanyAngry);
				companySoundTimer = 60f;
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch : MonoBehaviour
	{
		[HarmonyPatch("SetScrapValue")]
		[HarmonyPostfix]
		private static void InitializeItems(GrabbableObject __instance)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			switch (__instance.itemProperties.itemName)
			{
			case "Qtas":
				__instance.insertedBattery = new Battery(false, 1f);
				__instance.itemProperties.requiresBattery = true;
				__instance.itemProperties.itemIsTrigger = true;
				__instance.itemProperties.batteryUsage = 0.1f;
				__instance.useCooldown = 1f;
				break;
			case "Megaphone":
				__instance.insertedBattery = new Battery(false, 1f);
				__instance.itemProperties.requiresBattery = true;
				__instance.itemProperties.itemIsTrigger = true;
				__instance.itemProperties.batteryUsage = 0.01f;
				break;
			case "Sanic":
				__instance.insertedBattery = new Battery(false, 1f);
				__instance.itemProperties.requiresBattery = true;
				__instance.itemProperties.itemIsTrigger = true;
				__instance.itemProperties.batteryUsage = 0.25f;
				__instance.useCooldown = 15f;
				break;
			case "Sandvich":
				__instance.insertedBattery = new Battery(false, 1f);
				__instance.itemProperties.requiresBattery = true;
				__instance.itemProperties.itemIsTrigger = true;
				__instance.itemProperties.batteryUsage = 0.2f;
				__instance.useCooldown = 4f;
				break;
			case "Jumper":
				__instance.insertedBattery = new Battery(false, 1f);
				__instance.itemProperties.requiresBattery = true;
				__instance.itemProperties.itemIsTrigger = true;
				__instance.itemProperties.batteryUsage = 0.2f;
				__instance.useCooldown = 4f;
				break;
			}
		}

		[HarmonyPatch("ItemActivate")]
		[HarmonyPostfix]
		private static void ItemActivateSpecialEffects(GrabbableObject __instance)
		{
			PlayerControllerB playerHeldBy = __instance.playerHeldBy;
			if ((Object)(object)playerHeldBy != (Object)null)
			{
				switch (__instance.itemProperties.itemName)
				{
				case "Sanic":
					((MonoBehaviour)playerHeldBy).StartCoroutine(ItemEffectSuperSpeed(__instance, playerHeldBy));
					break;
				case "Sandvich":
					((MonoBehaviour)playerHeldBy).StartCoroutine(ItemEffectSandvich(__instance, playerHeldBy));
					break;
				case "Jumper":
					((MonoBehaviour)playerHeldBy).StartCoroutine(ItemEffectSuperJump(__instance, playerHeldBy));
					break;
				}
			}
		}

		private static IEnumerator ItemEffectSuperSpeed(GrabbableObject __instanceItem, PlayerControllerB __instancePlayer)
		{
			__instancePlayer.isSpeedCheating = true;
			__instancePlayer.isSprinting = true;
			__instancePlayer.sprintMeter = 0f;
			float timer2 = 7.1f;
			AudioClip noiseAudio = ShitpostModBase.soundSonic;
			((Component)__instanceItem).gameObject.GetComponent<AudioSource>().PlayOneShot(noiseAudio);
			WalkieTalkie.TransmitOneShotAudio(((Component)__instanceItem).gameObject.GetComponent<AudioSource>(), noiseAudio, 1f);
			RoundManager.Instance.PlayAudibleNoise(((Component)__instanceItem).transform.position, 100f, 1f, 0, __instanceItem.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			if ((Object)(object)__instanceItem.playerHeldBy != (Object)null)
			{
				__instanceItem.playerHeldBy.timeSinceMakingLoudNoise = 0f;
			}
			while (timer2 > 0f)
			{
				__instancePlayer.sprintMeter = 0f;
				timer2 -= 0.05f;
				__instancePlayer.isSprinting = true;
				yield return (object)new WaitForSeconds(0.05f);
			}
			__instancePlayer.carryWeight += 1f;
			__instancePlayer.isSpeedCheating = false;
			__instancePlayer.isSprinting = false;
			__instancePlayer.sprintMeter = 0f;
			timer2 = 7.5f;
			while (timer2 > 0f)
			{
				__instancePlayer.sprintMeter = 0f;
				timer2 -= 0.05f;
				yield return (object)new WaitForSeconds(0.05f);
			}
			__instancePlayer.carryWeight -= 1f;
		}

		private static IEnumerator ItemEffectSuperJump(GrabbableObject __instanceItem, PlayerControllerB __instancePlayer)
		{
			__instancePlayer.hinderedMultiplier = 2f;
			__instancePlayer.DamagePlayer(15, true, true, (CauseOfDeath)2, 0, true, default(Vector3));
			AudioClip noiseAudio = ShitpostModBase.soundHardkor;
			((Component)__instanceItem).gameObject.GetComponent<AudioSource>().PlayOneShot(noiseAudio);
			WalkieTalkie.TransmitOneShotAudio(((Component)__instanceItem).gameObject.GetComponent<AudioSource>(), noiseAudio, 1f);
			RoundManager.Instance.PlayAudibleNoise(((Component)__instanceItem).transform.position, 100f, 1f, 0, __instanceItem.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			if ((Object)(object)__instanceItem.playerHeldBy != (Object)null)
			{
				__instanceItem.playerHeldBy.timeSinceMakingLoudNoise = 0f;
			}
			float timer = 2f;
			float jumpVal = 1f;
			while (timer > 0f)
			{
				Vector3 newPos = ((Component)__instancePlayer).transform.position;
				newPos.y += jumpVal;
				jumpVal -= (jumpVal - 0.1f) / (timer / 0.01f);
				((Component)__instancePlayer).transform.position = newPos;
				timer -= 0.01f;
				yield return (object)new WaitForSeconds(0.01f);
			}
			__instancePlayer.fallValueUncapped = 0f;
			__instancePlayer.fallValue = 0f;
			yield return (object)new WaitUntil((Func<bool>)(() => __instancePlayer.thisController.isGrounded));
			yield return (object)new WaitForSeconds(0.1f);
			__instancePlayer.hinderedMultiplier = 1f;
			yield return null;
		}

		private static IEnumerator ItemEffectSandvich(GrabbableObject __instanceItem, PlayerControllerB __instancePlayer)
		{
			float randomNum = Random.Range(0f, 1f);
			bool isDed = false;
			if ((double)__instanceItem.insertedBattery.charge > 0.95)
			{
				if ((double)randomNum > 0.97)
				{
					isDed = true;
				}
			}
			else if ((double)randomNum > 0.6)
			{
				isDed = true;
			}
			__instancePlayer.carryWeight += 100f;
			float timer = 2.2f;
			AudioClip noiseAudio2 = ShitpostModBase.soundSandvichEat;
			((Component)__instanceItem).gameObject.GetComponent<AudioSource>().PlayOneShot(noiseAudio2);
			WalkieTalkie.TransmitOneShotAudio(((Component)__instanceItem).gameObject.GetComponent<AudioSource>(), noiseAudio2, 1f);
			RoundManager.Instance.PlayAudibleNoise(((Component)__instanceItem).transform.position, 100f, 1f, 0, __instanceItem.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			if ((Object)(object)__instanceItem.playerHeldBy != (Object)null)
			{
				__instanceItem.playerHeldBy.timeSinceMakingLoudNoise = 0f;
			}
			while (timer > 0f)
			{
				__instancePlayer.health += 10;
				if (__instancePlayer.health > 100)
				{
					__instancePlayer.health = 100;
				}
				timer -= 0.2f;
				yield return (object)new WaitForSeconds(0.2f);
			}
			HUDManager.Instance.UpdateHealthUI(__instancePlayer.health, true);
			__instancePlayer.carryWeight -= 100f;
			if (isDed)
			{
				noiseAudio2 = ShitpostModBase.soundSandvichDed;
				((Component)__instanceItem).gameObject.GetComponent<AudioSource>().PlayOneShot(noiseAudio2);
				WalkieTalkie.TransmitOneShotAudio(((Component)__instanceItem).gameObject.GetComponent<AudioSource>(), noiseAudio2, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)__instanceItem).transform.position, 100f, 1f, 0, __instanceItem.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
				if ((Object)(object)__instanceItem.playerHeldBy != (Object)null)
				{
					__instanceItem.playerHeldBy.timeSinceMakingLoudNoise = 0f;
				}
				int damage = 100;
				__instancePlayer.DamagePlayer(damage, true, true, (CauseOfDeath)4, 0, true, default(Vector3));
				__instancePlayer.DamagePlayer(damage, true, true, (CauseOfDeath)4, 0, true, default(Vector3));
				__instancePlayer.DamagePlayer(damage, true, true, (CauseOfDeath)4, 0, true, default(Vector3));
			}
			else
			{
				noiseAudio2 = ShitpostModBase.soundSandvichHeal;
				((Component)__instanceItem).gameObject.GetComponent<AudioSource>().PlayOneShot(noiseAudio2);
				WalkieTalkie.TransmitOneShotAudio(((Component)__instanceItem).gameObject.GetComponent<AudioSource>(), noiseAudio2, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)__instanceItem).transform.position, 100f, 1f, 0, __instanceItem.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
				if ((Object)(object)__instanceItem.playerHeldBy != (Object)null)
				{
					__instanceItem.playerHeldBy.timeSinceMakingLoudNoise = 0f;
				}
			}
			yield return null;
		}

		private static IEnumerator ItemEffectTeleport(GrabbableObject __instanceItem, PlayerControllerB __instancePlayer)
		{
			yield return null;
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderBugAIPatch : MonoBehaviour
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartEnemyAutioLoop(HoarderBugAI __instance)
		{
			NetworkBehaviour val = Object.FindObjectOfType<NetworkBehaviour>();
			if (!val.IsOwner)
			{
			}
		}

		private static IEnumerator AudioLoop(HoarderBugAI __instance)
		{
			float bugSoundTimer = 0f;
			float bugSoundAdditionalTime = 0f;
			while (!((EnemyAI)__instance).isEnemyDead)
			{
				if (bugSoundTimer > 0f)
				{
					bugSoundTimer -= Time.deltaTime;
					if (__instance.angryTimer > 0f && bugSoundTimer < bugSoundAdditionalTime)
					{
						bugSoundTimer = 0f;
					}
				}
				if (bugSoundTimer <= 0f && (Object)(object)__instance.watchingPlayer != (Object)null)
				{
					AudioClip[] sounds = ShitpostModBase.soundsLootbugChitter;
					if (__instance.angryTimer > 0f)
					{
						sounds = ShitpostModBase.soundsLootbugAngry;
						bugSoundTimer += 2f;
						bugSoundAdditionalTime = 0f;
					}
					else
					{
						bugSoundTimer += 2f;
						float randTime = 5f + Random.Range(0f, 25f);
						bugSoundTimer += randTime;
						bugSoundAdditionalTime = randTime;
					}
					int id = Random.Range(0, sounds.Length);
					AudioClip sound = sounds[id];
					bugSoundTimer += sound.length;
					((EnemyAI)__instance).creatureSFX.PlayOneShot(sound);
				}
				yield return (object)new WaitForSeconds(0.1f);
				bugSoundTimer -= 0.1f;
			}
			yield return null;
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	internal class JesterAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(JesterAI __instance)
		{
		}

		[HarmonyPatch("SetJesterInitialValues")]
		[HarmonyPostfix]
		private static void SetJesterWindUp(JesterAI __instance)
		{
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPatch : MonoBehaviour
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideStart(Turret __instance)
		{
			NetworkBehaviour val = Object.FindObjectOfType<NetworkBehaviour>();
			if (val.IsOwner)
			{
				((MonoBehaviour)__instance).StartCoroutine(TurretLoop(__instance));
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void OverrideUpdate(Turret __instance, ref float ___turretInterval)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			NetworkBehaviour val = Object.FindObjectOfType<NetworkBehaviour>();
			if (val.IsOwner && __instance.rotationRange == 360f && (int)__instance.turretMode == 1)
			{
				___turretInterval -= Time.deltaTime / 2f;
			}
		}

		private static IEnumerator TurretLoop(Turret __instance)
		{
			float randomNum = Random.Range(0f, 1f);
			int turretBehaviour = 0;
			if (randomNum < 0.1f)
			{
				turretBehaviour = 1;
			}
			Debug.Log((object)$"Turret behaviour: {turretBehaviour}");
			float gracePeriod = 5f;
			while (turretBehaviour != 0)
			{
				PlayerControllerB[] players = Object.FindObjectsOfType<PlayerControllerB>();
				List<PlayerControllerB> playersToFollow = new List<PlayerControllerB>();
				bool playerNearby = false;
				PlayerControllerB[] array = players;
				foreach (PlayerControllerB player in array)
				{
					Vector3.Distance(((Component)__instance).transform.position, ((Component)player).transform.position);
					float turretRange = __instance.rotationRange;
					__instance.rotationRange = 360f;
					if ((Object)(object)__instance.CheckForPlayersInLineOfSight(2f, false) != (Object)null)
					{
						playerNearby = true;
						playersToFollow.Add(player);
						gracePeriod -= 0.5f;
					}
					__instance.rotationRange = turretRange;
				}
				if (gracePeriod > 0f)
				{
					yield return (object)new WaitForSeconds(0.5f);
					continue;
				}
				randomNum = Random.Range(0f, 1f);
				if (playerNearby && randomNum > 0.92f && turretBehaviour == 1 && (int)__instance.turretMode == 0)
				{
					__instance.turretMode = (TurretMode)3;
					__instance.EnterBerserkModeServerRpc(0);
					randomNum = Random.Range(15f, 25f);
					gracePeriod = 5f;
					yield return (object)new WaitForSeconds(randomNum);
				}
				if (turretBehaviour == 2)
				{
					Vector3 newPosition = ((Component)__instance).transform.eulerAngles;
					newPosition.y += Random.Range(-90f, 90f);
					((Component)__instance).transform.eulerAngles = newPosition;
					Debug.Log((object)$"New rotation: {newPosition.y}");
					((MonoBehaviour)__instance).StartCoroutine(RotateTurret(__instance, newPosition));
					Random.Range(15f, 30f);
					randomNum = 5f;
					yield return (object)new WaitForSeconds(randomNum);
				}
				yield return (object)new WaitForSeconds(0.5f);
			}
			yield return null;
		}

		private static IEnumerator RotateTurret(Turret __instance, Vector3 newPosition)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Random.Range(2f, 4f);
			float rotationSpeed = 1f;
			float timer = 2f;
			while (timer > 0f)
			{
				Vector3 newTurretPosition = Vector3.RotateTowards(((Component)__instance).transform.position, newPosition, rotationSpeed * 0.01f, 0f);
				((Component)__instance).transform.position = newTurretPosition;
				timer -= 0.01f;
				yield return (object)new WaitForSeconds(0.01f);
			}
			yield return null;
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatch : MonoBehaviour
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideStart(Landmine __instance)
		{
			NetworkBehaviour val = Object.FindObjectOfType<NetworkBehaviour>();
			if (val.IsOwner)
			{
				((MonoBehaviour)__instance).StartCoroutine(LandmineLoop(__instance));
			}
		}

		private static IEnumerator LandmineLoop(Landmine __instance)
		{
			float randomNum = Random.Range(0f, 1f);
			_ = ((Component)__instance).transform.localScale;
			int landmineBehaviour = 0;
			if (randomNum < 0.1f)
			{
				landmineBehaviour = 1;
			}
			else if (randomNum < 0.2f)
			{
				landmineBehaviour = 2;
			}
			Debug.Log((object)$"Landmine behaviour {landmineBehaviour}");
			while (!__instance.hasExploded && landmineBehaviour != 0)
			{
				PlayerControllerB[] players = Object.FindObjectsOfType<PlayerControllerB>();
				List<PlayerControllerB> playersToFollow = new List<PlayerControllerB>();
				bool playerNearby = false;
				bool playerInExplRange = false;
				PlayerControllerB[] array = players;
				foreach (PlayerControllerB player in array)
				{
					float distance = Vector3.Distance(((Component)__instance).transform.position, ((Component)player).transform.position);
					if (distance < 12f && __instance.MineHasLineOfSight(((Component)player).transform.position) && Mathf.Abs(((Component)player).transform.position.y - ((Component)__instance).transform.position.y) < 0.2f)
					{
						playerNearby = true;
						playersToFollow.Add(player);
					}
					if (distance < 4f && __instance.MineHasLineOfSight(((Component)player).transform.position))
					{
						playerInExplRange = true;
					}
				}
				randomNum = Random.Range(0f, 1f);
				if (playerInExplRange && randomNum > 0.9f)
				{
				}
				if (playerNearby && randomNum > 0.85f && landmineBehaviour == 1)
				{
					int randomId = Random.Range(0, playersToFollow.Count);
					PlayerControllerB playerToFollow = playersToFollow[randomId];
					((MonoBehaviour)__instance).StartCoroutine(MoveTowardsPlayer(__instance, playerToFollow));
					randomNum = Random.Range(15f, 25f);
					yield return (object)new WaitForSeconds(randomNum);
				}
				if (landmineBehaviour == 2)
				{
					Vector3 newPosition = ((Component)__instance).transform.position;
					newPosition.x += Random.Range(-7f, 7f);
					newPosition.z += Random.Range(-7f, 7f);
					if (__instance.MineHasLineOfSight(newPosition))
					{
						((MonoBehaviour)__instance).StartCoroutine(MoveTowardsPosition(__instance, newPosition));
						randomNum = Random.Range(10f, 20f);
						yield return (object)new WaitForSeconds(randomNum);
					}
				}
				yield return (object)new WaitForSeconds(0.5f);
			}
			yield return null;
		}

		private static IEnumerator MoveTowardsPlayer(Landmine __instance, PlayerControllerB __instancePlayer)
		{
			float followTime = Random.Range(4f, 6f);
			float followSpeed = Random.Range(3.5f, 6.5f);
			if (followSpeed < 4.5f)
			{
				followTime += 4f;
			}
			float timer = followTime;
			while (timer > 0f)
			{
				Vector3 newMinePosition = Vector3.MoveTowards(((Component)__instance).transform.position, ((Component)__instancePlayer).transform.position, followSpeed * 0.01f);
				newMinePosition.y = ((Component)__instance).transform.position.y;
				((Component)__instance).transform.position = newMinePosition;
				timer -= 0.01f;
				yield return (object)new WaitForSeconds(0.01f);
			}
			yield return null;
		}

		private static IEnumerator MoveTowardsPosition(Landmine __instance, Vector3 newPosition)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			float followSpeed = Random.Range(5f, 7f);
			float timer = 2f;
			while (timer > 0f)
			{
				Vector3 newMinePosition = Vector3.MoveTowards(((Component)__instance).transform.position, newPosition, followSpeed * 0.01f);
				newMinePosition.y = ((Component)__instance).transform.position.y;
				((Component)__instance).transform.position = newMinePosition;
				timer -= 0.01f;
				yield return (object)new WaitForSeconds(0.01f);
			}
			yield return null;
		}
	}
	[HarmonyPatch(typeof(NoisemakerProp))]
	internal class NoisemakerPropPatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPostfix]
		private static void PlaySound(NoisemakerProp __instance)
		{
			if (((GrabbableObject)__instance).itemProperties.itemName == "Megaphone")
			{
				__instance.noiseAudio.PlayOneShot(ShitpostModBase.soundsNword);
				__instance.noiseAudioFar.PlayOneShot(ShitpostModBase.soundsNword);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch : MonoBehaviour
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(PlayerControllerB __instance, ref bool ___isFallingFromJump)
		{
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void UpdateAwake(ref float ___jumpForce, ref float ___grabDistance)
		{
		}

		[HarmonyPatch("PlayerHitGroundEffects")]
		[HarmonyPrefix]
		private static void UpdatePlayerHitGroundEffects(PlayerControllerB __instance)
		{
			if (__instance.hinderedMultiplier == 2f)
			{
				__instance.fallValueUncapped /= 2f;
				if (__instance.fallValueUncapped > -35f)
				{
					__instance.takingFallDamage = false;
				}
				else
				{
					__instance.fallValue = -25f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyPrefix]
		private static void SpawnMoreScrap(RoundManager __instance)
		{
		}

		[HarmonyPatch("SetChallengeFileRandomModifiers")]
		[HarmonyPostfix]
		private static void SpawnMoreHazards(RoundManager __instance)
		{
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(StartOfRound __instance)
		{
			__instance.shipIntroSpeechSFX = ShitpostModBase.soundShipStart;
		}
	}
}
namespace ShitpostMod.Objects
{
	internal class SanicItem : GrabbableObject
	{
		public override void Start()
		{
			((GrabbableObject)this).Start();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(ShitpostModBase.soundSonic);
		}

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

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

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

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

		private static IEnumerator ItemEffectSuperSpeed()
		{
			yield return null;
		}
	}
}