Decompiled source of MoreFun v1.2.0

MoreFun.dll

Decompiled 7 months ago
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using MoreFun.patches;
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("MoreFun")]
[assembly: AssemblyDescription("A mod that make the game funnier and better")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreFun")]
[assembly: AssemblyCopyright("Copyright IanTapply22 ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1e3ab1ab-4496-4444-a788-c8b977dd79c9")]
[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 MoreFun
{
	internal class Configuration
	{
		public static ConfigEntry<bool> enableExperimentationMode;

		public static ConfigEntry<bool> enableAllEnemyVentsOpen;

		public static ConfigEntry<bool> enableSilentLandmines;

		public static ConfigEntry<bool> enableFlashlightsConnectedToShip;

		public static ConfigEntry<bool> enableLightsGoBoom;

		public static ConfigEntry<bool> enableAlwaysFlickerLights;

		public static ConfigEntry<bool> enableSlowCoilHead;

		public static ConfigEntry<bool> enableNutcrackerFastTurn;

		public static ConfigEntry<bool> enableTestBodyMode;

		public static ConfigEntry<bool> enableSilentSandWorm;

		public static ConfigEntry<bool> enableFastCoil;

		public static ConfigEntry<bool> enableFullViewTurrets;

		public static void Init()
		{
			enableExperimentationMode = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Experimentation Mode", false, "Enable this to enable all the other options. This is for testing purposes only. ENABLE AT YOUR OWN RISK");
			enableAllEnemyVentsOpen = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable All Enemy Vents Open", true, "Enable this to make all enemy vents open by default but still usable.");
			enableSilentLandmines = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Silent Landmines", true, "Enable this to make landmines silent.");
			enableFlashlightsConnectedToShip = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Flashlights Connected To Ship", true, "Enable this to make flashlights connected to the ship lights, this will trigger lights rarely.");
			enableLightsGoBoom = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Lights Go Boom", true, "Enable this to make lights blow up sometimes, stop messing with the ship lights.");
			enableAlwaysFlickerLights = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Always Flicker Lights", true, "Enable this to make lights always flicker.");
			enableSlowCoilHead = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Slow Coil Head", true, "Enable this to make coil heads slow when they sneak up on you.");
			enableNutcrackerFastTurn = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Nutcracker Fast Turn", true, "Enable this to make nutcrackers turn fast.");
			enableTestBodyMode = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Test Body Mode", false, "Enable this to make ragdolls test bodies.");
			enableSilentSandWorm = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Silent Sand Worm", true, "Enable this to make sand worms silent.");
			enableFastCoil = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Fast Coil", true, "Enable this to make coil heads fast.");
			enableFullViewTurrets = ((BaseUnityPlugin)MoreFunBase.instance).Config.Bind<bool>("Experimentation Mode", "Enable Full View Turrets", true, "Enable this to make turrets have a full view around them.");
		}
	}
	[BepInPlugin("me.iantapply.morefun", "MoreFun", "1.2.0")]
	public class MoreFunBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("me.iantapply.morefun");

		public static MoreFunBase instance;

		internal ManualLogSource log;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			log = ((BaseUnityPlugin)this).Logger;
			log.LogInfo((object)"MoreFun lethal company mod loading...");
			Configuration.Init();
			log.LogInfo((object)"MoreFun configuration loaded. Loading patches...");
			if (Configuration.enableExperimentationMode.Value)
			{
				harmony.PatchAll(typeof(AlwaysDrunkPatch));
				harmony.PatchAll(typeof(LoudBoss));
				harmony.PatchAll(typeof(LongLadder));
			}
			if (Configuration.enableAllEnemyVentsOpen.Value)
			{
				harmony.PatchAll(typeof(MakeEnemyVentsAllOpen));
			}
			if (Configuration.enableSilentLandmines.Value)
			{
				harmony.PatchAll(typeof(SilentLandmines));
			}
			if (Configuration.enableFlashlightsConnectedToShip.Value)
			{
				harmony.PatchAll(typeof(FlashlightsConnectedToShipLights));
			}
			if (Configuration.enableLightsGoBoom.Value)
			{
				harmony.PatchAll(typeof(LightsGoBoom));
			}
			if (Configuration.enableAlwaysFlickerLights.Value)
			{
				harmony.PatchAll(typeof(GuysIThinkItsAJinn));
			}
			if (Configuration.enableSlowCoilHead.Value)
			{
				harmony.PatchAll(typeof(SlowCoil));
			}
			if (Configuration.enableNutcrackerFastTurn.Value)
			{
				harmony.PatchAll(typeof(NutterPopAndLock));
			}
			if (Configuration.enableTestBodyMode.Value)
			{
				harmony.PatchAll(typeof(YouAreTestSubject));
			}
			if (Configuration.enableSilentSandWorm.Value)
			{
				harmony.PatchAll(typeof(WormGummy));
			}
			if (Configuration.enableFastCoil.Value)
			{
				harmony.PatchAll(typeof(FastCoil));
			}
			if (Configuration.enableFullViewTurrets.Value)
			{
				harmony.PatchAll(typeof(ILikeToSeeALot));
			}
			log.LogInfo((object)"MoreFun patches loaded. Happy playing!");
		}
	}
	internal class PluginModInfo
	{
		public const string MOD_GUID = "me.iantapply.morefun";

		public const string MOD_NAME = "MoreFun";

		public const string MOD_VERSION = "1.2.0";
	}
}
namespace MoreFun.patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class AlwaysDrunkPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void alwaysDrunkPatch(ref float ___drunknessInertia, ref bool ___increasingDrunknessThisFrame)
		{
			___drunknessInertia = 1.3f;
			___increasingDrunknessThisFrame = false;
		}
	}
	[HarmonyPatch(typeof(SelectableLevel))]
	internal class CouldYouHurryUp
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void sooooooooooSlowwwwwwwwwww(SelectableLevel __instance)
		{
			__instance.timeToArrive = 18f;
		}
	}
	[HarmonyPatch(typeof(SpringManAI))]
	internal class FastCoil
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void fastAhhhhCoilHead(ref float ___currentChaseSpeed)
		{
			___currentChaseSpeed = 30f;
		}
	}
	[HarmonyPatch(typeof(FlashlightItem))]
	internal class FlashlightsConnectedToShipLights
	{
		[HarmonyPatch("SwitchFlashlight")]
		[HarmonyPostfix]
		private static void makeFlashlightsConnectedToShipLights()
		{
			if (Random.Range(0, 27) == 14)
			{
				Object.FindObjectOfType<ShipLights>().ToggleShipLightsOnLocalClientOnly();
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class GuysIThinkItsAJinn
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void ahhhhhhhFlashlightsGoFlicky(RoundManager __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(lightGoOffAndOn(__instance, flickerFlashlights: true, disableFlashlights: true));
		}

		private static IEnumerator lightGoOffAndOn(RoundManager __instance, bool flickerFlashlights = false, bool disableFlashlights = false)
		{
			Debug.Log((object)"Flickering lights");
			if (flickerFlashlights)
			{
				Debug.Log((object)"Flickering flashlights");
				FlashlightItem.globalFlashlightInterferenceLevel = 1;
				FlashlightItem[] array = Object.FindObjectsOfType<FlashlightItem>();
				if (array != null)
				{
					for (int i = 0; i < array.Length; i++)
					{
						array[i].flashlightAudio.Stop();
						array[i].flashlightAudio.volume = 0f;
						if (disableFlashlights && (Object)(object)((GrabbableObject)array[i]).playerHeldBy != (Object)null && ((GrabbableObject)array[i]).playerHeldBy.isInsideFactory)
						{
							array[i].flashlightInterferenceLevel = 2;
						}
					}
				}
			}
			if (__instance.allPoweredLightsAnimators.Count > 0 && (Object)(object)__instance.allPoweredLightsAnimators[0] != (Object)null)
			{
				int loopCount = 0;
				int b = 4;
				while (b > 0 && b != 0)
				{
					for (int j = loopCount; j < __instance.allPoweredLightsAnimators.Count / b; j++)
					{
						loopCount++;
						__instance.allPoweredLightsAnimators[j].SetTrigger("Flicker");
					}
					yield return (object)new WaitForSeconds(0.05f);
					b--;
				}
			}
			if (!flickerFlashlights)
			{
				yield break;
			}
			yield return (object)new WaitForSeconds(0.3f);
			FlashlightItem[] array2 = Object.FindObjectsOfType<FlashlightItem>();
			if (array2 != null)
			{
				for (int k = 0; k < array2.Length; k++)
				{
					array2[k].flashlightInterferenceLevel = 0;
				}
			}
			FlashlightItem.globalFlashlightInterferenceLevel = 0;
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class ILikeToSeeALot
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void aroundTheWorld(Turret __instance)
		{
			__instance.rotationRange = 359f;
		}
	}
	[HarmonyPatch(typeof(ShipLights))]
	internal class LightsGoBoom
	{
		[HarmonyPatch("ToggleShipLights")]
		[HarmonyPostfix]
		private static void lightsGoBoom()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (Random.Range(0, 30) == 3)
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				Vector3 val = (((Component)localPlayerController.gameplayCamera).transform.position - ((Component)localPlayerController.gameplayCamera).transform.position) * 80f / Vector3.Distance(((Component)localPlayerController.gameplayCamera).transform.position, ((Component)localPlayerController.gameplayCamera).transform.position);
				localPlayerController.KillPlayer(val, true, (CauseOfDeath)3, 0);
			}
		}
	}
	[HarmonyPatch(typeof(ExtensionLadderItem))]
	internal class LongLadder
	{
		[HarmonyPatch("GetLadderExtensionDistance")]
		private static float GetLadderExtensionDistance(ExtensionLadderItem __instance)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			int num = 268437761;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(((Component)__instance.baseNode).transform.position, Vector3.up, ref val, 15f, num, (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref val)).distance;
			}
			return 15f;
		}
	}
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class LoudBoss
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void makeBossLoud(DepositItemsDesk __instance)
		{
			__instance.MakeLoudNoise(1);
		}
	}
	[HarmonyPatch(typeof(EnemyVent))]
	internal class MakeEnemyVentsAllOpen
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void makeVentsAllOpen(EnemyVent __instance)
		{
			__instance.OpenVentClientRpc();
		}
	}
	[HarmonyPatch(typeof(NutcrackerEnemyAI))]
	internal class NutterPopAndLock
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void turnMugShot(NutcrackerEnemyAI __instance)
		{
			__instance.torsoTurnSpeed = 8f;
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class SilentLandmines
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void makeAllLandminesSilent(Landmine __instance)
		{
			__instance.mineAudio.volume = 0f;
			__instance.mineFarAudio.volume = 0f;
			__instance.hasExploded = true;
		}
	}
	[HarmonyPatch(typeof(SpringManAI))]
	internal class SlowCoil
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void slowAhhhhCoilHead(ref float ___currentChaseSpeed)
		{
			___currentChaseSpeed = 5f;
		}
	}
	[HarmonyPatch(typeof(SandWormAI))]
	internal class WormGummy
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void makeWormGummy(SandWormAI __instance)
		{
			((EnemyAI)__instance).creatureSFX.Stop();
		}
	}
	[HarmonyPatch(typeof(RagdollGrabbableObject))]
	internal class YouAreTestSubject
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void strangerThingsTestSubject(RagdollGrabbableObject __instance)
		{
			__instance.testBody = true;
		}
	}
}