Decompiled source of Non Lethal Company v1.3.1

NonLethalCompany.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NonLethalCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A BepInEx/Lethal Company plugin.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+288bcab600741722792cbe54081c4181be51d577")]
[assembly: AssemblyProduct("NonLethalCompany")]
[assembly: AssemblyTitle("NonLethalCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NonLethalCompany
{
	[BepInPlugin("NonLethalCompany", "NonLethalCompany", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance;

		private static GameObject _spikePrefab;

		private static bool _isFirst = true;

		private void Awake()
		{
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patch applying...");
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patch applied!");
		}

		[HarmonyPatch(typeof(CaveDwellerAI), "Start")]
		[HarmonyPostfix]
		private static void ManEaterBloodParticlesSoftPatch(CaveDwellerAI __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			MainModule main = __instance.killPlayerParticle1.main;
			((MainModule)(ref main)).maxParticles = 0;
			((MainModule)(ref main)).duration = 0f;
			((MainModule)(ref main)).startSize = new MinMaxCurve(0f);
			MainModule main2 = __instance.killPlayerParticle2.main;
			((MainModule)(ref main2)).maxParticles = 0;
			((MainModule)(ref main2)).duration = 0f;
			((MainModule)(ref main2)).startSize = new MinMaxCurve(0f);
		}

		[HarmonyPatch(typeof(KillLocalPlayer), "KillPlayer")]
		[HarmonyPrefix]
		private static bool FanRoomDecapitateSoftPatch(KillLocalPlayer __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00d3: 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)
			if ((int)__instance.causeOfDeath != 15)
			{
				return true;
			}
			__instance.deathAnimation = 0;
			__instance.causeOfDeath = (CauseOfDeath)15;
			if ((Object)(object)_spikePrefab != (Object)null)
			{
				__instance.spawnPrefab = _spikePrefab;
				return true;
			}
			GameObject val = Object.Instantiate<GameObject>(__instance.spawnPrefab);
			val.GetComponentsInChildren<ParticleSystem>().ToList().ForEach(delegate(ParticleSystem particleSystem)
			{
				//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_0025: Unknown result type (might be due to invalid IL or missing references)
				MainModule main = particleSystem.main;
				((MainModule)(ref main)).maxParticles = 0;
				((MainModule)(ref main)).duration = 0f;
				((MainModule)(ref main)).startSize = new MinMaxCurve(0f);
				Object.Destroy((Object)(object)particleSystem);
			});
			val.GetComponentsInChildren<AudioSource>().ToList().ForEach(delegate(AudioSource audioSource)
			{
				((Behaviour)audioSource).enabled = false;
			});
			Object.DontDestroyOnLoad((Object)(object)val);
			Transform transform = val.transform;
			transform.position += Vector3.down * 10000f;
			_spikePrefab = val;
			__instance.spawnPrefab = val;
			return true;
		}

		[HarmonyPatch(typeof(ButlerEnemyAI), "Start")]
		[HarmonyPostfix]
		private static void ButlerBloodParticleSoftPatch(ButlerEnemyAI __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			MainModule main = __instance.stabBloodParticle.main;
			((MainModule)(ref main)).maxParticles = 0;
			((MainModule)(ref main)).duration = 0f;
			((MainModule)(ref main)).startSize = new MinMaxCurve(0f);
			MainModule main2 = __instance.popParticle.main;
			((MainModule)(ref main2)).maxParticles = 0;
			((MainModule)(ref main2)).duration = 0f;
			((MainModule)(ref main2)).startSize = new MinMaxCurve(0f);
		}

		[HarmonyPatch(typeof(ButlerEnemyAI), "StabPlayerClientRpc")]
		[HarmonyPostfix]
		private static void ButlerStabParticleSoftPatch(ButlerEnemyAI __instance)
		{
			__instance.stabBloodParticle.Stop();
			__instance.stabBloodParticle.Clear();
		}

		[HarmonyPatch(typeof(ButlerEnemyAI), "KillEnemy")]
		[HarmonyPostfix]
		private static void ButlerPopParticleSoftPatch(ButlerEnemyAI __instance)
		{
			__instance.popParticle.Stop();
			__instance.popParticle.Clear();
		}

		[HarmonyPatch(typeof(KnifeItem), "ItemActivate")]
		[HarmonyPostfix]
		private static void KnifeBloodParticleSoftPatch(KnifeItem __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			MainModule main = __instance.bloodParticle.main;
			((MainModule)(ref main)).maxParticles = 0;
			((MainModule)(ref main)).duration = 0f;
			((MainModule)(ref main)).startSize = new MinMaxCurve(0f);
		}

		[HarmonyPatch(typeof(SpikeRoofTrap), "Start")]
		[HarmonyPostfix]
		private static void SpikeTrapBloodParticleSoftPatch(SpikeRoofTrap __instance)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_spikePrefab != (Object)null)
			{
				__instance.deadBodyStickingPointPrefab = _spikePrefab;
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(__instance.deadBodyStickingPointPrefab);
			val.GetComponentsInChildren<ParticleSystem>().ToList().ForEach(delegate(ParticleSystem particleSystem)
			{
				//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_0025: Unknown result type (might be due to invalid IL or missing references)
				MainModule main = particleSystem.main;
				((MainModule)(ref main)).maxParticles = 0;
				((MainModule)(ref main)).duration = 0f;
				((MainModule)(ref main)).startSize = new MinMaxCurve(0f);
				Object.Destroy((Object)(object)particleSystem);
			});
			val.GetComponentsInChildren<AudioSource>().ToList().ForEach(delegate(AudioSource audioSource)
			{
				((Behaviour)audioSource).enabled = false;
			});
			Object.DontDestroyOnLoad((Object)(object)val);
			Transform transform = val.transform;
			transform.position += Vector3.down * 10000f;
			_spikePrefab = val;
			__instance.deadBodyStickingPointPrefab = val;
		}

		[HarmonyPatch(typeof(ForestGiantAI), "Start")]
		[HarmonyPostfix]
		private static void ForestGiantAnimationSoftPatch(ForestGiantAI __instance)
		{
			AnimationClip val = ((EnemyAI)__instance).creatureAnimator.runtimeAnimatorController.animationClips.First((AnimationClip clip) => ((Object)clip).name.Equals("FGiantEatPlayer"));
			val.events = val.events.Where((AnimationEvent animEvent) => !animEvent.functionName.Equals("PlayParticle")).ToArray();
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ForestGiantHardPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ForestGiantAI), "bloodOnFaceDecal"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Behaviour), "set_enabled", (Type[])null, (Type[])null), (string)null)
			}).RemoveInstructions(4);
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SpawnDeadBody")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SpawnBodiesHardPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null)
			}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldc_I4, (object)0),
				new CodeInstruction(OpCodes.Starg, (object)5)
			});
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlayerControllerB), "bodyBloodDecals"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldlen, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Conv_I4, (object)null, (string)null)
			}).Advance(-1).SetAndAdvance(OpCodes.Nop, (object)null)
				.RemoveInstructions(5);
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "UpdatePlayerPositionClientRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> UpdatePositionHardPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[6]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlayerControllerB), "bleedingHeavily"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(PlayerControllerB), "DropBlood", (Type[])null, (Type[])null), (string)null)
			}).SetAndAdvance(OpCodes.Nop, (object)null).RemoveInstructions(5);
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientClientRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DamageRPCHardPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldarg_2, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(PlayerControllerB), "DropBlood", (Type[])null, (Type[])null), (string)null)
			}).RemoveInstructions(36);
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DropBlood")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DropBloodHardPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null)
			}).SetAndAdvance(OpCodes.Ret, (object)null);
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "AddBloodToBody")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> AddBloodToBodyHardPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null)
			}).SetAndAdvance(OpCodes.Ret, (object)null);
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(DeadBodyInfo), "MakeCorpseBloody")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> MakeCorpseBloodyHardPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null)
			}).SetAndAdvance(OpCodes.Ret, (object)null);
			return val.InstructionEnumeration();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NonLethalCompany";

		public const string PLUGIN_NAME = "NonLethalCompany";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}