Decompiled source of LCMaskedInfestationMod v1.0.0

LCMaskedInfestationMod.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx.Logging;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LCMaskedInfestationMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LCMaskedInfestationMod")]
[assembly: AssemblyTitle("LCMaskedInfestationMod")]
[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 LCMaskedInfestationMod
{
	[BepInPlugin("local.SimonTendo.LCMaskedInfestationMod", "LCMaskedInfestationMod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin LCMaskedInfestationMod is loaded!");
			new Harmony("LCMaskedInfestationMod").Patch((MethodBase)typeof(RoundManager).GetMethod("RefreshEnemiesList", BindingFlags.Instance | BindingFlags.NonPublic), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(RoundManagerPatch).GetMethod("Transpiler")), (HarmonyMethod)null, (HarmonyMethod)null);
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class RoundManagerPatch
	{
		private static ManualLogSource Logger = Plugin.Logger;

		[HarmonyTranspiler]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			Logger.LogInfo((object)"Transpiler from LCMaskedInfestationMod compiling!");
			CodeInstruction item = Transpilers.EmitDelegate<Action>((Action)delegate
			{
				Logger.LogInfo((object)"Start of code by Transpiler from plugin LCMaskedInfestationMod!");
				DateTime dateTime = new DateTime(DateTime.Now.Year, 10, 23);
				bool flag = DateTime.Today == dateTime;
				Random random = new Random(StartOfRound.Instance.randomMapSeed + 5781);
				if ((!flag && random.Next(0, 210) < 3) || random.Next(0, 1000) < 15)
				{
					Logger.LogDebug((object)"Infestation: succeeded initial check");
					((Component)RoundManager.Instance.indoorFog).gameObject.SetActive(random.Next(0, 100) < 20);
					if (random.Next(0, 100) < 25)
					{
						Logger.LogDebug((object)"Infestation: succeeded Nutcracker check");
						for (int j = 0; j < RoundManager.Instance.currentLevel.Enemies.Count; j++)
						{
							if (RoundManager.Instance.currentLevel.Enemies[j].enemyType.enemyName == "Nutcracker")
							{
								RoundManager.Instance.enemyRushIndex = j;
								RoundManager.Instance.currentMaxInsidePower = 20f;
								break;
							}
						}
						if (RoundManager.Instance.enemyRushIndex == -1)
						{
							for (int k = 0; k < RoundManager.Instance.currentLevel.Enemies.Count; k++)
							{
								if (RoundManager.Instance.currentLevel.Enemies[k].enemyType.enemyName == "Hoarding bug")
								{
									RoundManager.Instance.enemyRushIndex = k;
									RoundManager.Instance.currentMaxInsidePower = 30f;
									break;
								}
							}
						}
					}
					else if (random.Next(0, 100) < 25)
					{
						Logger.LogDebug((object)"Infestation: succeeded custom Masked check");
						for (int l = 0; l < RoundManager.Instance.currentLevel.Enemies.Count; l++)
						{
							if (RoundManager.Instance.currentLevel.Enemies[l].enemyType.enemyName == "Masked")
							{
								RoundManager.Instance.enemyRushIndex = l;
								RoundManager.Instance.currentMaxInsidePower = 20f;
								break;
							}
						}
						if (RoundManager.Instance.enemyRushIndex == -1)
						{
							for (int m = 0; m < RoundManager.Instance.currentLevel.Enemies.Count; m++)
							{
								if (RoundManager.Instance.currentLevel.Enemies[m].enemyType.enemyName == "Hoarding bug")
								{
									RoundManager.Instance.enemyRushIndex = m;
									RoundManager.Instance.currentMaxInsidePower = 30f;
									break;
								}
							}
						}
					}
					else
					{
						Logger.LogDebug((object)"Infestation: default Hoarding bug body");
						for (int n = 0; n < RoundManager.Instance.currentLevel.Enemies.Count; n++)
						{
							if (RoundManager.Instance.currentLevel.Enemies[n].enemyType.enemyName == "Hoarding bug")
							{
								RoundManager.Instance.enemyRushIndex = n;
								RoundManager.Instance.currentMaxInsidePower = 30f;
								break;
							}
						}
					}
					Logger.LogDebug((object)$"Infestation: reached end of body with enemyRushIndex [{RoundManager.Instance.enemyRushIndex}]");
				}
				else
				{
					Logger.LogDebug((object)"Infestation: failed initial check");
					((Component)RoundManager.Instance.indoorFog).gameObject.SetActive(random.Next(0, 150) < 3);
				}
				Logger.LogInfo((object)"End of code by Transpiler from plugin LCMaskedInfestationMod.");
			});
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			for (int i = 0; i < list.Count - 1; i++)
			{
				CodeInstruction val = list[i];
				if (val.opcode == OpCodes.Call && ((MethodInfo)val.operand).Name == "get_Now")
				{
					Logger.LogDebug((object)$"successfully found {val} at [{i}]");
					int num2 = i - 1 + 151;
					string text = "callvirt void UnityEngine.GameObject::SetActive(bool value)";
					if (num2 < list.Count && ((object)list[num2]).ToString() == text)
					{
						Logger.LogDebug((object)$"successfully found {text} at [{num2}]");
						num = i;
					}
					else
					{
						Logger.LogWarning((object)$"Transpiler failed to find command ('{text}' at [{num2}]) from vanilla game, aborting check as to not break anything unwanted!!");
					}
					break;
				}
			}
			if (num == -1)
			{
				Logger.LogWarning((object)"Failed to find DateTime.get_Now() from RoundManager.RefreshEnemiesList()! Plugin LCMaskedInfestationMod will not execute.");
				return list;
			}
			Logger.LogDebug((object)"REMOVING OLD CODE");
			list.RemoveRange(num - 1, 152);
			Logger.LogDebug((object)"INSERTING NEW CODE");
			list.Insert(num - 1, item);
			Logger.LogDebug((object)"RETURNING CODE INSTRUCTIONS");
			return list;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LCMaskedInfestationMod";

		public const string PLUGIN_NAME = "LCMaskedInfestationMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}