Decompiled source of LevelScaling v0.7.0
LevelScaling.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using LevelScaling.LevelStats; using LevelScaling.Patches; using Photon.Pun; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("LevelScaling")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LevelScaling")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("94187d6e-952a-4336-b083-0210fe153e6f")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace LevelScaling { public class ChallengeManager { public enum ChallengeType { None, LightsOut, HighQuota, LargeMap, EnemyRush, FragileValuables, IncreasedDamage, HiddenInformation, FoggyLevel, TimeAttack, OverOvercharge, NoMap, RadiationWarning } public class Challenge { public ChallengeType type; public string name; public int startingLevel; public string info; public int Weight => type switch { ChallengeType.LightsOut => Plugin.ChallengeChanceMultiplier_LightsOut.Value, ChallengeType.HighQuota => Plugin.ChallengeChanceMultiplier_HighQuota.Value, ChallengeType.LargeMap => Plugin.ChallengeChanceMultiplier_LargeMap.Value, ChallengeType.FoggyLevel => Plugin.ChallengeChanceMultiplier_FoggyLevel.Value, ChallengeType.IncreasedDamage => Plugin.ChallengeChanceMultiplier_IncreasedDamage.Value, ChallengeType.FragileValuables => Plugin.ChallengeChanceMultiplier_FragileValuables.Value, ChallengeType.OverOvercharge => Plugin.ChallengeChanceMultiplier_OverOvercharge.Value, ChallengeType.NoMap => Plugin.ChallengeChanceMultiplier_NoMap.Value, ChallengeType.EnemyRush => Plugin.ChallengeChanceMultiplier_EnemyRush.Value, ChallengeType.HiddenInformation => Plugin.ChallengeChanceMultiplier_HiddenInformation.Value, _ => 0, }; public Challenge(ChallengeType type, string name, int startingLevel, string info) { this.type = type; this.name = name; this.startingLevel = startingLevel; this.info = info; } } public static List<ChallengeType> currentChallenges = new List<ChallengeType>(); public static ChallengeType forceChallenge = ChallengeType.None; public static NetworkedEvent ChallengeSync; public static Dictionary<string, int> challengesDofD = new Dictionary<string, int> { { "currentSeed", 1 }, { "lastChallengeLevel", -1 }, { "lastChallengeType", -1 } }; public static readonly List<Challenge> allChallenges = new List<Challenge> { new Challenge(ChallengeType.LightsOut, "Lights Out", 3, "The level's lights have stopped working.<br>Use your flashlight well."), new Challenge(ChallengeType.HighQuota, "Overtime", 7, "Taxman is requiring extra effort for this level.<br>Your quotas will be significantly higher."), new Challenge(ChallengeType.LargeMap, "Enlarged Level", 12, "This level appears to be much larger than normal.<br>Remember to use your map."), new Challenge(ChallengeType.FoggyLevel, "Dense Fog", 15, "There seems to be lots of fog on this level.<br>Visibility will be low, tread carefully."), new Challenge(ChallengeType.IncreasedDamage, "Increased Damage", 5, "All incoming damage for both Semibots and enemies<br>will be greatly increased. Be careful."), new Challenge(ChallengeType.FragileValuables, "Fragile Valuables", 15, "All valuables are very fragile, regardless of how they<br>look on the outside. Each valuable will be priced slightly higher."), new Challenge(ChallengeType.OverOvercharge, "Over-Overcharge", 10, "Overcharge will build up from holding valuables too.<br>Pay close attention and don't explode yourself."), new Challenge(ChallengeType.NoMap, "Broken Map", 7, "Your map is disabled, however Semibots will naturally<br>regenerate health slowly; up to the health they started the level with."), new Challenge(ChallengeType.EnemyRush, "Enemy Rush", 10, "There are many more enemies than usual on this level,<br>but enemies are lighter, and have significantly reduced health."), new Challenge(ChallengeType.HiddenInformation, "Hidden Information", 10, "This level is much shorter than others,<br>but some information will be obstructed.") }; public static int CurrentSeed { get { if (!challengesDofD.ContainsKey("currentSeed")) { challengesDofD.Add("currentSeed", 1); } return challengesDofD["currentSeed"]; } set { if (!challengesDofD.ContainsKey("currentSeed")) { challengesDofD.Add("currentSeed", value); } else { challengesDofD["currentSeed"] = value; } } } public static int LastChallengeLevel { get { if (!challengesDofD.ContainsKey("lastChallengeLevel")) { challengesDofD.Add("lastChallengeLevel", -1); } return challengesDofD["lastChallengeLevel"]; } set { if (!challengesDofD.ContainsKey("lastChallengeLevel")) { challengesDofD.Add("lastChallengeLevel", value); } else { challengesDofD["lastChallengeLevel"] = value; } } } public static int LastChallengeType { get { if (!challengesDofD.ContainsKey("lastChallengeType")) { challengesDofD.Add("lastChallengeType", -1); } return challengesDofD["lastChallengeType"]; } set { if (!challengesDofD.ContainsKey("lastChallengeType")) { challengesDofD.Add("lastChallengeType", value); } else { challengesDofD["lastChallengeType"] = value; } } } public static bool IsChallengeActive(ChallengeType challenge) { return currentChallenges.Contains(challenge); } public static Challenge GetChallenge(ChallengeType challenge) { foreach (Challenge allChallenge in allChallenges) { if (allChallenge.type == challenge) { return allChallenge; } } return new Challenge(ChallengeType.None, "????????", 0, "Unknown challenge - can't get any info. Sorry!"); } public static void Setup() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown ChallengeSync = new NetworkedEvent("Challenge Sync", (Action<EventData>)OnChallengeSync); } public static void DetermineChallengeForLevel(int level, int initialSeed) { //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } int num = initialSeed + level; Random random = new Random(num); int num2 = Mathf.Max(0, level - Mathf.Max(1, LastChallengeLevel) - 1); float num3 = Mathf.Clamp(2.5f * Mathf.Sqrt(1.5f * (float)level), 1f, 30f); float num4 = Mathf.Clamp((float)num2 * 4f, 0f, 20f); float num5 = num3 + num4; if (num2 >= 3 && level >= 10) { num5 += 5f; if (num2 >= 5) { num5 += 7f; } } if (level >= 5 && LastChallengeLevel == -1) { num5 += 15f; if (level >= 7) { num5 += 20f; } } num5 *= Plugin.ChallengeChanceMultiplier.Value; float num6 = (float)random.Next(0, 1000) / 10f; Plugin.loggy.LogDebug((object)$"Determining challenge level with seed {num}"); bool flag = (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelShop || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelTutorial || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelArena || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobby || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobbyMenu; bool flag2 = level < 3 || (level <= 25 && level % 5 == 0); bool flag3 = num6 >= num5; bool flag4 = LastChallengeLevel == level - 1 && random.Next(0, 100) >= 5; if (forceChallenge == ChallengeType.None && (flag || flag2 || flag3 || flag4)) { ChallengeSync.RaiseEvent((object)0, NetworkingEvents.RaiseAll, SendOptions.SendReliable); Plugin.loggy.LogDebug((object)("No challenge was picked." + $"\n level: {level} - pass: {!flag2}" + $"\n lv type: {RunManager.instance.levelCurrent.NarrativeName} - pass: {!flag}" + $"\n lastchal: {LastChallengeLevel} ({level - 1}) - pass: {!flag4}" + $"\n percent: {num6} < {num5} - pass: {!flag3}")); return; } Plugin.loggy.LogDebug((object)("Challenge was picked!" + $"\n level: {level} - pass: {!flag2}" + $"\n lv type: {RunManager.instance.levelCurrent.NarrativeName} - pass: {!flag}" + $"\n lastchal: {LastChallengeLevel} ({level - 1}) - pass: {!flag4}" + $"\n percent: {num6} < {num5} - pass: {!flag3}")); int num7 = 0; int num8 = 0; int num9 = 0; List<Challenge> list = new List<Challenge>(); foreach (Challenge allChallenge in allChallenges) { if (LevelGeneratorPatch.CurrentLevel >= allChallenge.startingLevel && allChallenge.type != (ChallengeType)LastChallengeType) { list.Add(allChallenge); num9 += allChallenge.Weight; } } int num10 = random.Next(0, num9); foreach (Challenge item in list) { num8 += item.Weight; if (num8 > num10) { num7 = (int)item.type; break; } } if (forceChallenge != 0) { num7 = (int)forceChallenge; } forceChallenge = ChallengeType.None; LastChallengeLevel = level; LastChallengeType = num7; if (SemiFunc.IsMultiplayer()) { ChallengeSync.RaiseEvent((object)num7, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } else { SetupChallenges((ChallengeType)num7); } } public static void SetupChallenges(ChallengeType challenge) { currentChallenges.Clear(); if (challenge != 0) { currentChallenges.Add(challenge); } } private static void OnChallengeSync(EventData data) { int num = (int)data.CustomData; SetupChallenges((ChallengeType)num); Plugin.loggy.LogDebug((object)$"Received challenge sync - Challenge: {(ChallengeType)num}"); } } internal class Helpers { public static PlayerChatBoxState truckScreenState = (PlayerChatBoxState)0; private static readonly Dictionary<int, Color> difficultyColors = new Dictionary<int, Color> { { 2147483644, new Color(0f, 0f, 0f) }, { 999, new Color(0f, 0f, 0f) }, { 100, new Color(0.2f, 0.2f, 0.2f) }, { 90, new Color(0f, 1f, 0.5f) }, { 80, new Color(0f, 1f, 1f) }, { 70, new Color(0f, 0.5f, 1f) }, { 60, new Color(0f, 0f, 1f) }, { 50, new Color(0.5f, 0f, 1f) }, { 40, new Color(1f, 0f, 1f) }, { 30, new Color(1f, 0f, 0.5f) }, { 20, new Color(1f, 0f, 0f) }, { 15, new Color(1f, 0.5f, 0f) }, { 10, new Color(1f, 1f, 0f) }, { 5, new Color(0.5f, 1f, 0f) }, { 1, new Color(0f, 1f, 0f) } }; public static int PlayerCount => GameDirector.instance.PlayerList.Count; public static bool TruckLeaving { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if ((int)truckScreenState != 2) { return (int)truckScreenState == 3; } return true; } } public static int CurrentLevel => LevelGeneratorPatch.CurrentLevel; public static void DebugForceLoadLevel(int level, ChallengeManager.ChallengeType forcedChallenge = ChallengeManager.ChallengeType.None) { RunManager.instance.levelsCompleted = level - 1; ChallengeManager.forceChallenge = forcedChallenge; RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)1); } public static string TimeToString(float seconds) { seconds = Mathf.Clamp(seconds, 0f, 360000f); int num = (int)(seconds * 1000f) % 1000; int num2 = (int)seconds % 60; int num3 = (int)(seconds / 60f) % 60; int num4 = (int)(seconds / 3600f); return $"{num4:00}:{num3:00}:{num2:00}<size=75%>.{num:000}</size>"; } public static Color GetDifficultyColor(int level) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Color val = Color.black; int num = 0; foreach (KeyValuePair<int, Color> difficultyColor in difficultyColors) { if (level >= difficultyColor.Key) { float num2 = (float)(level - difficultyColor.Key) / (float)(num - difficultyColor.Key); return Color.Lerp(difficultyColor.Value, val, num2); } val = difficultyColor.Value; num = difficultyColor.Key; } return new Color(0f, 0f, 0f); } public static string ColoredText(string text, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) string text2 = ColorUtility.ToHtmlStringRGB(color); return ColoredText(text, "#" + text2); } public static string ColoredText(string text, string hexColor) { return "<color=" + hexColor + ">" + text + "</color>"; } } [HarmonyPatch(typeof(ExtractionPoint))] internal class ExtractionPointPatch { private static int TotalMapValueAtStartOfRound; [HarmonyPatch("HaulGoalSet")] [HarmonyPrefix] private static void HaulGoalSetPrefix(ref int value) { int value2 = Traverse.Create((object)RoundDirector.instance).Field("haulGoalMax").GetValue<int>(); int value3 = Traverse.Create((object)RoundDirector.instance).Field("extractionPoints").GetValue<int>(); int value4 = Traverse.Create((object)RoundDirector.instance).Field("extractionPointsCompleted").GetValue<int>(); if (value4 == 0) { TotalMapValueAtStartOfRound = value2; } float num = 1f; if (Plugin.Modify_HaulGoal.Value) { num = ((LevelGeneratorPatch.CurrentLevel == 1) ? 0.28f : ((LevelGeneratorPatch.CurrentLevel <= 6) ? Mathf.Lerp(0.33f, 0.43f, Mathf.InverseLerp(2f, 6f, (float)LevelGeneratorPatch.CurrentLevel)) : ((LevelGeneratorPatch.CurrentLevel <= 11) ? Mathf.Lerp(0.44f, 0.5f, Mathf.InverseLerp(7f, 11f, (float)LevelGeneratorPatch.CurrentLevel)) : ((LevelGeneratorPatch.CurrentLevel > 50) ? Mathf.Lerp(0.75f, 0.95f, Mathf.InverseLerp(51f, 250f, (float)LevelGeneratorPatch.CurrentLevel)) : Mathf.Lerp(0.5f, 0.75f, Mathf.InverseLerp(12f, 50f, (float)LevelGeneratorPatch.CurrentLevel)))))); } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HighQuota)) { Plugin.loggy.LogDebug((object)"High Quota active - increasing haul goal..."); float num2 = Mathf.Abs(1f - num); num += Mathf.Clamp(num2 / 2f, 0.1f, 0.4f); } if (Plugin.Modify_HaulGoal.Value) { float num3 = 1f - Mathf.Clamp(0.1f * (float)(value3 - value4 - 1), 0f, 0.5f); int num4 = Mathf.RoundToInt((float)Mathf.RoundToInt((float)TotalMapValueAtStartOfRound * num / (float)value3) * num3); value = Mathf.Max(num4, 1000); } else { value = Mathf.RoundToInt((float)value * num); } } [HarmonyPatch("ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruck")] [HarmonyPostfix] private static void ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruckP() { LevelStatsManager.firstExtractionOpenedThisLevel = true; } [HarmonyPatch("DestroyTheFirstPhysObjectsInHaulList")] [HarmonyPrefix] private static void DestroyTheFirstPhysObjectsInHaulListP() { if (SemiFunc.IsMasterClientOrSingleplayer() && RoundDirector.instance.dollarHaulList.Count != 0 && Object.op_Implicit((Object)(object)RoundDirector.instance.dollarHaulList[0])) { ValuableObject component = RoundDirector.instance.dollarHaulList[0].GetComponent<ValuableObject>(); SurplusValuable component2 = RoundDirector.instance.dollarHaulList[0].GetComponent<SurplusValuable>(); if (Object.op_Implicit((Object)(object)component) && !Object.op_Implicit((Object)(object)component2)) { LevelStatsManager.AddValueExtracted(Traverse.Create((object)component).Field("dollarValueCurrent").GetValue<float>()); } } } [HarmonyPatch("DestroyAllPhysObjectsInHaulList")] [HarmonyPrefix] private static void DestroyAllPhysObjectsInHaulListP() { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } foreach (GameObject dollarHaul in RoundDirector.instance.dollarHaulList) { ValuableObject component = dollarHaul.GetComponent<ValuableObject>(); SurplusValuable component2 = dollarHaul.GetComponent<SurplusValuable>(); if (!Object.op_Implicit((Object)(object)component) || Object.op_Implicit((Object)(object)component2)) { break; } LevelStatsManager.AddValueExtracted(Traverse.Create((object)component).Field("dollarValueCurrent").GetValue<float>()); } } [HarmonyPatch("SpawnTaxReturn")] [HarmonyPrefix] private static void SpawnTaxReturnP() { if (SemiFunc.IsMasterClientOrSingleplayer()) { int value = Traverse.Create((object)RoundDirector.instance).Field("extractionPointSurplus").GetValue<int>(); if (value > 0) { LevelStatsManager._valueFromSurplus += value; } } } [HarmonyPatch("SetHaulText")] [HarmonyPostfix] private static void SetHaulTextP(ref ExtractionPoint __instance, ref bool ___isShop, ref float ___haulBarTargetScale) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation) && !___isShop) { ((TMP_Text)__instance.haulGoalScreen).text = "<color=#bd4300>$</color>?????"; ___haulBarTargetScale = 1f; Traverse.Create((object)__instance).Method("SetEmojiScreen", new object[2] { "<sprite name=:)>", false }).GetValue(); } } } [HarmonyPatch(typeof(LevelGenerator))] internal class LevelGeneratorPatch { public static int CurrentLevel => RunManager.instance.levelsCompleted + 1; private static int CurrentModCount => Traverse.Create((object)LevelGenerator.Instance).Field("ModuleAmount").GetValue<int>(); private static int CurrentExtCount => Traverse.Create((object)LevelGenerator.Instance).Field("ExtractionAmount").GetValue<int>(); private static int GetNewModuleCount() { if (!SemiFunc.RunIsLevel()) { return CurrentModCount; } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation)) { return Random.Range(5, 9); } int num = CurrentModCount; if (Plugin.Modify_ModuleCount.Value) { num = ((CurrentLevel <= 2) ? (3 + CurrentLevel) : ((CurrentLevel <= 6) ? Mathf.RoundToInt(Mathf.Lerp(5f, 7f, Mathf.InverseLerp(3f, 6f, (float)CurrentLevel))) : ((CurrentLevel <= 10) ? Mathf.RoundToInt(Mathf.Lerp(8f, 9f, Mathf.InverseLerp(7f, 10f, (float)CurrentLevel))) : ((CurrentLevel <= 20) ? Mathf.RoundToInt(Mathf.Lerp(10f, 12f, Mathf.InverseLerp(11f, 20f, (float)CurrentLevel))) : ((CurrentLevel <= 50) ? Mathf.RoundToInt(Mathf.Lerp(13f, 18f, Mathf.InverseLerp(21f, 50f, (float)CurrentLevel))) : ((CurrentLevel > 100) ? 25 : Mathf.RoundToInt(Mathf.Lerp(19f, 24f, Mathf.InverseLerp(51f, 100f, (float)CurrentLevel))))))))); } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.LargeMap)) { Plugin.loggy.LogDebug((object)"Large Map active - enlarging map..."); num += Mathf.Clamp(Mathf.RoundToInt((float)num * 0.35f), 6, 12); } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.FoggyLevel)) { Plugin.loggy.LogDebug((object)"Foggy Level challenge active - lowering map size..."); num = Mathf.CeilToInt((float)num / 2f); } return num; } private static int GetNewExtractionCount() { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation)) { return Random.Range(1, 3); } if (!Plugin.Modify_ExtractionCount.Value) { return CurrentExtCount; } if (CurrentLevel <= 2 || !SemiFunc.RunIsLevel()) { return 0; } if (CurrentLevel <= 5) { return 1; } if (CurrentLevel <= 8) { return 2; } if (CurrentLevel <= 20) { return Mathf.RoundToInt(Mathf.Lerp(3f, 4f, Mathf.InverseLerp(9f, 20f, (float)CurrentLevel))); } if (CurrentLevel < 100) { return Mathf.RoundToInt(Mathf.Lerp(5f, 8f, Mathf.InverseLerp(21f, 99f, (float)CurrentLevel))); } return 9; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TileGenerationTranspiler(IEnumerable<CodeInstruction> inst) { //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(inst); if (list.Count <= 20) { Plugin.loggy.LogError((object)"Less than 20 instructions were found in TileGeneration, this is abnormal."); return list; } int num = -1; Plugin.loggy.LogDebug((object)"Searching for Module index..."); for (int i = 3; i < list.Count - 1; i++) { if (list[i].opcode == OpCodes.Ldfld && (FieldInfo)list[i].operand == AccessTools.Field(typeof(LevelGenerator), "ModuleAmount") && list[i + 1].opcode == OpCodes.Ldc_I4_3) { num = i - 3; break; } } if (num == -1) { Plugin.loggy.LogError((object)"Never found an insertion point for ModuleCount, unable to patch TileGeneration."); return list; } Plugin.loggy.LogDebug((object)$"Found module index at {num}"); Plugin.loggy.LogDebug((object)"Searching for Extraction index..."); int num2 = -1; for (int j = 1; j < list.Count - 1; j++) { if (list[j].opcode == OpCodes.Ldarg_0 && list[j + 1].opcode == OpCodes.Ldc_I4_M1 && list[j + 4].opcode == OpCodes.Ldfld && (FieldInfo)list[j + 4].operand == AccessTools.Field(typeof(LevelGenerator), "ExtractionAmount")) { num2 = j - 1; break; } } if (num2 == -1) { Plugin.loggy.LogError((object)"Never found an insertion point for ExtractionCount, unable to patch TileGeneration."); return list; } Plugin.loggy.LogDebug((object)$"Found extraction index at {num2}"); List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelGeneratorPatch), "GetNewModuleCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(LevelGenerator), "ModuleAmount")) }; List<CodeInstruction> collection2 = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelGeneratorPatch), "GetNewExtractionCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(LevelGenerator), "ExtractionAmount")) }; list.InsertRange(num2, collection2); list.InsertRange(num, collection); return list; } [HarmonyPatch("GenerateDone")] [HarmonyPostfix] private static void GenerateDonePostfix(ref int ___ModuleAmount, ref int ___ExtractionAmount) { Plugin.loggy.LogDebug((object)$"Amounts at end of GenerateDone: M = {___ModuleAmount} // E = {___ExtractionAmount}"); Plugin.loggy.LogDebug((object)$"Expected amounts for GenerateDone: M = {GetNewModuleCount()} // E = {GetNewExtractionCount()}"); } } [BepInPlugin("Swaggies.LevelScaling", "LevelScaling", "0.7.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public enum ExtractedUIDisplayType { AlwaysTotalMapValue, AlwaysCurrentMapValue, Alternate } private const string _guid = "Swaggies.LevelScaling"; private const string _name = "LevelScaling"; public const string _ver = "0.7.0"; private readonly Harmony harmony = new Harmony("Swaggies.LevelScaling"); public static ManualLogSource loggy; public static ConfigEntry<bool> StatsUIShow_Base; public static ConfigEntry<bool> StatsUIShow_Map; public static ConfigEntry<bool> StatsUIShow_EndOfLevel; public static ConfigEntry<bool> StatsUIShow_Shop; public static ConfigEntry<ExtractedUIDisplayType> StatsUIShow_ExtractedUI; public static ConfigEntry<bool> StatsUIDisplay_Challenge; public static ConfigEntry<bool> StatsUIDisplay_Time; public static ConfigEntry<bool> StatsUIDisplay_Deaths; public static ConfigEntry<bool> StatsUIDisplay_OrbDrops; public static ConfigEntry<bool> StatsUIDisplay_Extracted; public static ConfigEntry<bool> StatsUIDisplay_Broken; public static ConfigEntry<bool> StatsUIDisplay_Found; public static ConfigEntry<bool> StatsUIDisplay_Explored; public static ConfigEntry<bool> ShowOldOvercharge; public static ConfigEntry<float> ChallengeChanceMultiplier; public static ConfigEntry<int> ChallengeChanceMultiplier_LightsOut; public static ConfigEntry<int> ChallengeChanceMultiplier_HighQuota; public static ConfigEntry<int> ChallengeChanceMultiplier_LargeMap; public static ConfigEntry<int> ChallengeChanceMultiplier_FoggyLevel; public static ConfigEntry<int> ChallengeChanceMultiplier_IncreasedDamage; public static ConfigEntry<int> ChallengeChanceMultiplier_FragileValuables; public static ConfigEntry<int> ChallengeChanceMultiplier_OverOvercharge; public static ConfigEntry<int> ChallengeChanceMultiplier_NoMap; public static ConfigEntry<int> ChallengeChanceMultiplier_EnemyRush; public static ConfigEntry<int> ChallengeChanceMultiplier_HiddenInformation; public static ConfigEntry<bool> Modify_ModuleCount; public static ConfigEntry<bool> Modify_ExtractionCount; public static ConfigEntry<bool> Modify_HaulGoal; public static ConfigEntry<bool> Modify_TotalMapValue; private void Awake() { loggy = Logger.CreateLogSource("Swaggies.LevelScaling"); loggy.LogMessage((object)"LevelScaling's up and runnin' on 0.7.0"); ChallengeManager.Setup(); LevelStatsSyncing.Setup(); harmony.PatchAll(typeof(LevelGeneratorPatch)); harmony.PatchAll(typeof(ExtractionPointPatch)); harmony.PatchAll(typeof(ValuableDirectorPatch)); harmony.PatchAll(typeof(RunManagerPatch)); harmony.PatchAll(typeof(StatsManagerPatch)); harmony.PatchAll(typeof(GameDirectorPatch)); harmony.PatchAll(typeof(LightManagerPatch)); harmony.PatchAll(typeof(LoadingUIPatch)); harmony.PatchAll(typeof(EnvironmentDirectorPatch)); harmony.PatchAll(typeof(PlayerControllerPatch)); harmony.PatchAll(typeof(PlayerHealthPatch)); harmony.PatchAll(typeof(EnemyHealthPatch)); harmony.PatchAll(typeof(PhysGrabObjectImpactDetectorPatch)); harmony.PatchAll(typeof(ValuableObjectPatch)); harmony.PatchAll(typeof(TruckScreenTextPatch)); harmony.PatchAll(typeof(StatsUIPatch)); harmony.PatchAll(typeof(EnemyParentPatch)); harmony.PatchAll(typeof(EnemyValuablePatch)); harmony.PatchAll(typeof(OverchargeUI)); harmony.PatchAll(typeof(PhysGrabObjectPatch)); harmony.PatchAll(typeof(PhysGrabberPatch)); harmony.PatchAll(typeof(MapToolControllerPatch)); harmony.PatchAll(typeof(PlayerAvatarPatch)); harmony.PatchAll(typeof(EnemyDirectorPatch)); harmony.PatchAll(typeof(EnemyRigidbodyPatch)); harmony.PatchAll(typeof(HealthUIPatch)); harmony.PatchAll(typeof(EnergyUIPatch)); harmony.PatchAll(typeof(HaulUIPatch)); harmony.PatchAll(typeof(ClownTrapPatch)); harmony.PatchAll(typeof(ValuableEggPatch)); harmony.PatchAll(typeof(SemiFuncPatch)); harmony.PatchAll(typeof(MapPatch)); harmony.PatchAll(typeof(MapModulePatch)); harmony.PatchAll(typeof(RoundDirectorPatch)); CreateConfig(); } private void CreateConfig() { //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Expected O, but got Unknown //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Expected O, but got Unknown //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Expected O, but got Unknown //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Expected O, but got Unknown StatsUIShow_Base = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Show always", true, "Whether the level stats are always displayed on screen (applies when changed)"); StatsUIShow_Map = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Show when map is open", true, "Whether the level stats are displayed with the map open (if not, they will be hidden with the map open, overriding other settings) (applies when changed)"); StatsUIShow_EndOfLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Show at end of level", true, "Whether the level stats will be shown at the end of a level (overriden by Always Show and Show With Map) (applies when changed)"); StatsUIShow_Shop = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Show in shop", true, "Whether the level stats are shown in the shop (overriden by all other settings) (applies when changed)"); StatsUIShow_ExtractedUI = ((BaseUnityPlugin)this).Config.Bind<ExtractedUIDisplayType>("Level Stats UI", "Extracted Value Display Type", ExtractedUIDisplayType.AlwaysTotalMapValue, "If the \"extracted value\" stats displays the total map value, or current remaining map value (taking broken valuables into account). Set to Alternate for automatically swapping between them every few seconds in-game (applies when changed)"); StatsUIDisplay_Challenge = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Active Challenge", true, "Whether to display the active challenge on the UI (applies when changed)"); StatsUIDisplay_Time = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Level Timer", true, "Whether to display the level stopwatch on the UI (applies when changed)"); StatsUIDisplay_Deaths = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Shop Death Count", true, "Whether to display the number of shop deaths on the UI (applies when changed)"); StatsUIDisplay_OrbDrops = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Orb Drops Count", true, "Whether to display the number of orbs dropped from killed enemies on the UI (applies when changed)"); StatsUIDisplay_Extracted = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Value Extracted", true, "Whether to display the amount of value extracted on the UI (applies when changed)"); StatsUIDisplay_Broken = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Value Broken", true, "Whether to display the amount of value broken on the UI (applies when changed)"); StatsUIDisplay_Found = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Valuables Found", true, "Whether to display the number of valuables found on the UI (applies when changed)"); StatsUIDisplay_Explored = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Modules Explored", true, "Whether to display the number of modules explored on the UI (applies when changed)"); ShowOldOvercharge = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "Show old Overcharge UI", true, "Whether to enable the old Overcharge UI (number at the top left under the stamina meter - seen in old videos with overcharge) (applies at the start of each level)"); ChallengeChanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Challenge Levels", "Chance multiplier", 1f, new ConfigDescription("Adjust the multiplier for the chance of a challenge level appearing - you can see the base challenges in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); ChallengeChanceMultiplier_LightsOut = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Lights Out Weight", 30, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_HighQuota = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Overtime Weight", 50, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_LargeMap = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Enlarged Level Weight", 20, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_FoggyLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Dense Fog Weight", 20, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_IncreasedDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Increased Damage Weight", 30, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_FragileValuables = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Fragile Valuables Weight", 50, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_OverOvercharge = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Over-Overcharge Weight", 50, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_NoMap = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Broken Map Weight", 40, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_EnemyRush = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Enemy Rush Weight", 35, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChallengeChanceMultiplier_HiddenInformation = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Hidden Information Weight", 15, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); Modify_ModuleCount = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Scaling", "Modify Module Count", true, "Whether Level Scaling should apply its progressive module counts for levels (set to false for vanilla) (applies at the start of each level) (HOST ONLY)"); Modify_ExtractionCount = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Scaling", "Modify Extraction Count", true, "Whether Level Scaling should apply its progressive amount of number of extraction points for levels (set to false for vanilla) (applies at the start of each level) (HOST ONLY)"); Modify_HaulGoal = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Scaling", "Modify Haul Goal", true, "Whether Level Scaling should apply its progressive curve for percentage of map value that determines the extraction point quotas (set to false for vanilla) (applies at the start of each level) (HOST ONLY)"); Modify_TotalMapValue = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Scaling", "Modify Total Map Value", true, "Whether Level Scaling should apply its progressive total map values for levels (set to false for vanilla) (applies at the start of each level) (HOST ONLY)"); } } [HarmonyPatch(typeof(ValuableDirector))] internal class ValuableDirectorPatch { private static int TotalMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("totalMaxAmount").GetValue<int>(); private static int TinyMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("tinyMaxAmount").GetValue<int>(); private static int SmallMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("smallMaxAmount").GetValue<int>(); private static int MediumMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("mediumMaxAmount").GetValue<int>(); private static int BigMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("bigMaxAmount").GetValue<int>(); private static int WideMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("wideMaxAmount").GetValue<int>(); private static int TallMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("tallMaxAmount").GetValue<int>(); private static int VeryTallMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("veryTallMaxAmount").GetValue<int>(); private static float TotalMaxValue => Traverse.Create((object)ValuableDirector.instance).Field("totalMaxValue").GetValue<float>(); private static float NewValueCount() { float num = TotalMaxValue; if (Plugin.Modify_TotalMapValue.Value) { num = ((LevelGeneratorPatch.CurrentLevel <= 11) ? Mathf.Lerp(30f, 180f, Mathf.InverseLerp(1f, 11f, (float)LevelGeneratorPatch.CurrentLevel)) : ((LevelGeneratorPatch.CurrentLevel > 100) ? Mathf.Lerp(500f, 1100f, Mathf.InverseLerp(100f, 1000f, (float)LevelGeneratorPatch.CurrentLevel)) : Mathf.Lerp(180f, 500f, Mathf.InverseLerp(11f, 100f, (float)LevelGeneratorPatch.CurrentLevel)))); } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HighQuota)) { Plugin.loggy.LogDebug((object)"High Quota active - increasing total max value..."); num *= 1.33f; } return num; } private static int MultiplyItemCount(int inAmount) { if (!Plugin.Modify_TotalMapValue.Value) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HighQuota)) { Plugin.loggy.LogDebug((object)"High Quota active - increasing valuable max amounts..."); return Mathf.RoundToInt((float)inAmount * 1.33f); } return inAmount; } float num = 1f; if (LevelGeneratorPatch.CurrentLevel > 5) { num = Mathf.Lerp(1f, 1.1f, Mathf.InverseLerp(5f, 11f, (float)LevelGeneratorPatch.CurrentLevel)); } if (LevelGeneratorPatch.CurrentLevel > 11) { num = Mathf.Lerp(1.1f, 2.2f, Mathf.InverseLerp(11f, 100f, (float)LevelGeneratorPatch.CurrentLevel)); } if (LevelGeneratorPatch.CurrentLevel > 100) { num = Mathf.Lerp(2.2f, 5f, Mathf.InverseLerp(100f, 999f, (float)LevelGeneratorPatch.CurrentLevel)); } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HighQuota)) { Plugin.loggy.LogDebug((object)"High Quota active - increasing valuable max amounts..."); num *= 1.33f; } return Mathf.RoundToInt((float)inAmount * num); } private static int NewTotalItemCount() { return MultiplyItemCount(TotalMaxAmount); } private static int NewTinyItemCount() { return MultiplyItemCount(TinyMaxAmount); } private static int NewSmallItemCount() { return MultiplyItemCount(SmallMaxAmount); } private static int NewMediumItemCount() { return MultiplyItemCount(MediumMaxAmount); } private static int NewBigItemCount() { return MultiplyItemCount(BigMaxAmount); } private static int NewWideItemCount() { return MultiplyItemCount(WideMaxAmount); } private static int NewTallItemCount() { return MultiplyItemCount(TallMaxAmount); } private static int NewVeryTallItemCount() { return MultiplyItemCount(VeryTallMaxAmount); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> SetupHostTranspiler(IEnumerable<CodeInstruction> inst) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Expected O, but got Unknown //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Expected O, but got Unknown //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Expected O, but got Unknown //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Expected O, but got Unknown //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Expected O, but got Unknown //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Expected O, but got Unknown //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Expected O, but got Unknown //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Expected O, but got Unknown //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Expected O, but got Unknown //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Expected O, but got Unknown //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(inst); if (list.Count <= 20) { Plugin.loggy.LogError((object)"Less than 20 instructions were found in SetupHost, this is abnormal, refusing to patch."); return list; } int num = -1; for (int i = 1; i < list.Count - 1; i++) { if (list[i].opcode == OpCodes.Stfld && list[i + 1].opcode == OpCodes.Call && (FieldInfo)list[i].operand == AccessTools.Field(typeof(ValuableDirector), "veryTallMaxAmount") && (MethodInfo)list[i + 1].operand == AccessTools.Method(typeof(SemiFunc), "RunIsArena", (Type[])null, (Type[])null)) { num = i; break; } } if (num == -1) { Plugin.loggy.LogError((object)"Never found an insertion point, unable to patch SetupHost."); return list; } List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewValueCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "totalMaxValue")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewTotalItemCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "totalMaxAmount")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewSmallItemCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "smallMaxAmount")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewMediumItemCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "mediumMaxAmount")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewBigItemCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "bigMaxAmount")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewWideItemCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "wideMaxAmount")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewVeryTallItemCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "veryTallMaxAmount")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewTallItemCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "tallMaxAmount")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewTinyItemCount", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "tinyMaxAmount")) }; list.InsertRange(num, collection); Plugin.loggy.LogDebug((object)"Successfully patched ValuableDirector.SetupHost"); return list; } } } namespace LevelScaling.Patches { [HarmonyPatch(typeof(ClownTrap))] internal class ClownTrapPatch { [HarmonyPatch("TrapStop")] [HarmonyPostfix] private static void TrapStopP(ref ClownTrap __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>(); if (Object.op_Implicit((Object)(object)component)) { LevelStatsManager.AddValueBroken(Traverse.Create((object)component).Field("dollarValueCurrent").GetValue<float>()); } } } } [HarmonyPatch(typeof(EnemyDirector))] internal class EnemyDirectorPatch { [HarmonyPatch("AmountSetup")] [HarmonyPrefix] private static bool AmountSetupPrefix(ref EnemyDirector __instance, ref int ___amountCurve1Value, ref int ___amountCurve2Value, ref int ___amountCurve3Value, ref int ___totalAmount, ref List<EnemySetup> ___enemiesDifficulty1, ref List<EnemySetup> ___enemiesDifficulty2, ref List<EnemySetup> ___enemiesDifficulty3, ref List<EnemySetup> ___enemyListCurrent, ref float ___despawnedTimeMultiplier) { if (!ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush)) { return true; } float num = SemiFunc.RunGetDifficultyMultiplier1(); float num2 = SemiFunc.RunGetDifficultyMultiplier2(); float num3 = SemiFunc.RunGetDifficultyMultiplier3(); if (num2 > 0f) { ___amountCurve3Value = Mathf.CeilToInt(__instance.amountCurve3_2.Evaluate(num) * 1.1f) + 1; ___amountCurve2Value = Mathf.CeilToInt(__instance.amountCurve2_2.Evaluate(num) * 1.3f) + 1; ___amountCurve1Value = Mathf.CeilToInt(__instance.amountCurve1_2.Evaluate(num) * 1.6f) + 1; } else { ___amountCurve3Value = Mathf.CeilToInt(__instance.amountCurve3_1.Evaluate(num) * 1.2f) + 1; ___amountCurve2Value = Mathf.CeilToInt(__instance.amountCurve2_1.Evaluate(num) * 1.4f) + 1; ___amountCurve1Value = Mathf.CeilToInt(__instance.amountCurve1_1.Evaluate(num) * 1.8f) + 1; } Traverse val = Traverse.Create((object)EnemyDirector.instance); ___enemyListCurrent.Clear(); for (int i = 0; i < ___amountCurve1Value; i++) { val.Method("PickEnemies", new object[1] { ___enemiesDifficulty1 }).GetValue(); } for (int j = 0; j < ___amountCurve2Value; j++) { val.Method("PickEnemies", new object[1] { ___enemiesDifficulty2 }).GetValue(); } for (int k = 0; k < ___amountCurve3Value; k++) { val.Method("PickEnemies", new object[1] { ___enemiesDifficulty3 }).GetValue(); } ___despawnedTimeMultiplier = 1f; if (num3 > 0f) { ___despawnedTimeMultiplier = __instance.despawnTimeCurve_2.Evaluate(num3); } else if (num2 > 0f) { ___despawnedTimeMultiplier = __instance.despawnTimeCurve_1.Evaluate(num2); } ___totalAmount = ___amountCurve1Value + ___amountCurve2Value + ___amountCurve3Value; Plugin.loggy.LogDebug((object)$"Enemy Rush challenge list: {___amountCurve1Value} / {___amountCurve2Value} / {___amountCurve3Value}"); return false; } } [HarmonyPatch(typeof(EnemyHealth))] internal class EnemyHealthPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakeP(ref int ___healthCurrent) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush)) { ___healthCurrent /= 2; } } [HarmonyPatch("OnSpawn")] [HarmonyPostfix] private static void OnSpawnP(ref int ___healthCurrent) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush)) { ___healthCurrent /= 2; } } [HarmonyPatch("Hurt")] [HarmonyPrefix] private static void HurtP(ref int _damage) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.IncreasedDamage)) { Plugin.loggy.LogDebug((object)"Increased Damage active - increasing damage to enemy..."); _damage = Mathf.CeilToInt((float)_damage * 1.33f); } } } [HarmonyPatch(typeof(EnemyParent))] internal class EnemyParentPatch { [HarmonyPatch("Spawn")] [HarmonyPostfix] private static void SpawnP(ref Enemy ___Enemy) { if (SemiFunc.IsMasterClientOrSingleplayer() && !LevelStatsManager.individualOrbDropCounts.ContainsKey(___Enemy)) { EnemyHealth value = Traverse.Create((object)___Enemy).Field("Health").GetValue<EnemyHealth>(); if (Object.op_Implicit((Object)(object)value) && value.spawnValuable) { LevelStatsManager.maxIndividualOrbDrops++; LevelStatsManager.individualOrbDropCounts.Add(___Enemy, 0); } } } [HarmonyPatch("Despawn")] [HarmonyPrefix] private static void DespawnP(ref Enemy ___Enemy) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } EnemyHealth value = Traverse.Create((object)___Enemy).Field("Health").GetValue<EnemyHealth>(); if (!Object.op_Implicit((Object)(object)value) || !value.spawnValuable || Traverse.Create((object)value).Field("spawnValuableCurrent").GetValue<int>() >= value.spawnValuableMax || Traverse.Create((object)value).Field("healthCurrent").GetValue<int>() > 0) { return; } if (LevelStatsManager.individualOrbDropCounts.ContainsKey(___Enemy)) { LevelStatsManager.individualOrbDropCounts[___Enemy]++; if (LevelStatsManager.individualOrbDropCounts[___Enemy] == 1) { LevelStatsManager.AddIndivOrb(); } } foreach (KeyValuePair<Enemy, int> individualOrbDropCount in LevelStatsManager.individualOrbDropCounts) { if (individualOrbDropCount.Value == 0) { return; } } LevelStatsManager.SetAllOrbsFound(value: true); } } [HarmonyPatch(typeof(EnemyRigidbody))] internal class EnemyRigidbodyPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakeP(ref EnemyRigidbody __instance) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush)) { GrabForce grabForceNeeded = __instance.grabForceNeeded; grabForceNeeded.amount *= 0.75f; } } } [HarmonyPatch(typeof(EnemyValuable))] internal class EnemyValuablePatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartP() { if (SemiFunc.IsMasterClientOrSingleplayer()) { LevelStatsManager.AddEnemyKill(); } } } [HarmonyPatch(typeof(EnergyUI))] internal class EnergyUIPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdateP(ref TextMeshProUGUI ___Text) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation) && Object.op_Implicit((Object)(object)___Text)) { ((TMP_Text)___Text).text = "??"; } } } [HarmonyPatch(typeof(EnvironmentDirector))] internal class EnvironmentDirectorPatch { [HarmonyPatch("Setup")] [HarmonyPostfix] private static void SetupP(ref Camera ___MainCamera) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.LightsOut)) { RenderSettings.fogStartDistance *= 0.86f; RenderSettings.fogEndDistance *= 0.86f; ___MainCamera.farClipPlane = RenderSettings.fogEndDistance + 1f; Plugin.loggy.LogDebug((object)"Lights Out challenge active - reducing fog distance a lil..."); } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.FoggyLevel)) { RenderSettings.fogStartDistance *= 0.37f; RenderSettings.fogEndDistance *= 0.37f; ___MainCamera.farClipPlane = RenderSettings.fogEndDistance + 1f; Plugin.loggy.LogDebug((object)"Foggy Level challenge active - lowering fog distance..."); } } } [HarmonyPatch(typeof(GameDirector))] internal class GameDirectorPatch { private static VideoClip cache; private static VideoClip Clip { get { if ((Object)(object)cache == (Object)null) { VideoClip[] array = Resources.FindObjectsOfTypeAll<VideoClip>(); foreach (VideoClip val in array) { if (((Object)val).name == "Video Overlay") { cache = val; break; } } } return cache; } } [HarmonyPatch("gameStateStart")] [HarmonyPostfix] private static void gameStateStartP(ref float ___gameStateTimer) { if (!(___gameStateTimer > 0f) && ChallengeManager.currentChallenges.Count != 0) { ChallengeManager.Challenge challenge = ChallengeManager.GetChallenge(ChallengeManager.currentChallenges[0]); string name = challenge.name; string info = challenge.info; Traverse.Create((object)TutorialDirector.instance).Field("delayBeforeTip").SetValue((object)1.5f); Traverse.Create((object)TutorialDirector.instance).Field("showTipTimer").SetValue((object)10f); TutorialUI.instance.SetTipPage(Clip, "<size=70%><line-height=110%><b>" + name + ":</b> " + info + "<br></line-height></size>"); } } } [HarmonyPatch(typeof(HaulUI))] internal class HaulUIPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdateP(ref TextMeshProUGUI ___Text, ref int ___currentHaulValue) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation) && SemiFunc.RunIsLevel()) { string text = "<color=#558B2F>$</color>"; string oldValue = text + SemiFunc.DollarGetString(Mathf.Max(0, ___currentHaulValue)); ((TMP_Text)___Text).text = ((TMP_Text)___Text).text.Replace(oldValue, text + "?????"); } } } [HarmonyPatch(typeof(HealthUI))] internal class HealthUIPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdateP(ref TextMeshProUGUI ___Text) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation) && Object.op_Implicit((Object)(object)___Text)) { ((TMP_Text)___Text).text = "???"; } } } [HarmonyPatch(typeof(LightManager))] internal class LightManagerPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void SetupP(ref LightManager __instance, ref bool ___turnOffLights, ref bool ___turningOffLights, ref bool ___turningOffEmissions) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.LightsOut) && (int)GameDirector.instance.currentState == 2 && Object.op_Implicit((Object)(object)PlayerAvatar.instance) && !___turnOffLights) { ((MonoBehaviour)__instance).StopAllCoroutines(); ___turningOffLights = true; ((MonoBehaviour)__instance).StartCoroutine("TurnOffLights"); ___turningOffEmissions = true; ((MonoBehaviour)__instance).StartCoroutine("TurnOffEmissions"); ___turnOffLights = true; Plugin.loggy.LogDebug((object)"Lights Out challenge active - disabling lights and emissions..."); } } } [HarmonyPatch(typeof(LoadingUI))] internal class LoadingUIPatch { [HarmonyPatch("LevelAnimationStart")] [HarmonyPostfix] private static void LevelAnimationStartP(ref LoadingUI __instance) { if (ChallengeManager.currentChallenges.Count == 0) { return; } string text = ""; for (int i = 0; i < ChallengeManager.currentChallenges.Count; i++) { text += ChallengeManager.GetChallenge(ChallengeManager.currentChallenges[i]).name; if (i != ChallengeManager.currentChallenges.Count - 1) { text += " + "; } } text = text.ToUpper(); ((TMP_Text)__instance.levelNumberText).text = "<color=red>CHALLENGE LEVEL: " + text + "</color>"; ((TMP_Text)__instance.levelNameText).text = "<color=#f99>" + ((TMP_Text)__instance.levelNameText).text + "</color>"; } } [HarmonyPatch(typeof(MapModule))] internal class MapModulePatch { [HarmonyPatch("Hide")] [HarmonyPrefix] private static void HideP(ref bool ___animating) { if (!___animating) { LevelStatsManager.AddModuleExplored(); } } } [HarmonyPatch(typeof(Map))] internal class MapPatch { [HarmonyPatch("AddRoomVolume")] [HarmonyPostfix] private static void AddRoomVolumeP(ref Map __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { LevelStatsManager.totalModules = __instance.MapModules.Count; } } } [HarmonyPatch(typeof(MapToolController))] internal class MapToolControllerPatch { public static bool mapToolActive; [HarmonyPatch(typeof(MapToolController), "Update")] [HarmonyPostfix] private static void UpdateP2(ref bool ___Active, ref PhotonView ___photonView) { if (!GameManager.Multiplayer() || ___photonView.IsMine) { mapToolActive = ___Active; } } [HarmonyPatch("Update")] [HarmonyPrefix] private static bool UpdateP() { return !ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.NoMap); } } [HarmonyPatch(typeof(PhysGrabber))] internal class PhysGrabberPatch { [HarmonyPatch("PhysGrabOverChargeLogic")] [HarmonyPostfix] private static void PhysGrabOverChargeLogicP(ref PhysGrabber __instance, ref float ___physGrabBeamOverChargeTimer, ref float ___physGrabBeamOverChargeFloat, ref float ___physGrabBeamOverchargeDecreaseCooldown) { if (!__instance.isLocal || ___physGrabBeamOverChargeTimer > 0f || ___physGrabBeamOverChargeFloat <= 0f) { return; } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.OverOvercharge)) { if (___physGrabBeamOverchargeDecreaseCooldown > 0f) { ___physGrabBeamOverchargeDecreaseCooldown += Time.deltaTime * 0.1f; } ___physGrabBeamOverChargeFloat -= 0.02f * Time.deltaTime; } if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush)) { if (___physGrabBeamOverchargeDecreaseCooldown > 0f) { ___physGrabBeamOverchargeDecreaseCooldown += Time.deltaTime * 0.5f; ___physGrabBeamOverChargeFloat -= 0.04f * Time.deltaTime; } else { ___physGrabBeamOverChargeFloat -= 0.067f * Time.deltaTime; } } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector))] internal class PhysGrabObjectImpactDetectorPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartP(ref PhysGrabObjectImpactDetector __instance, ref ValuableObject ___valuableObject) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.FragileValuables) && Object.op_Implicit((Object)(object)___valuableObject)) { Plugin.loggy.LogDebug((object)"Fragile Valuables active - increasing fragility..."); __instance.fragility = Mathf.Max(__instance.fragility, (float)Random.Range(85, 101)); __instance.durability = Mathf.Min(__instance.durability, (float)Random.Range(0, 11)); } } [HarmonyPatch("BreakRPC")] [HarmonyPostfix] private static void BreakP(ref PhysGrabObjectImpactDetector __instance, ref float valueLost, ref bool _loseValue) { if (SemiFunc.IsMasterClientOrSingleplayer() && valueLost != 0f && _loseValue) { if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<SurplusValuable>())) { LevelStatsManager.AddValueExtracted(0f - valueLost); } LevelStatsManager.AddValueBroken(valueLost); } } [HarmonyPatch("DestroyObjectRPC")] [HarmonyPrefix] private static void DestroyObjectRPCP(ref PhysGrabObjectImpactDetector __instance, ref ValuableObject ___valuableObject) { if (SemiFunc.IsMasterClientOrSingleplayer() && Object.op_Implicit((Object)(object)___valuableObject)) { float value = Traverse.Create((object)___valuableObject).Field("dollarValueCurrent").GetValue<float>(); if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<SurplusValuable>())) { LevelStatsManager.AddValueExtracted(0f - value); } LevelStatsManager.AddValueBroken(value); } } } [HarmonyPatch(typeof(PhysGrabObject))] internal class PhysGrabObjectPatch { [HarmonyPatch("FixedUpdate")] [HarmonyPostfix] private static void UpdateP(ref PhysGrabObject __instance, ref bool ___heldByLocalPlayer) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.OverOvercharge) && ___heldByLocalPlayer && !((Object)(object)((Component)__instance).GetComponent<ValuableObject>() == (Object)null)) { float num = __instance.rb.mass; if (num > 1f) { num = Mathf.Pow(Mathf.Sqrt(num), 1.3333334f); } float num2 = 0.05f; if (GameDirector.instance.PlayerList.Count == 2) { num2 = 0.045f; } if (GameDirector.instance.PlayerList.Count == 1) { num2 = 0.03f; } PhysGrabber.instance.PhysGrabOverCharge(num / (float)__instance.playerGrabbing.Count * num2, 0f); } } } [HarmonyPatch(typeof(PlayerAvatar))] internal class PlayerAvatarPatch { [HarmonyPatch("HealedOther")] [HarmonyPostfix] private static void HealedOtherP(ref PlayerAvatar __instance) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.NoMap) && !((Object)(object)__instance != (Object)(object)PlayerAvatar.instance)) { PlayerHealthPatch.maxHealth = Mathf.Max(10, PlayerHealthPatch.maxHealth - 10); if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.IncreasedDamage)) { PlayerHealthPatch.maxHealth = Mathf.Max(10, PlayerHealthPatch.maxHealth - 10); } Plugin.loggy.LogDebug((object)$"Reduced max health to {PlayerHealthPatch.maxHealth}"); } } } [HarmonyPatch(typeof(PlayerController))] internal class PlayerControllerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakeP(ref float ___sprintRechargeAmount) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.LargeMap)) { Plugin.loggy.LogDebug((object)"Large Map active - increasing stam regen rate..."); ___sprintRechargeAmount *= 1.67f; } } [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartP(ref PlayerController __instance) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.LightsOut)) { Plugin.loggy.LogDebug((object)"Lights Out active - increasing walk speed..."); PlayerController obj = __instance; obj.MoveSpeed *= 1.15f; } } } [HarmonyPatch(typeof(PlayerHealth))] internal class PlayerHealthPatch { private static float healCooldown = 0f; private static float damageCooldown = 0f; public static int maxHealth = -1; [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakeP() { healCooldown = 0f; damageCooldown = 0f; maxHealth = -1; } [HarmonyPatch("Hurt")] [HarmonyPrefix] private static void HurtP(ref int damage) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.IncreasedDamage)) { Plugin.loggy.LogDebug((object)"Increased Damage active - increasing damage to player..."); damage = Mathf.CeilToInt((float)damage * 2f); } damageCooldown = 5f; } [HarmonyPatch("Heal")] [HarmonyPrefix] private static void HealP(ref int healAmount) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.IncreasedDamage)) { Plugin.loggy.LogDebug((object)"Increased Damage active - increasing heal amount for player..."); healAmount = Mathf.CeilToInt((float)healAmount * 2f); } } [HarmonyPatch("Death")] [HarmonyPostfix] private static void DeathP() { if (SemiFunc.IsMasterClientOrSingleplayer()) { LevelStatsManager.AddPlayerDeath(); } } [HarmonyPatch("Update")] [HarmonyPrefix] private static void UpdateP(ref PlayerHealth __instance, ref PlayerAvatar ___playerAvatar, ref bool ___healthSet, ref int ___health) { if (!ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.NoMap) || (Object)(object)___playerAvatar != (Object)(object)PlayerAvatar.instance || Traverse.Create((object)PlayerAvatar.instance).Field("isDisabled").GetValue<bool>()) { return; } if (maxHealth == -1) { if (___healthSet) { maxHealth = Mathf.Max(10, ___health); } return; } if (___health > maxHealth) { maxHealth = Mathf.Max(10, ___health); } damageCooldown = Mathf.Max(0f, damageCooldown - Time.deltaTime); healCooldown = Mathf.Max(0f, healCooldown - Time.deltaTime); if (damageCooldown > 0f || healCooldown > 0f || ___health >= maxHealth) { return; } __instance.Heal(1, false); healCooldown = 3f; if (GameDirector.instance.PlayerList.Count < 2) { return; } int num = 0; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (Traverse.Create((object)player).Field("isDisabled").GetValue<bool>()) { continue; } num++; if (num > 1) { if (num <= 3) { healCooldown += 0.5f; } healCooldown += 0.5f; if (num >= 6) { break; } } } } } [HarmonyPatch(typeof(RoomVolume))] internal class RoomVolumePatch { } [HarmonyPatch(typeof(RoundDirector))] internal class RoundDirectorPatch { } [HarmonyPatch(typeof(RunManager))] internal class RunManagerPatch { [HarmonyPatch("ChangeLevel")] [HarmonyPostfix] private static void ChangeLevel_Postfix(ref RunManager __instance, ref ChangeLevelType _changeLevelType) { LevelStatsManager.OnNewLevel(); if (!SemiFunc.IsMultiplayer() && ((Object)(object)__instance.levelCurrent == (Object)(object)__instance.levelShop || (Object)(object)__instance.levelCurrent == (Object)(object)__instance.levelArena || (Object)(object)__instance.levelCurrent == (Object)(object)__instance.levelLobby)) { Plugin.loggy.LogDebug((object)("Returning due to single player map being " + __instance.levelCurrent.NarrativeName)); ChallengeManager.SetupChallenges(ChallengeManager.ChallengeType.None); } else { ChallengeManager.DetermineChallengeForLevel(__instance.levelsCompleted + 1, ChallengeManager.CurrentSeed); } } [HarmonyPatch("UpdateLevel")] [HarmonyPostfix] private static void UpdateLevel_Postfix(ref RunManager __instance) { LevelStatsManager.OnNewLevel(); } } [HarmonyPatch(typeof(SemiFunc))] internal class SemiFuncPatch { [HarmonyPatch("OnLevelGenDone")] [HarmonyPostfix] private static void OnLevelGenDoneP() { LevelStatsManager.SetModuleCount(LevelStatsManager.totalModules); } } [HarmonyPatch(typeof(StatsManager))] internal class StatsManagerPatch { [HarmonyPatch("LoadGame")] [HarmonyPostfix] private static void LoadGameP(ref StatsManager __instance, ref string fileName) { if (SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.loggy.LogDebug((object)"Loading challenge seed"); if (File.Exists(Application.persistentDataPath + "/saves/" + fileName + "/" + fileName + ".es3") && __instance.dictionaryOfDictionaries.TryGetValue("LSchallengeSeed", out var value)) { ChallengeManager.CurrentSeed = value["currentSeed"]; ChallengeManager.LastChallengeLevel = value["lastChallengeLevel"]; Plugin.loggy.LogDebug((object)$"Loaded challenge data {ChallengeManager.CurrentSeed} / {ChallengeManager.LastChallengeLevel}"); } } } [HarmonyPatch("SaveGame")] [HarmonyPrefix] private static void SaveGameP(ref StatsManager __instance) { if (SemiFunc.IsMasterClientOrSingleplayer()) { if (__instance.dictionaryOfDictionaries.ContainsKey("LSchallengeSeed")) { __instance.dictionaryOfDictionaries["LSchallengeSeed"] = ChallengeManager.challengesDofD; Plugin.loggy.LogDebug((object)$"Setting saved challenge data {ChallengeManager.CurrentSeed} / {ChallengeManager.LastChallengeLevel}"); return; } ChallengeManager.CurrentSeed = Random.Range(0, 100000000); ChallengeManager.LastChallengeLevel = -1; __instance.dictionaryOfDictionaries.Add("LSchallengeSeed", ChallengeManager.challengesDofD); Plugin.loggy.LogDebug((object)$"Saved challenge data {ChallengeManager.CurrentSeed} / {ChallengeManager.LastChallengeLevel}"); } } [HarmonyPatch("SaveFileCreate")] [HarmonyPrefix] private static void SaveFileCreateP(ref StatsManager __instance) { if (SemiFunc.IsMasterClientOrSingleplayer()) { ChallengeManager.CurrentSeed = Random.Range(0, 100000000); ChallengeManager.LastChallengeLevel = -1; if (__instance.dictionaryOfDictionaries.ContainsKey("LSchallengeSeed")) { __instance.dictionaryOfDictionaries["LSchallengeSeed"] = ChallengeManager.challengesDofD; } else { __instance.dictionaryOfDictionaries.Add("LSchallengeSeed", ChallengeManager.challengesDofD); } Plugin.loggy.LogDebug((object)$"Setting challenge data {ChallengeManager.CurrentSeed} / {ChallengeManager.LastChallengeLevel}"); } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdateP() { LevelStatsManager.Update(); } } [HarmonyPatch(typeof(StatsUI))] internal class StatsUIPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartP(ref StatsUI __instance) { LevelStatsUI.Create(__instance); } } [HarmonyPatch(typeof(TruckScreenText))] internal class TruckScreenTextPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void TruckScreenText_Awake() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Helpers.truckScreenState = (PlayerChatBoxState)0; } [HarmonyPatch("PlayerChatBoxStateUpdateRPC")] [HarmonyPostfix] private static void TruckScreenText_PlayerChatBoxStateUpdateRPC(ref PlayerChatBoxState _state) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Helpers.truckScreenState = _state; } } [HarmonyPatch(typeof(ValuableEgg))] internal class ValuableEggPatch { [HarmonyPatch("Explode")] [HarmonyPostfix] private static void TrapStopP(ref ValuableEgg __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>(); if (Object.op_Implicit((Object)(object)component)) { LevelStatsManager.AddValueBroken(Traverse.Create((object)component).Field("dollarValueCurrent").GetValue<float>()); } } } } [HarmonyPatch(typeof(ValuableObject))] internal class ValuableObjectPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartP() { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { LevelStatsManager.AddValuableTotal(); } } [HarmonyPatch("DollarValueSetLogic")] [HarmonyPostfix] private static void DollarValueSetLogicP(ref ValuableObject __instance) { if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.FragileValuables)) { Plugin.loggy.LogDebug((object)"Fragile Valuables active - increasing price..."); Traverse val = Traverse.Create((object)__instance).Field("dollarValueCurrent"); float value = val.GetValue<float>(); if (value <= 1000f) { val.SetValue((object)(value * 1.7f)); } else if (value <= 5000f) { val.SetValue((object)(value * 1.4f)); } else if (value <= 10000f) { val.SetValue((object)(value * 1.2f)); } else { val.SetValue((object)(value * 1.1f)); } } } [HarmonyPatch("DiscoverRPC")] [HarmonyPrefix] private static void DiscoverRPCP(ref bool ___discovered) { if (!___discovered && SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { LevelStatsManager.AddValuableFound(); } } } } namespace LevelScaling.LevelStats { internal class LevelStatsManager { public static bool firstExtractionOpenedThisLevel = false; public static bool _syncedTimer = false; public static float thisLevelTime = 0f; public static int enemyKills = 0; public static int playerDeaths = 0; public static float totalValueExtracted = 0f; public static int totalMapValue = 0; public static int _lastTotalMapValue = 0; public static int _valueFromSurplus = 0; public static float totalValueBroken = 0f; public static int modulesExplored = 0; public static int totalModules = 0; public static int valuablesFound = 0; public static int valuablesTotal = 0; public static int individualOrbDrops = 0; public static int maxIndividualOrbDrops = 0; public static Dictionary<Enemy, int> individualOrbDropCounts = new Dictionary<Enemy, int>(); public static bool allOrbsDropped = false; public static int ExploredPercentage => Mathf.FloorToInt(100f * (float)modulesExplored / (float)totalModules); public static int RemainingTotalMapValue => totalMapValue - (int)totalValueBroken; public static void OnNewLevel() { thisLevelTime = 0f; enemyKills = 0; playerDeaths = 0; totalValueExtracted = 0f; totalValueBroken = 0f; firstExtractionOpenedThisLevel = false; _syncedTimer = false; totalMapValue = 0; _lastTotalMapValue = 0; _valueFromSurplus = 0; modulesExplored = 0; totalModules = 0; valuablesFound = 0; valuablesTotal = 0; individualOrbDrops = 0; maxIndividualOrbDrops = 0; individualOrbDropCounts.Clear(); allOrbsDropped = false; } public static void Update() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.RunIsLevel() || SemiFunc.RunIsShop()) { if (firstExtractionOpenedThisLevel && !Helpers.TruckLeaving) { thisLevelTime += Time.deltaTime; } else if (Helpers.TruckLeaving && !_syncedTimer) { LevelStatsSyncing.TimerSync.RaiseEvent((object)thisLevelTime, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); _syncedTimer = true; } } if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { if ((Object)(object)RoundDirector.instance == (Object)null) { totalMapValue = 0; } else { totalMapValue = Traverse.Create((object)RoundDirector.instance).Field("haulGoalMax").GetValue<int>(); totalMapValue -= _valueFromSurplus; } if (SemiFunc.IsMultiplayer() && totalMapValue != _lastTotalMapValue) { LevelStatsSyncing.ValueSync.RaiseEvent((object)totalMapValue, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); _lastTotalMapValue = totalMapValue; } } } public static void AddEnemyKill() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { enemyKills++; LevelStatsSyncing.KillsSync.RaiseEvent((object)enemyKills, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void AddPlayerDeath() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsShop()) { playerDeaths++; LevelStatsSyncing.DeathsSync.RaiseEvent((object)playerDeaths, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void AddValueExtracted(float value) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { totalValueExtracted += value; LevelStatsSyncing.ExtractedSync.RaiseEvent((object)totalValueExtracted, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void AddValueBroken(float value) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { totalValueBroken += value; LevelStatsSyncing.BrokenSync.RaiseEvent((object)totalValueBroken, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void SetModuleCount(int value) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { totalModules = value; LevelStatsSyncing.ModuleTotalSync.RaiseEvent((object)totalModules, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void AddModuleExplored() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { modulesExplored++; LevelStatsSyncing.ModuleSync.RaiseEvent((object)modulesExplored, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void AddTotalIndivOrbs(int value) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { maxIndividualOrbDrops += value; LevelStatsSyncing.MaxIndivOrbSync.RaiseEvent((object)maxIndividualOrbDrops, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void AddIndivOrb() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { individualOrbDrops++; LevelStatsSyncing.IndivOrbSync.RaiseEvent((object)individualOrbDrops, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void SetAllOrbsFound(bool value) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { allOrbsDropped = value; LevelStatsSyncing.IndivOrbCompleteSync.RaiseEvent((object)allOrbsDropped, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void AddValuableTotal() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { valuablesTotal++; LevelStatsSyncing.ValuablesTotalSync.RaiseEvent((object)valuablesTotal, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void AddValuableFound() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { valuablesFound++; LevelStatsSyncing.ValuablesFoundSync.RaiseEvent((object)valuablesFound, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } } internal class LevelStatsSyncing { public static NetworkedEvent TimerSync; public static NetworkedEvent KillsSync; public static NetworkedEvent DeathsSync; public static NetworkedEvent ExtractedSync; public static NetworkedEvent ValueSync; public static NetworkedEvent BrokenSync; public static NetworkedEvent ModuleTotalSync; public static NetworkedEvent ModuleSync; public static NetworkedEvent MaxIndivOrbSync; public static NetworkedEvent IndivOrbSync; public static NetworkedEvent IndivOrbCompleteSync; public static NetworkedEvent ValuablesTotalSync; public static NetworkedEvent ValuablesFoundSync; public static void Setup() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown TimerSync = new NetworkedEvent("Timer Sync", (Action<EventData>)SyncTimer); KillsSync = new NetworkedEvent("Kills Sync", (Action<EventData>)SyncKills); DeathsSync = new NetworkedEvent("Deaths Sync", (Action<EventData>)SyncDeaths); ExtractedSync = new NetworkedEvent("Extracted Sync", (Action<EventData>)SyncExtracted); ValueSync = new NetworkedEvent("Value Sync", (Action<EventData>)SyncMapValue); BrokenSync = new NetworkedEvent("Broken Sync", (Action<EventData>)SyncBroken); ModuleTotalSync = new NetworkedEvent("ModuleTotalSync", (Action<EventData>)SyncTotalModules); ModuleSync = new NetworkedEvent("ModuleSync", (Action<EventData>)SyncModulesExplored); IndivOrbSync = new NetworkedEvent("IndivOrbSync", (Action<EventData>)SyncIndivOrbCount); MaxIndivOrbSync = new NetworkedEvent("MaxIndivOrbSync", (Action<EventData>)SyncMaxIndivOrbCount); IndivOrbCompleteSync = new NetworkedEvent("IndivOrbCompleteSync", (Action<EventData>)SyncIndivOrbsComplete); ValuablesTotalSync = new NetworkedEvent("ValuablesTotalSync", (Action<EventData>)SyncValuablesTotal); ValuablesFoundSync = new NetworkedEvent("ValuablesFoundSync", (Action<EventData>)SyncValuablesFound); } public static void SyncValuablesFound(EventData data) { LevelStatsManager.valuablesFound = (int)data.CustomData; } public static void SyncValuablesTotal(EventData data) { LevelStatsManager.valuablesTotal = (int)data.CustomData; } public static void SyncIndivOrbCount(EventData data) { LevelStatsManager.individualOrbDrops = (int)data.CustomData; } public static void SyncMaxIndivOrbCount(EventData data) { LevelStatsManager.maxIndividualOrbDrops = (int)data.CustomData; } public static void SyncIndivOrbsComplete(EventData data) { LevelStatsManager.allOrbsDropped = (bool)data.CustomData; } public static void SyncTotalModules(EventData data) { LevelStatsManager.totalModules = (int)data.CustomData; } public static void SyncModulesExplored(EventData data) { LevelStatsManager.modulesExplored = (int)data.CustomData; } public static void SyncTimer(EventData data) { LevelStatsManager.thisLevelTime = (float)data.CustomData; } public static void SyncKills(EventData data) { LevelStatsManager.enemyKills = (int)data.CustomData; } public static void SyncDeaths(EventData data) { LevelStatsManager.playerDeaths = (int)data.CustomData; } public static void SyncExtracted(EventData data) { LevelStatsManager.totalValueExtracted = (float)data.CustomData; } public static void SyncMapValue(EventData data) { LevelStatsManager.totalMapValue = (int)data.CustomData; } public static void SyncBroken(EventData data) { LevelStatsManager.totalValueBroken = (float)data.CustomData; } } internal class LevelStatsUI : SemiUI { public static LevelStatsUI instance; public TextMeshProUGUI statsNumbers; public TextMeshProUGUI statsText; public TextMeshProUGUI statsHeader; private bool dontScoot = true; private static readonly Color colorNone = new Color(0.5f, 0.5f, 0.5f); private static readonly Color colorSubtext = new Color(0.63f, 0.63f, 0.63f); private static readonly Color colorBad = new Color(1f, 0.7f, 0.7f); private static readonly Color colorNeutral = new Color(1f, 1f, 0.2f); private static readonly Color colorGood = new Color(0.2f, 1f, 0.2f); private static readonly Color colorSubtextGood = new Color(0.15f, 0.7f, 0.15f); private static readonly Color colorSubtextNeutral = new Color(0.7f, 0.7f, 0.15f); private static readonly Color colorSubtextBad = new Color(0.7f, 0.45f, 0.45f); private static readonly Color colorBase = Color.white; private static bool showBase => Plugin.StatsUIShow_Base.Value; private static bool showShop => Plugin.StatsUIShow_Shop.Value; private static bool showMap => Plugin.StatsUIShow_Map.Value; private static bool showEnd => Plugin.StatsUIShow_EndOfLevel.Value; public static void Create(StatsUI orig) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) Plugin.loggy.LogDebug((object)"creating LevelStatsUI object..."); if (SemiFunc.RunIsShop() || SemiFunc.RunIsLevel()) { GameObject obj = Object.Instantiate<GameObject>(((Component)orig).gameObject, ((Component)orig).gameObject.transform.parent); ((Object)obj).name = "LevelStatsUI"; obj.transform.localPosition = new Vector3(240f, -20f, 0f); StatsUI val = default(StatsUI); if (obj.TryGetComponent<StatsUI>(ref val)) { Object.DestroyImmediate((Object)(object)val); } obj.AddComponent<LevelStatsUI>(); } } protected override void Start() { //IL_00ab: 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) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) ((SemiUI)this).Start(); if ((Object)(object)instance != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)instance).gameObject); } instance = this; statsHeader = ((Component)((Component)this).gameObject.transform.GetChild(1)).GetComponent<TextMeshProUGUI>(); ((Behaviour)statsHeader).enabled = true; if (SemiFunc.RunIsLevel()) { ((TMP_Text)statsHeader).text = $"LEVEL {Helpers.CurrentLevel}"; } else if (SemiFunc.RunIsShop()) { ((TMP_Text)statsHeader).text = $"SHOP {Helpers.CurrentLevel - 1}"; } ((Graphic)statsHeader).color = Helpers.GetDifficultyColor(Helpers.CurrentLevel); statsText = ((Component)((Component)this).gameObject.transform.GetChild(0)).GetComponent<TextMeshProUGUI>(); TextMeshProUGUI obj = statsText; ((TMP_Text)obj).margin = ((TMP_Text)obj).margin + new Vector4(-500f, 0f, 0f, 0f); Transform transform = ((TMP_Text)statsText).transform; transform.localPosition -= new Vector3(10f, 0f, 0f); ((TMP_Text)statsText).alignment = (TextAlignmentOptions)260; ((Graphic)statsText).color = new Color(1f, 0.4f, 0f); ((TMP_Text)statsText).fontStyle = (FontStyles)0; statsNumbers = ((Component)this).GetComponent<TextMeshProUGUI>(); ((TMP_Text)statsNumbers).alignment = (TextAlignmentOptions)257; ((Graphic)statsNumbers).color = Color.white; ((TMP_Text)statsNumbers).fontStyle = (FontStyles)1; if (Plugin.ShowOldOvercharge.Value) { ((MonoBehaviour)this).StartCoroutine(EnableOvercharge()); } } private IEnumerator EnableOvercharge() { yield return (object)new WaitForSeconds(2f); OverchargeUI val = Object.FindObjectOfType<OverchargeUI>(true); if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(true); } } protected override void Update() { ((SemiUI)this).Update(); ((TMP_Text)statsText).text = ""; ((TMP_Text)statsNumbers).text = ""; ScootLogic(); SetText(); } private void ScootLogic() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) dontScoot = showBase; if (SemiFunc.RunIsShop()) { dontScoot = showShop; } if (Helpers.TruckLeaving && showEnd) { dontScoot = true; } if (MapToolControllerPatch.mapToolActive) { dontScoot = showMap; } if (!dontScoot) { ((SemiUI)this).SemiUIScoot(new Vector2(200f, 0f)); } } private void SetText() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) if (Plugin.StatsUIDisplay_Challenge.Value && ChallengeManager.currentChallenges.Count > 0) { ChallengeManager.Challenge challenge = ChallengeManager.GetChallenge(ChallengeManager.currentChallenges[0]); TextMeshProUGUI obj = statsText; ((TMP_Text)obj).text = ((TMP_Text)obj).text + "CHALLENGE\n"; TextMeshProUGUI obj2 = statsNumbers; ((TMP_Text)obj2).text = ((TMP_Text)obj2).text + Helpers.ColoredText(challenge.name, Color.red) + "\n"; } if (Plugin.StatsUIDisplay_Time.Value) { TextMeshProUGUI obj3 = statsText; ((TMP_Text)obj3).text = ((TMP_Text)obj3).text + "TIME\n"; string text = Helpers.ColoredText(Helpers.TimeToString(LevelStatsManager.thisLevelTime), (!LevelStatsManager.firstExtractionOpenedThisLevel) ? colorNone : (Helpers.TruckLeaving ? colorGood : colorBase)); TextMeshProUGUI obj4 = statsNumbers; ((TMP_Text)obj4).text = ((TMP_Text)obj4).text + text + "\n"; } if (SemiFunc.RunIsShop() && Plugin.StatsUIDisplay_Deaths.Value) { TextMeshProUGUI obj5 = statsText; ((TMP_Text)obj5).text = ((TMP_Text)obj5).text + "DEATHS\n"; string text2 = Helpers.ColoredText($"{LevelStatsManager.playerDeaths}", (LevelStatsManager.playerDeaths == 0) ? colorNone : colorBad); TextMeshProUGUI obj6 = statsNumbers; ((TMP_Text)obj6).text = ((TMP_Text)obj6).text + text2 + "\n"; } if (SemiFunc.RunIsLevel()) { if (Plugin.StatsUIDisplay_OrbDrops.Value) { TextMeshProUGUI obj7 = statsText; ((TMP_Text)obj7).text = ((TMP_Text)obj7).text + "ORB DROPS\n"; string text3 = Helpers.ColoredText(LevelStatsManager.enemyKills.ToString(), LevelStatsManager.allOrbsDropped ? colorGood : ((LevelStatsManager.enemyKills == 0) ? colorNone : colorBase)); TextMeshProUGUI obj8 = statsNumbers; ((TMP_Text)obj8).text = ((TMP_Text)obj8).text + text3 + "\n"; } if (Plugin.StatsUIDisplay_Extracted.Value) { TextMeshProUGUI obj9 = statsText; ((TMP_Text)obj9).text = ((TMP_Text)obj9).text + "EXTRACTED\n"; string text4 = Helpers.ColoredText("$" + SemiFunc.DollarGetString((int)LevelStatsManager.totalValueExtracted), GetExtractedAColor()); TextMeshProUGUI val = statsNumbers; ((TMP_Text)val).text = ((TMP_Text)val).text + text4 + " <size=75%>" + GetExtractedB() + "</size>\n"; } if (Plugin.StatsUIDisplay_Broken.Value) { TextMeshProUGUI obj10 = statsText; ((TMP_Text)obj10).text = ((TMP_Text)obj10).text + "BROKEN\n"; string text5 = Helpers.ColoredText("-$" + SemiFunc.DollarGetString((int)LevelStatsManager.totalValueBroken), (LevelStatsManager.totalValueBroken < 1f) ? colorNone : colorBad); TextMeshProUGUI obj11 = statsNumbers; ((TMP_Text)obj11).text = ((TMP_Text)obj11).text + text5 + "\n"; } if (Plugin.StatsUIDisplay_Found.Value) { TextMeshProUGUI obj12 = statsText; ((TMP_Text)obj12).text = ((TMP_Text)obj12).text + "FOUND\n"; string arg = Helpers.ColoredText($"/{LevelStatsManager.valuablesTotal}", colorSubtext); string text6 = Helpers.ColoredText($"{LevelStatsManager.valuablesFound} <size=75%>{arg}</size>", (LevelStatsManager.valuablesFound >= LevelStatsManager.valuablesTotal) ? colorGood : ((LevelStatsManager.valuablesFound < 1) ? colorNone : colorBase)); TextMeshProUGUI obj13 = statsNumbers; ((TMP_Text)obj13).text = ((TMP_Text)obj13).text + text6 + "\n"; } if (Plugin.StatsUIDisplay_Explored.Value) { TextMeshProUGUI obj14 = statsText; ((TMP_Text)obj14).text = ((TMP_Text)obj14).text + "EXPLORED\n"; string arg2 = Helpers.ColoredText($"/{LevelStatsManager.totalModules}", colorSubtext); string text7 = Helpers.ColoredText($"{LevelStatsManager.modulesExplored} <size=75%>{arg2}</size>", (LevelStatsManager.modulesExplored >= LevelStatsManager.totalModules) ? colorGood : ((LevelStatsManager.modulesExplored < 1) ? colorNone : colorBase)); TextMeshProUGUI obj15 = statsNumbers; ((TMP_Text)obj15).text = ((TMP_Text)obj15).text + text7 + "\n"; } } } private Color GetExtractedAColor() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (LevelStatsManager.totalValueExtracted >= (float)LevelStatsManager.totalMapValue) { return colorGood; } if (LevelStatsManager.totalValueExtracted >= (float)LevelStatsManager.RemainingTotalMapValue) { return colorNeutral; } if (LevelStatsMana