Decompiled source of LeanCompany v1.0.1

LeanCompany.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Timers;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LeanCompany.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("LeanCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LeanCompany")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("42b5ed3c-8f86-4e12-9257-46a16f7bf5b7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace LeanCompany
{
	[BepInPlugin("Tomato.LeanCompany", "Lean Company Mod", "1.0.0.0")]
	public class LeanCompanyMod : BaseUnityPlugin
	{
		private const string modGUID = "Tomato.LeanCompany";

		private const string modName = "Lean Company Mod";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Tomato.LeanCompany");

		private static LeanCompanyMod Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Tomato.LeanCompany");
			mls.LogInfo((object)"LeanCompanyMod loaded");
			harmony.PatchAll(typeof(LeanCompanyMod));
			harmony.PatchAll(typeof(EnemyDamagePatches));
			harmony.PatchAll(typeof(BlobPatches));
		}
	}
}
namespace LeanCompany.Patches
{
	[HarmonyPatch(typeof(BlobAI))]
	internal class BlobPatches
	{
		private static int _gradientColorProperty = Shader.PropertyToID("_Gradient_Color");

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPrefix(BlobAI __instance)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			__instance.thisSlimeMaterial.SetColor(_gradientColorProperty, Color.magenta);
		}
	}
	[HarmonyPatch]
	internal class EnemyDamagePatches
	{
		private static Timer _delayTimer;

		private static bool isSpeedChanged;

		private static IEnumerable<MethodBase> TargetMethods()
		{
			return typeof(BlobAI).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator ilGenerator)
		{
			MethodInfo damagePlayerMethod = AccessTools.Method(typeof(PlayerControllerB), "DamagePlayer", (Type[])null, (Type[])null);
			MethodInfo damagePlayerRedirect = AccessTools.Method(typeof(EnemyDamagePatches), "InterceptBlobDamage", (Type[])null, (Type[])null);
			foreach (CodeInstruction instruction in instructions)
			{
				if (instruction.opcode == OpCodes.Callvirt && instruction.operand == damagePlayerMethod)
				{
					yield return new CodeInstruction(OpCodes.Call, (object)damagePlayerRedirect);
				}
				else
				{
					yield return instruction;
				}
			}
		}

		private static void InterceptBlobDamage(PlayerControllerB player, int damageNumber, bool hasDamageSFX, bool callRPC, CauseOfDeath causeOfDeath, int deathAnimation, bool fallDamage, Vector3 force)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			player.DamagePlayer(85, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
		}
	}
}