polic72.LCR2.dll

Decompiled 17 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("polic72.LCR2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+8cf7c02ac6c4af05e54c32b241cc9865e0a5f30d")]
[assembly: AssemblyProduct("lcr2")]
[assembly: AssemblyTitle("polic72.LCR2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 lcr2
{
	[BepInPlugin("polic72.LCR2", "lcr2", "1.0.1")]
	public class lcr2 : BaseUnityPlugin
	{
		public static lcr2 Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"polic72.LCR2 v1.0.1 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("polic72.LCR2");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "polic72.LCR2";

		public const string PLUGIN_NAME = "lcr2";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace lcr2.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	public class IndoorEnemiesPatch
	{
		[HarmonyPatch(typeof(RoundManager), "PlotOutEnemiesForNextHour")]
		[HarmonyPrefix]
		public static void PlotOutEnemiesForNextHour(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.IndoorEnemiesLevel;
		}

		[HarmonyPatch(typeof(RoundManager), "AssignRandomEnemyToVent")]
		[HarmonyPrefix]
		public static void AssignRandomEnemyToVent(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.IndoorEnemiesLevel;
		}

		[HarmonyPatch(typeof(RoundManager), "AssignRandomEnemyToVent")]
		[HarmonyPostfix]
		public static void AssignRandomEnemyToVent_PostDebug(RoundManager __instance, EnemyVent vent)
		{
			lcr2.Logger.LogInfo((object)("Assigned a " + ((Object)vent.enemyType).name + " to vent " + ((Object)vent).name));
		}

		[HarmonyPatch(typeof(RoundManager), "InsideEnemyCannotBeSpawned")]
		[HarmonyPrefix]
		public static void EnemyCannotBeSpawned(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.IndoorEnemiesLevel;
		}

		[HarmonyPatch(typeof(RoundManager), "BeginEnemySpawning")]
		[HarmonyPrefix]
		public static void BeginEnemySpawning(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.IndoorEnemiesLevel;
		}

		[HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")]
		[HarmonyPrefix]
		public static void RefreshEnemyList(RoundManager __instance)
		{
			__instance.currentLevel.maxEnemyPowerCount = RandomManager.IndoorEnemiesLevel?.maxEnemyPowerCount ?? 0;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class OutdoorEnemiesPatch
	{
		[HarmonyPatch(typeof(RoundManager), "PredictAllOutsideEnemies")]
		[HarmonyPrefix]
		public static void PredictAllOutsideEnemies(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.OutdoorEnemiesLevel;
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnEnemiesOutside")]
		[HarmonyPrefix]
		public static void SpawnEnemiesOutside(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.OutdoorEnemiesLevel;
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnRandomOutsideEnemy")]
		[HarmonyPrefix]
		public static void SpawnRandomOutsideEnemy(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.OutdoorEnemiesLevel;
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnRandomOutsideEnemy")]
		[HarmonyPostfix]
		public static void SpawnRandomOutsideEnemy_Debug(RoundManager __instance)
		{
			EnemyAI val = __instance.SpawnedEnemies[__instance.SpawnedEnemies.Count - 1];
			lcr2.Logger.LogInfo((object)("Spawned " + ((Object)val.enemyType).name + " outside"));
		}

		[HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")]
		[HarmonyPrefix]
		public static void RefreshEnemiesList(RoundManager __instance)
		{
			__instance.currentLevel.maxOutsideEnemyPowerCount = RandomManager.OutdoorEnemiesLevel?.maxOutsideEnemyPowerCount ?? 0;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class RandomManager
	{
		protected static readonly Random Random = new Random();

		public static SelectableLevel? RealLevel;

		public static SelectableLevel? ScrapLevel;

		public static SelectableLevel? IndoorEnemiesLevel;

		public static SelectableLevel? OutdoorEnemiesLevel;

		public static string? log_text;

		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPrefix]
		private static void LoadNewLevel(RoundManager __instance)
		{
			log_text = RollLevels(__instance);
			if (!((Object)(object)RealLevel == (Object)null) && !((Object)(object)ScrapLevel == (Object)null) && !((Object)(object)IndoorEnemiesLevel == (Object)null) && !((Object)(object)OutdoorEnemiesLevel == (Object)null))
			{
				lcr2.Logger.LogInfo((object)("The actual level is \"" + RealLevel.PlanetName + "\""));
				lcr2.Logger.LogInfo((object)("The scrap level is \"" + ScrapLevel.PlanetName + "\""));
				lcr2.Logger.LogInfo((object)("The indoor level is \"" + IndoorEnemiesLevel.PlanetName + "\""));
				lcr2.Logger.LogInfo((object)("The OutdoorEnemiesLevel level is \"" + OutdoorEnemiesLevel.PlanetName + "\""));
			}
		}

		public static string RollLevels(RoundManager roundManager)
		{
			StringBuilder stringBuilder = new StringBuilder(256);
			RealLevel = roundManager.currentLevel;
			stringBuilder.Append("Map: " + RealLevel.PlanetName + "\n");
			do
			{
				ScrapLevel = roundManager.playersManager.levels[Random.Next(0, roundManager.playersManager.levels.Length)];
			}
			while (ScrapLevel.PlanetName == "71 Gordion");
			stringBuilder.Append("Scrap: " + ScrapLevel.PlanetName + "\n");
			IndoorEnemiesLevel = roundManager.playersManager.levels[Random.Next(0, roundManager.playersManager.levels.Length)];
			stringBuilder.Append("Indoor: " + IndoorEnemiesLevel.PlanetName + "\n");
			do
			{
				OutdoorEnemiesLevel = roundManager.playersManager.levels[Random.Next(0, roundManager.playersManager.levels.Length)];
				lcr2.Logger.LogInfo((object)("Outdoor level (now " + OutdoorEnemiesLevel.PlanetName + ") was liquidation before"));
			}
			while (OutdoorEnemiesLevel.PlanetName == "44 Liquidation");
			stringBuilder.Append("Outdoor: " + OutdoorEnemiesLevel.PlanetName + "\n");
			return stringBuilder.ToString();
		}

		public static void RollLevels_Debug(RoundManager roundManager)
		{
			RealLevel = roundManager.currentLevel;
			SelectableLevel val = null;
			for (int i = 0; i < roundManager.playersManager.levels.Length; i++)
			{
				SelectableLevel val2 = roundManager.playersManager.levels[i];
				string text = val2.PlanetName.ToLower();
				if (text.StartsWith("7") && text.Contains("dine"))
				{
					val = val2;
				}
			}
			ScrapLevel = val ?? RealLevel;
			IndoorEnemiesLevel = val ?? RealLevel;
			OutdoorEnemiesLevel = val ?? RealLevel;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class ScrapPatch
	{
		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPrefix]
		public static void SpawnScrapInLevel(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.ScrapLevel;
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")]
		[HarmonyPrefix]
		public static void SpawnMapObjects(RoundManager __instance)
		{
			__instance.currentLevel = RandomManager.ScrapLevel;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatch
	{
		[HarmonyPatch("EndOfGame")]
		[HarmonyPrefix]
		private static void EndOfGame(StartOfRound __instance)
		{
			if (((NetworkBehaviour)__instance).NetworkManager.IsServer)
			{
				HUDManager.Instance.AddTextToChatOnServer(RandomManager.log_text, -1);
			}
		}
	}
}