using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; using UnlimitedRoach.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("UnlimitedRoach")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+f1a1d61e460b5fdf451a256b0057450495d462a8")] [assembly: AssemblyProduct("UnlimitedRoach")] [assembly: AssemblyTitle("UnlimitedRoach")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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 UnlimitedRoach { [BepInPlugin("com.prideunique.unlimitedroach", "UnlimitedRoach", "1.0.1")] public sealed class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.prideunique.unlimitedroach"; public const string PLUGIN_NAME = "UnlimitedRoach"; public const string PLUGIN_VERSION = "1.0.1"; private Harmony harmony; internal static ManualLogSource Logger { get; private set; } private void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; harmony = new Harmony("com.prideunique.unlimitedroach"); Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttribute() != null) { harmony.PatchAll(type); } } SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneLoaded += OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)mode == 1 || CL_AssetManager.instance == null || !CL_AssetManager.instance.initialized) { return; } WKAssetDatabase fullCombinedAssetDatabase = CL_AssetManager.GetFullCombinedAssetDatabase(); if ((Object)(object)fullCombinedAssetDatabase == (Object)null) { return; } List list = new List(); foreach (M_Gamemode gamemodeAsset4 in fullCombinedAssetDatabase.gamemodeAssets) { foreach (GamemodeSetting gamemodeSetting in gamemodeAsset4.gamemodeSettings) { if (!list.Contains(gamemodeSetting)) { list.Add(gamemodeSetting); } } } GamemodeSetting val = null; GamemodeSetting val2 = null; foreach (GamemodeSetting item in list) { if (item.id == "unlimited") { val = item; } else if (item.id == "competitive") { val2 = item; } } if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { GamemodeSetting val3 = Object.Instantiate(val); val3.unlock = val2.unlock; M_Gamemode gamemodeAsset = CL_AssetManager.GetGamemodeAsset("Campaign", ""); M_Gamemode gamemodeAsset2 = CL_AssetManager.GetGamemodeAsset(" Chimney", ""); M_Gamemode gamemodeAsset3 = CL_AssetManager.GetGamemodeAsset("Chimney", ""); if ((Object)(object)gamemodeAsset != (Object)null && gamemodeAsset.gamemodeSettings.All((GamemodeSetting gamemodeSetting) => gamemodeSetting.id != "unlimited")) { gamemodeAsset.gamemodeSettings.Add(val3); Debug.Log((object)"[UnlimitedRoach] Added unlimited roaches game mode to campaign"); } if ((Object)(object)gamemodeAsset2 != (Object)null && gamemodeAsset2.gamemodeSettings.All((GamemodeSetting gamemodeSetting) => gamemodeSetting.id != "unlimited")) { gamemodeAsset2.gamemodeSettings.Add(val); Debug.Log((object)"[UnlimitedRoach] Added unlimited roaches game mode to chimney"); } if ((Object)(object)gamemodeAsset3 != (Object)null && gamemodeAsset3.gamemodeSettings.All((GamemodeSetting gamemodeSetting) => gamemodeSetting.id != "unlimited")) { gamemodeAsset3.gamemodeSettings.Add(val); Debug.Log((object)"[UnlimitedRoach] Added unlimited roaches game mode to chimney"); } } } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; M_Gamemode gamemodeAsset = CL_AssetManager.GetGamemodeAsset("Campaign", ""); M_Gamemode gamemodeAsset2 = CL_AssetManager.GetGamemodeAsset(" Chimney", ""); M_Gamemode gamemodeAsset3 = CL_AssetManager.GetGamemodeAsset("Chimney", ""); if ((Object)(object)gamemodeAsset != (Object)null) { gamemodeAsset.gamemodeSettings.RemoveAll((GamemodeSetting gmSetting) => gmSetting.id == "unlimited"); } if ((Object)(object)gamemodeAsset2 != (Object)null) { gamemodeAsset2.gamemodeSettings.RemoveAll((GamemodeSetting gmSetting) => gmSetting.id == "unlimited"); } if ((Object)(object)gamemodeAsset3 != (Object)null) { gamemodeAsset3.gamemodeSettings.RemoveAll((GamemodeSetting gmSetting) => gmSetting.id == "unlimited"); } Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } } namespace UnlimitedRoach.Patches { [PatchOnEntry] [HarmonyPatch] public class CL_GameManagerPatch { [HarmonyPatch(typeof(CL_GameManager), "AreAchievementsAllowed")] [HarmonyPrefix] private static bool CL_GameManagerAreAchievementsAllowed(CL_GameManager __instance, ref bool __result) { if ((Object)(object)CL_GameManager.gamemode == (Object)null) { return true; } bool num = CL_GameManager.gamemode.gamemodeName == "Campaign"; bool flag = CL_GameManager.gamemode.gamemodeName == " Chimney" || CL_GameManager.gamemode.gamemodeName == "Chimney"; bool flag2 = CL_GameManager.gamemode.HasActiveSetting("unlimited"); if ((num || flag) && flag2) { __result = false; return false; } return true; } } [PatchOnEntry] [HarmonyPatch] public class ENT_PlayerPatch { [HarmonyPatch(typeof(ENT_Player), "AchievementCheck")] [HarmonyPrefix] private static bool ENT_PlayerAchievementCheck(ENT_Player __instance) { if ((Object)(object)CL_GameManager.gamemode == (Object)null) { return true; } bool num = CL_GameManager.gamemode.gamemodeName == "Campaign"; bool flag = CL_GameManager.gamemode.gamemodeName == " Chimney" || CL_GameManager.gamemode.gamemodeName == "Chimney"; bool flag2 = CL_GameManager.gamemode.HasActiveSetting("unlimited"); if ((num || flag) && flag2) { return false; } return true; } } [PatchOnEntry] [HarmonyPatch] public class M_GamemodePatch { [HarmonyPatch(typeof(M_Gamemode), "Finish")] [HarmonyPrefix] private static bool M_GamemodeFinish(M_Gamemode __instance) { bool num = __instance.gamemodeName == "Campaign"; bool flag = __instance.gamemodeName == " Chimney" || __instance.gamemodeName == "Chimney"; bool flag2 = __instance.HasActiveSetting("unlimited"); if ((num || flag) && flag2) { Debug.Log((object)"[UnlimitedRoach] Blocking leaderboard submission"); return false; } return true; } } } namespace UnlimitedRoach.Core { [PublicAPI] [AttributeUsage(AttributeTargets.Class, Inherited = false)] internal sealed class PatchOnEntryAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }