Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CartInventory v1.4.1
CartInventory.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CartInventory.Challenges; using CartInventory.DTO; using CartInventory.Extensions; using CartInventory.Patches; using CartInventory.Shop; using HarmonyLib; using MenuLib; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Photon.Pun; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Gridorius")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+53b12c1670ec4d0b0955434d7b56a871d0df0b62")] [assembly: AssemblyProduct("CartInventory")] [assembly: AssemblyTitle("CartInventory")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CartInventory { public class CarefulHelper { public static void OnDestroy(ValuableObject component) { //IL_010a: Unknown result type (might be due to invalid IL or missing references) ValuableObject component2 = component; if (!SemiFunc.IsMasterClientOrSingleplayer() || !ModConfig.CarefulMode.Value || !SpawnHelper.SpawnedBags.Contains(component2)) { return; } RoomVolumeCheck value = Traverse.Create((object)component2).Field("roomVolumeCheck").GetValue<RoomVolumeCheck>(); if (!Traverse.Create((object)value).Field("inExtractionPoint").GetValue<bool>() && !TruckController.TruckItems.Any((ValuableAndPhysic vf) => (Object)(object)vf.Valuable == (Object)(object)component2)) { List<EnemySetup> enemiesDifficulty = EnemyDirector.instance.enemiesDifficulty2; List<EnemySetup> enemiesDifficulty2 = EnemyDirector.instance.enemiesDifficulty3; (EnemySetup, int) tuple = (PickEnemy(enemiesDifficulty), 2); if (Helpers.Chance(10)) { tuple = (PickEnemy(enemiesDifficulty2), 1); } CartInventory.Logger.LogWarning((object)("Spawn " + ((Object)tuple.Item1).name)); SpawnHelper.SpawnEnemy(tuple.Item1, ((Component)component2).transform.position, tuple.Item2); } } public static void RollSpawn(ValuableObject component) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) if (Helpers.Chance(ModConfig.CarefulSkipChance.Value)) { return; } List<EnemySetup> enemiesDifficulty = EnemyDirector.instance.enemiesDifficulty1; List<EnemySetup> enemiesDifficulty2 = EnemyDirector.instance.enemiesDifficulty2; List<EnemySetup> enemiesDifficulty3 = EnemyDirector.instance.enemiesDifficulty3; while (LevelStats.TotalValuablesDamage >= (float)ModConfig.CarefulSpawnT1Price.Value) { (EnemySetup, float, int) tuple = (PickEnemy(enemiesDifficulty), 3000f, Random.Range(1, 4)); if (LevelStats.TotalValuablesDamage >= (float)ModConfig.CarefulSpawnT3Price.Value) { tuple = (PickEnemy(enemiesDifficulty3), ModConfig.CarefulSpawnT3Price.Value, 1); } else if (LevelStats.TotalValuablesDamage >= (float)ModConfig.CarefulSpawnT2Price.Value) { tuple = (PickEnemy(enemiesDifficulty2), ModConfig.CarefulSpawnT2Price.Value, Random.Range(1, 2)); } CartInventory.Logger.LogWarning((object)("Spawn " + ((Object)tuple.Item1).name)); SpawnHelper.SpawnEnemy(tuple.Item1, ((Component)component).transform.position, tuple.Item3); LevelStats.TotalValuablesDamage -= tuple.Item2; } } public static EnemySetup PickEnemy(List<EnemySetup> enemies) { int num = Random.Range(0, enemies.Count); int num2 = 0; foreach (EnemySetup item in enemies.Where((EnemySetup e) => !((Object)e).name.Contains("Ceiling Eye") && !((Object)e).name.Contains("Slow Walker") && !((Object)e).name.Contains("Thin Man") && !((Object)e).name.Contains("Hidden"))) { if (num2 == num) { return item; } num2++; } return enemies.First(); } } [BepInPlugin("Gridorius.CartInventory", "CartInventory", "1.0")] public class CartInventory : BaseUnityPlugin { private TruckController _truckController; internal static CartInventory Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } public bool IsLoaded { get; private set; } public SaveManager SaveManager { get; set; } private void Awake() { Instance = this; SaveManager = new SaveManager(); ModConfig.Configure(((BaseUnityPlugin)this).Config); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); IsLoaded = true; Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); _truckController = new TruckController(); ShopUI.Initialize(); } private void Update() { if (ModConfig.EnableTruckItems.Value) { _truckController.CheckTruckValuables(); } } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public class Helpers { public static bool Chance(int chance) { int num = Random.Range(1, 99); return num >= 100 - ((chance > 100) ? 100 : ((chance >= 0) ? chance : 0)); } public static bool Chance(float chance) { return Chance((int)chance); } } public class LevelLerpBuilder { private readonly Dictionary<float, (bool, float)> LevelValues = new Dictionary<float, (bool, float)>(); public LevelLerpBuilder Add(float toLevel, float toValue) { LevelValues.Add(toLevel, (true, toValue)); return this; } public LevelLerpBuilder AddScalar(float toLevel, float toValue) { LevelValues.Add(toLevel, (false, toValue)); return this; } public float GetValue(float outOfRange, float startRange = 1f) { (float, float) tuple = (-100f, -100f); foreach (KeyValuePair<float, (bool, float)> levelValue in LevelValues) { if ((float)LevelStats.CurrentLevel <= levelValue.Key) { if (!levelValue.Value.Item1) { return levelValue.Value.Item2; } if (tuple.Item1 < 0f) { return Mathf.Lerp(startRange, levelValue.Value.Item2, Mathf.InverseLerp(1f, levelValue.Key, (float)LevelStats.CurrentLevel)); } return Mathf.Lerp(tuple.Item2, levelValue.Value.Item2, Mathf.InverseLerp(tuple.Item1 + 1f, levelValue.Key, (float)LevelStats.CurrentLevel)); } tuple = (levelValue.Key, levelValue.Value.Item2); } return outOfRange; } public int GetIntValue(float outOfRange, float startRange = 1f) { return Mathf.RoundToInt(GetValue(outOfRange, startRange)); } } public class LevelStats { public static float TotalLost; public static int EnemyKills = 0; public static List<PhysGrabCart> Carts = new List<PhysGrabCart>(); public static float LevelDollars; public static int TotalModules; public static int ExploredModules; public static float TotalValuablesDamage; public static bool FirstExtractionPointOpened = false; public static float Time = 0f; public static float ValuableChangeTime = 0f; public static PlayerChatBoxState TruckScreenState = (PlayerChatBoxState)0; public static List<ValuableObject> ValuableObjects = new List<ValuableObject>(); public static List<ValuableObject> Orbs = new List<ValuableObject>(); public static Dictionary<PhysGrabCart, List<ValuableObject>> CartValuables = new Dictionary<PhysGrabCart, List<ValuableObject>>(); public static List<EnemyParent> ImmortalEnemies = new List<EnemyParent>(); public static int EnemyTotal = 0; public static int CurrentLevel => RunManager.instance.levelsCompleted + 1; public static bool TruckLeaving { get { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 PlayerChatBoxState truckScreenState = TruckScreenState; if (truckScreenState - 2 <= 1) { return true; } return false; } } public static int CurrentModCount => Traverse.Create((object)LevelGenerator.Instance).Field("ModuleAmount").GetValue<int>(); public static int CurrentExtractionCount => Traverse.Create((object)LevelGenerator.Instance).Field("ExtractionAmount").GetValue<int>(); public static void Clear() { ResetValuables(); LevelDollars = 0f; TotalLost = 0f; Time = 0f; EnemyKills = 0; TotalValuablesDamage = 0f; TotalModules = 0; EnemyTotal = 0; ExploredModules = 0; FirstExtractionPointOpened = false; Orbs.Clear(); ImmortalEnemies.Clear(); Carts.Clear(); CartValuables.Clear(); } public static void AddModuleExplored() { ExploredModules++; } public static (int, float) GetCollectedCount() { (int, float) result = (0, 0f); foreach (ValuableObject valuable in ValuableObjects) { RoomVolumeCheck value = Traverse.Create((object)valuable).Field("roomVolumeCheck").GetValue<RoomVolumeCheck>(); bool value2 = Traverse.Create((object)value).Field("inExtractionPoint").GetValue<bool>(); float dollarValue = valuable.GetDollarValue(); if (value2 || CartValuables.Any<KeyValuePair<PhysGrabCart, List<ValuableObject>>>((KeyValuePair<PhysGrabCart, List<ValuableObject>> cart) => cart.Value.Contains(valuable))) { result.Item1++; result.Item2 += dollarValue; } } return result; } public static void UpdateLevelDollars() { LevelDollars = 0f; foreach (ValuableObject valuableObject in ValuableObjects) { LevelDollars += valuableObject.GetDollarValue(); } } public static void RegisterValuableObject(ValuableObject valuableObject) { if (!ValuableObjects.Contains(valuableObject) && ((Object)valuableObject).name.Contains("(Clone)")) { ValuableObjects.Add(valuableObject); UpdateLevelDollars(); } } public static void RemoveValuableObject(ValuableObject valuableObject) { if (Orbs.Contains(valuableObject)) { Orbs.Remove(valuableObject); } if (ValuableObjects.Contains(valuableObject)) { ValuableObjects.Remove(valuableObject); } } public static void ResetValuables() { ValuableObjects = new List<ValuableObject>(); } public static void Update() { if ((SemiFunc.RunIsLevel() || SemiFunc.RunIsShop()) && FirstExtractionPointOpened && !TruckLeaving) { Time += Time.deltaTime; ValuableChangeTime += Time.deltaTime; } if (!(ValuableChangeTime >= 120f)) { return; } ValuableChangeTime -= 120f; if (ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.FastExtraction)) { foreach (ValuableObject valuableObject in ValuableObjects) { valuableObject.SetDollarValue(valuableObject.GetDollarValue() * 0.9f); } UpdateLevelDollars(); } if (!ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.MoneyTime)) { return; } foreach (ValuableObject valuableObject2 in ValuableObjects) { valuableObject2.SetDollarValue(valuableObject2.GetDollarValue() * 1.1f); } UpdateLevelDollars(); } } internal class LevelStatsUI : SemiUI { [CompilerGenerated] private sealed class <EnableOvercharge>d__11 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public LevelStatsUI <>4__this; private OverchargeUI <objectOfType>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EnableOvercharge>d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <objectOfType>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; <objectOfType>5__1 = Object.FindObjectOfType<OverchargeUI>(true); if (Object.op_Implicit((Object)(object)<objectOfType>5__1)) { ((Component)<objectOfType>5__1).gameObject.SetActive(true); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static LevelStatsUI instance; private static readonly Color DangerColor = new Color(0.89f, 0.15f, 0.24f); private static readonly Color DollarColor = new Color(0.15f, 0.53f, 0.39f); private static readonly Color GrayColor = new Color(0.79f, 0.79f, 0.79f); private static readonly Color KeyColor = new Color(0.95f, 0.47f, 0.21f); private bool dontScoot = true; public TextMeshProUGUI statsText; public LevelStatsUI(CartInventory cartInventory) { } protected override void Start() { //IL_0055: 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; statsText = ((Component)this).gameObject.GetComponent<TextMeshProUGUI>(); ((TMP_Text)statsText).alignment = (TextAlignmentOptions)257; ((TMP_Text)statsText).color = Color.white; ((TMP_Text)statsText).fontStyle = (FontStyles)0; } protected override void Update() { //IL_0037: 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_009c: Unknown result type (might be due to invalid IL or missing references) ((SemiUI)this).Update(); ((TMP_Text)statsText).text = ""; if (!MapToolControllerPatch.MapIsOpen) { SetText(); } if (((Component)this).gameObject.transform.localPosition.x != ModConfig.StatusBarX.Value || ((Component)this).gameObject.transform.localPosition.y != ModConfig.StatusBarY.Value) { ((Component)this).gameObject.transform.localPosition = new Vector3(ModConfig.StatusBarX.Value, ModConfig.StatusBarY.Value, 0f); } } public static void Create(StatsUI orig) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) if ((SemiFunc.RunIsShop() || SemiFunc.RunIsLevel()) && ModConfig.ShowHud.Value) { GameObject val = GameObject.Find("Game Hud"); GameObject val2 = GameObject.Find("Tax Haul"); GameObject val3 = new GameObject("LevelStatsUI"); val3.transform.localPosition = new Vector3(ModConfig.StatusBarX.Value, ModConfig.StatusBarY.Value, 0f); val3.AddComponent(typeof(TextMeshProUGUI)); TextMeshProUGUI component = val3.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).font = val2.GetComponent<TMP_Text>().font; ((TMP_Text)component).fontSize = 19f; ((TMP_Text)component).enableWordWrapping = false; ((TMP_Text)component).alignment = (TextAlignmentOptions)257; val3.transform.SetParent(val.transform, false); val3.AddComponent<LevelStatsUI>(); } } [IteratorStateMachine(typeof(<EnableOvercharge>d__11))] private IEnumerator EnableOvercharge() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EnableOvercharge>d__11(0) { <>4__this = this }; } private void ScootLogic() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) ((SemiUI)this).SemiUIScoot(new Vector2(0f, 0f)); } public static string ColoredText(string text, Color color) { //IL_0001: 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>"; } private void SetText() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.RunIsShop() && !SemiFunc.RunIsLevel()) { return; } if (ModConfig.HudShowLevel.Value) { DrawLine("<size=150%>LEVEL", LevelStats.CurrentLevel + "<size=100%>", GrayColor); } if (ModConfig.HudShowLevel.Value) { DrawLine("CHALLENGE", ChallengeManager.CurrentChallengeName(), GrayColor); } if (ModConfig.HudShowTime.Value) { DrawLine("TIME", LevelStats.Time.GetTimeString(), GrayColor); } if (ModConfig.HudShowSaved.Value && CartInventory.Instance.SaveManager.Data.TrackDollars > 0) { DrawLine("SAVED", CartInventory.Instance.SaveManager.Data.TrackDollars.FormatDollars(), DollarColor); } if (SemiFunc.RunIsShop()) { return; } (int, float) collectedCount = LevelStats.GetCollectedCount(); if (ModConfig.HudShowCollected.Value) { string arg = ""; if (ModConfig.HudShowCollectedPercent.Value) { decimal num = ((LevelStats.ValuableObjects.Count > 0) ? ((decimal)collectedCount.Item1 / (decimal)LevelStats.ValuableObjects.Count) : 1m); arg = $"({num:p})"; } DrawLine("COLLECTED", $"{collectedCount.Item1} / {LevelStats.ValuableObjects.Count}{arg}", GrayColor); } if (ModConfig.HudShowDollars.Value) { string text = ""; if (ModConfig.HudShowDollarsPercent.Value) { decimal num2 = ((LevelStats.LevelDollars > 0f) ? ((decimal)collectedCount.Item2 / (decimal)LevelStats.LevelDollars) : 1m); text = $"({num2:p})"; } DrawLine("DOLLARS", collectedCount.Item2.FormatDollars() + " / " + LevelStats.LevelDollars.FormatDollars() + text, DollarColor); } if (ModConfig.HudShowLost.Value && LevelStats.TotalLost > 0f) { DrawLine("LOST", LevelStats.TotalLost.FormatDollars(), DangerColor); } if (ModConfig.HudShowExplored.Value) { DrawLine("EXPLORED", $"{LevelStats.ExploredModules} / {LevelStats.TotalModules}", GrayColor); } if (ModConfig.HudShowImmortal.Value) { DrawLine("IMMORTAL", $"{LevelStats.ImmortalEnemies.Count} / {LevelStats.EnemyTotal}", DangerColor); } if (ModConfig.HudShowKills.Value) { DrawLine("KILLS", $"{LevelStats.EnemyKills}", GrayColor); } if (!ModConfig.HudShowCarts.Value) { return; } int num3 = 0; DrawLine("CARTS", "", Color.green); foreach (PhysGrabCart cart in LevelStats.Carts) { if (Object.op_Implicit((Object)(object)cart)) { int value = Traverse.Create((object)cart).Field("haulCurrent").GetValue<int>(); int num4 = Mathf.RoundToInt(Vector3.Distance(((Component)PlayerController.instance).transform.position, ((Component)cart).transform.position)); TextMeshProUGUI obj = statsText; ((TMP_Text)obj).text = ((TMP_Text)obj).text + $"<line-height=60%> cart-{num3++} / {ColoredText(num4.ToString(), GrayColor)}m"; if (value > 0) { TextMeshProUGUI obj2 = statsText; ((TMP_Text)obj2).text = ((TMP_Text)obj2).text + " / " + ColoredText(value.FormatDollars(), DollarColor); } TextMeshProUGUI obj3 = statsText; ((TMP_Text)obj3).text = ((TMP_Text)obj3).text + "\n"; } } } private void DrawLine(string key, string value, Color valueColor) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = statsText; ((TMP_Text)val).text = ((TMP_Text)val).text + "<line-height=60%><font-weight=900>" + ColoredText(key + ": ", KeyColor) + "</font-weight> " + ColoredText(value, valueColor) + "\n"; } } public static class ModConfig { private static ConfigDescription ChanceRange = new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()); public static ConfigEntry<bool>? EnableValuableConvert { get; private set; } public static ConfigEntry<float>? CartVacuumCleanerScale { get; private set; } public static ConfigEntry<bool>? EnableInternetShop { get; private set; } public static ConfigEntry<bool>? SkipShopLevel { get; private set; } public static ConfigEntry<string>? InternetShopKey { get; private set; } public static ConfigEntry<bool>? ShowHud { get; private set; } public static ConfigEntry<float>? StatusBarX { get; private set; } public static ConfigEntry<float>? StatusBarY { get; private set; } public static ConfigEntry<bool>? EnableTruckItems { get; private set; } public static ConfigEntry<string>? TruckExtractionKey { get; private set; } public static ConfigEntry<string>? BagSplitKey { get; private set; } public static ConfigEntry<bool>? CarefulMode { get; private set; } public static ConfigEntry<bool>? CarefulOrbDamage { get; private set; } public static ConfigEntry<int>? CarefulSkipChance { get; private set; } public static ConfigEntry<int>? CarefulSpawnT3Price { get; private set; } public static ConfigEntry<int>? CarefulSpawnT2Price { get; private set; } public static ConfigEntry<int>? CarefulSpawnT1Price { get; private set; } public static ConfigEntry<bool>? EnableModuleScaling { get; private set; } public static ConfigEntry<bool>? EnableValuableScaling { get; private set; } public static ConfigEntry<bool>? EnableEnemyScaling { get; private set; } public static ConfigEntry<bool>? EnableImmortalEnemy { get; private set; } public static ConfigEntry<int>? ImmortalEnemyChance { get; private set; } public static ConfigEntry<int>? EnemyScalingSkipLevels { get; private set; } public static ConfigEntry<float>? EnemyTier1Multiplier { get; private set; } public static ConfigEntry<float>? EnemyTier2Multiplier { get; private set; } public static ConfigEntry<float>? EnemyTier3Multiplier { get; private set; } public static ConfigEntry<bool>? EnableExtractionScaling { get; private set; } public static ConfigEntry<bool>? HudShowLevel { get; private set; } public static ConfigEntry<bool>? HudShowTime { get; private set; } public static ConfigEntry<bool>? HudShowSaved { get; private set; } public static ConfigEntry<bool>? HudShowCollected { get; private set; } public static ConfigEntry<bool>? HudShowCollectedPercent { get; private set; } public static ConfigEntry<bool>? HudShowDollars { get; private set; } public static ConfigEntry<bool>? HudShowDollarsPercent { get; private set; } public static ConfigEntry<bool>? HudShowLost { get; private set; } public static ConfigEntry<bool>? HudShowExplored { get; private set; } public static ConfigEntry<bool>? HudShowImmortal { get; private set; } public static ConfigEntry<bool>? HudShowKills { get; private set; } public static ConfigEntry<bool>? HudShowCarts { get; private set; } public static void Configure(ConfigFile config) { Cart(config); Shop(config); Hud(config); Truck(config); CfMode(config); Scaling(config); } private static void Cart(ConfigFile config) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown string text = "Cart"; ConfigDescription val = new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()); EnableValuableConvert = config.Bind<bool>(text, "Enable valuable convert", true, (ConfigDescription)null); CartVacuumCleanerScale = config.Bind<float>(text, "Cart vacuum cleaner scale", 0.6f, val); } private static void Shop(ConfigFile config) { string text = "Internet shop"; EnableInternetShop = config.Bind<bool>(text, "Enable new shop interface", true, (ConfigDescription)null); SkipShopLevel = config.Bind<bool>(text, "Skip shop level", true, (ConfigDescription)null); InternetShopKey = config.Bind<string>(text, "Shop open button", "l", (ConfigDescription)null); } private static void Hud(ConfigFile config) { string text = "Status hud"; ShowHud = config.Bind<bool>(text, "Show hud", true, (ConfigDescription)null); StatusBarX = config.Bind<float>(text, "Hud position x", -240f, (ConfigDescription)null); StatusBarY = config.Bind<float>(text, "Hud position y", 30f, (ConfigDescription)null); HudShowLevel = config.Bind<bool>(text, "Show level", true, (ConfigDescription)null); HudShowTime = config.Bind<bool>(text, "Show time", true, (ConfigDescription)null); HudShowSaved = config.Bind<bool>(text, "Show saved dollars", true, (ConfigDescription)null); HudShowCollected = config.Bind<bool>(text, "Show collected valuables", true, (ConfigDescription)null); HudShowCollectedPercent = config.Bind<bool>(text, "Show collected valuables percent", true, (ConfigDescription)null); HudShowDollars = config.Bind<bool>(text, "Show level dollars", true, (ConfigDescription)null); HudShowDollarsPercent = config.Bind<bool>(text, "Show level dollars collected percent", true, (ConfigDescription)null); HudShowLost = config.Bind<bool>(text, "Show lost dollars", true, (ConfigDescription)null); HudShowExplored = config.Bind<bool>(text, "Show amount of explored modules", true, (ConfigDescription)null); HudShowImmortal = config.Bind<bool>(text, "Show immortal enemies", true, (ConfigDescription)null); HudShowKills = config.Bind<bool>(text, "Show kills", true, (ConfigDescription)null); HudShowCarts = config.Bind<bool>(text, "Show carts info", true, (ConfigDescription)null); } private static void Truck(ConfigFile config) { string text = "Truck"; EnableTruckItems = config.Bind<bool>(text, "Enable save items in truck", true, (ConfigDescription)null); TruckExtractionKey = config.Bind<string>(text, "Button to extract truck dollars into cart", "Slash", (ConfigDescription)null); BagSplitKey = config.Bind<string>(text, "Button to split grabbed bag", "Period", (ConfigDescription)null); } private static void CfMode(ConfigFile config) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown string text = "Careful mode"; ConfigDescription val = new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 20000), Array.Empty<object>()); CarefulMode = config.Bind<bool>(text, "Enable", true, (ConfigDescription)null); CarefulOrbDamage = config.Bind<bool>(text, "Register orb damage", false, (ConfigDescription)null); CarefulSkipChance = config.Bind<int>(text, "Chance skip spawn, damage saved to next iteration", 40, ChanceRange); CarefulSpawnT3Price = config.Bind<int>(text, "Damage to spawn enemy tier 3", 5000, val); CarefulSpawnT2Price = config.Bind<int>(text, "Damage to spawn enemy tier 2", 3000, val); CarefulSpawnT1Price = config.Bind<int>(text, "Damage to spawn enemy tier 1", 2000, val); } private static void Scaling(ConfigFile config) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown string text = "Scaling"; ConfigDescription val = new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()); EnableModuleScaling = config.Bind<bool>(text, "Enable module amount scaling", true, (ConfigDescription)null); EnableValuableScaling = config.Bind<bool>(text, "Enable valuable amount and price scaling", true, (ConfigDescription)null); EnableEnemyScaling = config.Bind<bool>(text, "Enable enemy amount scaling", true, (ConfigDescription)null); EnableImmortalEnemy = config.Bind<bool>(text, "Enable immortal enemies", true, (ConfigDescription)null); ImmortalEnemyChance = config.Bind<int>(text, "Immortal spawn chance", 30, ChanceRange); EnemyScalingSkipLevels = config.Bind<int>(text, "Enemy scaling skip levels", 1, (ConfigDescription)null); EnemyTier3Multiplier = config.Bind<float>(text, "Enemy tier 3 amount multiplier", 1.2f, val); EnemyTier2Multiplier = config.Bind<float>(text, "Enemy tier 2 amount multiplier", 1.4f, val); EnemyTier1Multiplier = config.Bind<float>(text, "Enemy tier 1 amount multiplier", 1.8f, val); EnableExtractionScaling = config.Bind<bool>(text, "Enable extraction amount scaling", true, (ConfigDescription)null); } } public class SaveManager { private string _currentSaveId = "default"; public SaveData Data { get; private set; } = new SaveData(); public void UpdateSaveId() { try { if ((Object)(object)StatsManager.instance != (Object)null) { string text = (string)AccessTools.Field(typeof(StatsManager), "saveFileCurrent").GetValue(StatsManager.instance); if (!string.IsNullOrEmpty(text)) { if (text.EndsWith(".sav")) { text = text.Substring(0, text.Length - 4); } _currentSaveId = text; return; } } if (string.IsNullOrEmpty(_currentSaveId)) { _currentSaveId = "default"; } } catch (Exception) { if (string.IsNullOrEmpty(_currentSaveId)) { _currentSaveId = "default"; } } } public string GetCurrentSaveFilePath() { return Path.Combine(Path.Combine(Paths.ConfigPath, "CartInventory"), _currentSaveId + ".json"); } public void Save() { if (SemiFunc.IsMultiplayer()) { return; } string currentSaveFilePath = GetCurrentSaveFilePath(); if (!File.Exists(currentSaveFilePath)) { string directoryName = Path.GetDirectoryName(currentSaveFilePath); if (directoryName != null && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } } string contents = JsonConvert.SerializeObject((object)Data, (Formatting)1); File.WriteAllText(currentSaveFilePath, contents); } public void Load() { if (SemiFunc.IsMultiplayer()) { return; } string currentSaveFilePath = GetCurrentSaveFilePath(); if (File.Exists(currentSaveFilePath)) { SaveData saveData = JsonConvert.DeserializeObject<SaveData>(File.ReadAllText(currentSaveFilePath)); if (saveData != null) { Data = saveData; } } } public void Delete() { if (!SemiFunc.IsMultiplayer()) { Data.TrackDollars = 0; string currentSaveFilePath = GetCurrentSaveFilePath(); if (File.Exists(currentSaveFilePath)) { File.Delete(currentSaveFilePath); } } } } public static class SpawnHelper { [CompilerGenerated] private sealed class <SpawnEnemyAfterTime>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnemySetup enemySetup; public Vector3 position; public TimeSpan timeSpan; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpawnEnemyAfterTime>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004e: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds((float)timeSpan.TotalSeconds); <>1__state = 1; return true; case 1: <>1__state = -1; Enemies.SpawnEnemy(enemySetup, position, Quaternion.identity, false); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static List<ValuableObject> SpawnedBags { get; } = new List<ValuableObject>(); public static void SpawnTaxBagInCart(PhysGrabCart cart, int dollars) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)cart).transform.position; Vector3 spawnPosition = default(Vector3); ((Vector3)(ref spawnPosition))..ctor(position.x, position.y + 0.1f, position.z); SpawnTaxBag(spawnPosition, dollars); } public static void SpawnTaxBag(Vector3 spawnPosition, int dollars) { //IL_0031: 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) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) GameObject surplusValuableSmall = AssetManager.instance.surplusValuableSmall; GameObject val = (SemiFunc.IsMultiplayer() ? PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)surplusValuableSmall).name, spawnPosition, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(surplusValuableSmall, spawnPosition, Quaternion.identity)); ValuableObject component = val.GetComponent<ValuableObject>(); PhysGrabObject component2 = val.GetComponent<PhysGrabObject>(); Traverse.Create((object)component2).Field("spawnTorque").SetValue((object)(Random.insideUnitSphere * 0.05f)); component.SetDollarValue(dollars); SpawnedBags.Add(component); } public static void SpawnEnemy(string name, Vector3 spawnPosition, int count = 1) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (EnemyDirector.instance.TryGetEnemyThatContainsName(name, out EnemySetup enemySetup)) { SpawnEnemy(enemySetup, spawnPosition, count); } } public static void SpawnEnemy(EnemySetup setup, Vector3 spawnPosition, int count = 1) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) LevelPoint val = null; float num = 500f; foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints) { if ((double)Vector3.Distance(((Component)levelPathPoint).transform.position, spawnPosition) < (double)num) { val = levelPathPoint; num = Vector3.Distance(((Component)levelPathPoint).transform.position, spawnPosition); } } if (!((Object)(object)val == (Object)null)) { for (int i = 0; i < count; i++) { Enemies.SpawnEnemy(setup, ((Component)val).transform.position, Quaternion.identity, false); } } } [IteratorStateMachine(typeof(<SpawnEnemyAfterTime>d__7))] private static IEnumerator SpawnEnemyAfterTime(EnemySetup enemySetup, Vector3 position, TimeSpan timeSpan) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpawnEnemyAfterTime>d__7(0) { enemySetup = enemySetup, position = position, timeSpan = timeSpan }; } } public class TruckController { public static List<ValuableAndPhysic> TruckItems = new List<ValuableAndPhysic>(); private Transform? _truckTransform; private static float objectInTruckCheckTimer = 0.5f; public TruckController() { _truckTransform = FindTruckInterior(); } public void CheckTruckValuables() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_truckTransform == (Object)null) { _truckTransform = FindTruckInterior(); } else { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } TruckItems.Clear(); Collider[] array = Physics.OverlapBox(_truckTransform.position, _truckTransform.localScale / 2f, _truckTransform.rotation); Collider[] array2 = array; foreach (Collider val in array2) { if (((Component)val).gameObject.layer != LayerMask.NameToLayer("PhysGrabObject")) { continue; } PhysGrabObject componentInParent1 = ((Component)val).GetComponentInParent<PhysGrabObject>(); if (Object.op_Implicit((Object)(object)componentInParent1) && TruckItems.All((ValuableAndPhysic x) => (Object)(object)x.Physic != (Object)(object)componentInParent1)) { ValuableObject componentInParent2 = ((Component)val).GetComponentInParent<ValuableObject>(); if (Object.op_Implicit((Object)(object)componentInParent2)) { TruckItems.Add(new ValuableAndPhysic(componentInParent2, componentInParent1)); } } } if (!TruckItems.Any()) { return; } foreach (ValuableAndPhysic truckItem in TruckItems) { float dollarValue = truckItem.Valuable.GetDollarValue(); CartInventory.Instance.SaveManager.Data.TrackDollars += (int)dollarValue; truckItem.Physic.DestroyPhysGrabObject(); } CartInventory.Instance.SaveManager.UpdateSaveId(); CartInventory.Instance.SaveManager.Save(); } } public static Transform? FindTruckInterior() { RoomVolume[] array = Object.FindObjectsOfType<RoomVolume>(); foreach (RoomVolume val in array) { if (val.Truck) { return ((Component)val).transform; } } GameObject[] array2 = (from go in Object.FindObjectsOfType<GameObject>() where ((Object)go).name.Contains("Truck") && (((Object)go).name.Contains("Interior") || ((Object)go).name.Contains("Inside") || ((Object)go).name.Contains("Room")) select go).ToArray(); if (array2.Length != 0) { return array2[0].transform; } TruckDoor val2 = Object.FindObjectOfType<TruckDoor>(); return ((Object)(object)val2 != (Object)null) ? ((Component)val2).transform : null; } } } namespace CartInventory.Shop { public class ShopSystem { public static Dictionary<Item, int> PurchasedItems = new Dictionary<Item, int>(); public static int PurchasePrice; private static readonly Dictionary<Item, int> Items = new Dictionary<Item, int>(); public static void UpdateShopItems() { Items.Clear(); PurchasedItems.Clear(); Dictionary<string, Item>.ValueCollection values = StatsManager.instance.itemDictionary.Values; foreach (Item item in values) { item.maxAmountInShop = 20; item.maxPurchaseAmount = 20; item.maxPurchase = true; int value = CalculateValue(item); Items.Add(item, value); PurchasedItems.Add(item, 0); } } public static bool Buy() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 if (PurchasePrice > SemiFunc.StatGetRunCurrency()) { return false; } List<Item> list = new List<Item>(); foreach (KeyValuePair<Item, int> purchasedItem in PurchasedItems) { if (purchasedItem.Value <= 0) { continue; } for (int i = 0; i < purchasedItem.Value; i++) { StatsManager.instance.ItemPurchase(purchasedItem.Key.itemAssetName); if ((int)purchasedItem.Key.itemType == 3) { StatsManager.instance.AddItemsUpgradesPurchased(purchasedItem.Key.itemAssetName); } if ((int)purchasedItem.Key.itemType == 5) { StatsManager.instance.runStats["chargingStationChargeTotal"] += 17; if (StatsManager.instance.runStats["chargingStationChargeTotal"] > 100) { StatsManager.instance.runStats["chargingStationChargeTotal"] = 100; } else { Traverse val = Traverse.Create((object)ChargingStation.instance).Field("chargeInt"); val.SetValue((object)(val.GetValue<int>() + 1)); } UpdateChargeStation(); } else { list.Add(purchasedItem.Key); } } } SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() - PurchasePrice); return true; } public static void RecalculatePrice() { PurchasePrice = 0; foreach (KeyValuePair<Item, int> purchasedItem in PurchasedItems) { PurchasePrice += Items[purchasedItem.Key] * purchasedItem.Value; } } public static bool AllowBuy() { return PurchasePrice <= SemiFunc.StatGetRunCurrency(); } public static Dictionary<Item, int> GetItems() { return Items; } private static void UpdateChargeStation() { //IL_0129: Unknown result type (might be due to invalid IL or missing references) float num = (float)StatsManager.instance.runStats["chargingStationChargeTotal"] / 100f; int value = Traverse.Create((object)ChargingStation.instance).Field("chargeSegments").GetValue<int>(); int num2 = Mathf.RoundToInt(num * (float)value); Traverse.Create((object)ChargingStation.instance).Field("chargeTotal").SetValue((object)StatsManager.instance.runStats["chargingStationChargeTotal"]); Traverse.Create((object)ChargingStation.instance).Field("chargeFloat").SetValue((object)num); Traverse.Create((object)ChargingStation.instance).Field("chargeSegmentCurrent").SetValue((object)num2); Traverse.Create((object)ChargingStation.instance).Field("chargeScale").SetValue((object)num); Traverse.Create((object)ChargingStation.instance).Field("chargeScaleTarget").SetValue((object)(num2 / value)); Transform value2 = Traverse.Create((object)ChargingStation.instance).Field("chargeBar").GetValue<Transform>(); if ((Object)(object)value2 != (Object)null) { value2.localScale = new Vector3(num, 1f, 1f); } Debug.Log((object)("Charging station charge total: " + StatsManager.instance.runStats["chargingStationChargeTotal"])); } private static void TruckPopulateItems(List<Item> items) { if (SemiFunc.IsNotMasterClient()) { return; } while (items.Count > 0) { bool flag = false; for (int i = 0; i < items.Count; i++) { Item item = items[i]; SpawnItem(item); items.RemoveAt(i); } } } private static void SpawnItem(Item item) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = ((Component)ShopManager.instance.itemRotateHelper).transform.rotation; Vector3 position = ((Component)TruckHealer.instance).transform.position; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(position.x, 1f, position.z); if (SemiFunc.IsMasterClient()) { PhotonNetwork.InstantiateRoomObject("Items/" + ((Object)item.prefab).name, val, rotation, (byte)0, (object[])null); } else if (!SemiFunc.IsMultiplayer()) { Object.Instantiate<GameObject>(item.prefab, val, rotation); } } private static int CalculateValue(Item item) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Invalid comparison between Unknown and I4 float value = Traverse.Create((object)ShopManager.instance).Field("itemValueMultiplier").GetValue<float>(); float num = Random.Range(item.value.valueMin, item.value.valueMax) * value; if ((double)num < 1000.0) { num = 1000f; } float num2 = Mathf.Ceil(num / 1000f); if ((int)item.itemType == 3) { num2 = ShopManager.instance.UpgradeValueGet(num2, item); } else if ((int)item.itemType == 8) { num2 = ShopManager.instance.HealthPackValueGet(num2); } else if ((int)item.itemType == 5) { num2 = ShopManager.instance.CrystalValueGet(num2); } return (int)num2; } } public class ShopUI { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action <>9__9_1; public static BuilderDelegate <>9__9_0; public static Action <>9__10_1; public static BuilderDelegate <>9__10_0; internal void <Initialize>b__9_0(Transform parent) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Internet shop", (Action)delegate { ShowPopup(); }, parent, new Vector2(350f, 20f)); } internal void <Initialize>b__9_1() { ShowPopup(); } internal void <ShowPopup>b__10_0(Transform p) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) _label = MenuAPI.CreateREPOLabel($"TOTAL: 0/{SemiFunc.StatGetRunCurrency()}", p, new Vector2(30f, 20f)); _buyButton = MenuAPI.CreateREPOButton(_buyText, (Action)delegate { if (!ShopSystem.Buy()) { ((TMP_Text)_buyButton.labelTMP).text = _buyErrorText; ((MonoBehaviour)_buyButton).StartCoroutine(ButtonError(0.5f)); } else { _popup.ClosePage(false); } }, p, new Vector2(370f, 20f)); } internal void <ShowPopup>b__10_1() { if (!ShopSystem.Buy()) { ((TMP_Text)_buyButton.labelTMP).text = _buyErrorText; ((MonoBehaviour)_buyButton).StartCoroutine(ButtonError(0.5f)); } else { _popup.ClosePage(false); } } } [CompilerGenerated] private sealed class <ButtonError>d__11 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float time; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ButtonError>d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(time); <>1__state = 1; return true; case 1: <>1__state = -1; ((TMP_Text)_buyButton.labelTMP).text = _buyText; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly List<(REPOSlider, Item, int)> Sliders = new List<(REPOSlider, Item, int)>(); private static REPOPopupPage? _popup; private static REPOLabel _label; private static REPOButton _buyButton; private static string _selectedType = "All"; private static Dictionary<string, REPOButton> _buttons = new Dictionary<string, REPOButton>(); private static string _buyText = "<color=#CCCCCC><b>Buy</b></color>"; private static string _buyAllowText = "<color=#63ff95><b>Buy</b></color>"; private static string _buyErrorText = "<color=#c41b27><b>Error</b></color>"; public static void Initialize() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown object obj = <>c.<>9__9_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Internet shop", (Action)delegate { ShowPopup(); }, parent, new Vector2(350f, 20f)); }; <>c.<>9__9_0 = val; obj = (object)val; } MenuAPI.AddElementToEscapeMenu((BuilderDelegate)obj); } public static void ShowPopup() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (!SemiFunc.IsMasterClientOrSingleplayer() || !ModConfig.EnableInternetShop.Value || ((Object)(object)_popup != (Object)null && ((Behaviour)_popup.menuPage).enabled)) { return; } _popup = MenuAPI.CreateREPOPopupPage("Shop", (PresetSide)0, false, true, 1.5f); REPOPopupPage? popup = _popup; object obj = <>c.<>9__10_0; if (obj == null) { BuilderDelegate val = delegate(Transform p) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) _label = MenuAPI.CreateREPOLabel($"TOTAL: 0/{SemiFunc.StatGetRunCurrency()}", p, new Vector2(30f, 20f)); _buyButton = MenuAPI.CreateREPOButton(_buyText, (Action)delegate { if (!ShopSystem.Buy()) { ((TMP_Text)_buyButton.labelTMP).text = _buyErrorText; ((MonoBehaviour)_buyButton).StartCoroutine(ButtonError(0.5f)); } else { _popup.ClosePage(false); } }, p, new Vector2(370f, 20f)); }; <>c.<>9__10_0 = val; obj = (object)val; } popup.AddElement((BuilderDelegate)obj); AddItems(); CreateOutfitButtons(); _popup.OpenPage(false); } [IteratorStateMachine(typeof(<ButtonError>d__11))] private static IEnumerator ButtonError(float time) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ButtonError>d__11(0) { time = time }; } private static void AddItems() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown Sliders.Clear(); ShopSystem.UpdateShopItems(); foreach (KeyValuePair<Item, int> item in ShopSystem.GetItems()) { _popup.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) REPOSlider val = MenuAPI.CreateREPOSlider(Regex.Replace(((Object)item.Key).name, "^Item\\s(Upgrade)?(\\sPlayer)?", "") + $"({item.Value}$)", "", (Action<int>)delegate(int i) { ShopSystem.PurchasedItems[item.Key] = i; OnChangeItems(); }, scrollView, Vector2.zero, 0, item.Key.maxAmountInShop, 0, "", "", (BarBehavior)0); Sliders.Add((val, item.Key, item.Value)); return ((REPOElement)val).rectTransform; }, 0f, 0f); } } private static void OnChangeItems() { ShopSystem.RecalculatePrice(); ((TMP_Text)_label.labelTMP).text = $"TOTAL: {ShopSystem.PurchasePrice}/{SemiFunc.StatGetRunCurrency()}"; if (ShopSystem.AllowBuy()) { ((TMP_Text)_buyButton.labelTMP).text = _buyAllowText; } else { ((TMP_Text)_buyButton.labelTMP).text = _buyText; } } private static void CreateOutfitButtons() { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown _buttons.Clear(); List<string> list = new List<string> { "All", "Drone", "Cart", "Upgrade", "Tools", "Crystal", "Grenade", "Melee", "HealthPack", "Gun", "Mine" }; int num = 0; foreach (string type in list) { string buttonText = "<size=14><color=#CCCCCC>" + type + "</color></size>"; int yPosition = 300 - (num - 1) * 14; REPOPopupPage? popup = _popup; if (popup != null) { popup.AddElement((BuilderDelegate)delegate(Transform parent) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) _buttons[type] = MenuAPI.CreateREPOButton(buttonText, (Action)delegate { OnChangeType(type); }, parent, new Vector2(370f, (float)yPosition)); }); } num++; } OnChangeType(_selectedType); } private static void OnChangeType(string type) { _selectedType = type; foreach (KeyValuePair<string, REPOButton> button in _buttons) { ((TMP_Text)button.Value.labelTMP).text = "<size=14><color=#CCCCCC>" + button.Key + "</color></size>"; } ((TMP_Text)_buttons[type].labelTMP).text = "<size=14><color=#63ff95><b>" + type + "</b></color></size>"; switch (type) { case "All": ShowTypeSliders(); break; case "Drone": ShowTypeSliders(default(itemType)); break; case "Cart": ShowTypeSliders((itemType)2, (itemType)12); break; case "Upgrade": ShowTypeSliders((itemType)3, (itemType)4); break; case "Tools": { itemType[] array = new itemType[3]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); ShowTypeSliders((itemType[])(object)array); break; } case "Crystal": ShowTypeSliders((itemType)5); break; case "Grenade": ShowTypeSliders((itemType)6); break; case "Melee": ShowTypeSliders((itemType)7); break; case "HealthPack": ShowTypeSliders((itemType)8); break; case "Gun": ShowTypeSliders((itemType)9); break; case "Mine": ShowTypeSliders((itemType)11); break; } } private static void ShowTypeSliders(params itemType[] types) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) bool flag = types.Length == 0; foreach (var slider in Sliders) { if (flag || types.Contains(slider.Item2.itemType)) { ((REPOElement)slider.Item1).repoScrollViewElement.visibility = true; } else { ((REPOElement)slider.Item1).repoScrollViewElement.visibility = false; } } } } } namespace CartInventory.Patches { [HarmonyPatch(typeof(ChatManager))] internal class ChatManagerPatch { public static ChatState ChatState; [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePatch(ref ChatState ___chatState) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) ChatState = ___chatState; } } [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 (!ModConfig.EnableEnemyScaling.Value || LevelStats.CurrentLevel < ModConfig.EnemyScalingSkipLevels.Value + 1) { return true; } float num = SemiFunc.RunGetDifficultyMultiplier1(); float num2 = SemiFunc.RunGetDifficultyMultiplier2(); float num3 = SemiFunc.RunGetDifficultyMultiplier3(); if ((double)num2 > 0.0) { ___amountCurve3Value = Mathf.CeilToInt(__instance.amountCurve3_2.Evaluate(num2) * ModConfig.EnemyTier3Multiplier.Value) + 2; ___amountCurve2Value = Mathf.CeilToInt(__instance.amountCurve2_2.Evaluate(num2) * ModConfig.EnemyTier2Multiplier.Value) + 2; ___amountCurve1Value = Mathf.CeilToInt(__instance.amountCurve1_2.Evaluate(num2) * ModConfig.EnemyTier1Multiplier.Value) + 2; } else { ___amountCurve3Value = Mathf.CeilToInt(__instance.amountCurve3_1.Evaluate(num) * ModConfig.EnemyTier3Multiplier.Value) + 1; ___amountCurve2Value = Mathf.CeilToInt(__instance.amountCurve2_1.Evaluate(num) * ModConfig.EnemyTier2Multiplier.Value) + 1; ___amountCurve1Value = Mathf.CeilToInt(__instance.amountCurve1_1.Evaluate(num) * ModConfig.EnemyTier1Multiplier.Value) + 1; } if (ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.MoneyTime)) { ___amountCurve3Value += 2; ___amountCurve2Value += 4; ___amountCurve1Value += 8; } 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 ((double)num3 > 0.0) { ___despawnedTimeMultiplier = __instance.despawnTimeCurve_2.Evaluate(num3); } else if ((double)num2 > 0.0) { ___despawnedTimeMultiplier = __instance.despawnTimeCurve_1.Evaluate(num2); } ___totalAmount = ___amountCurve1Value + ___amountCurve2Value + ___amountCurve3Value; return false; } [HarmonyPatch("PickEnemies")] [HarmonyPrefix] private static bool PickEnemies(EnemyDirector __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.DuckRaid)) { EnemySetup enemyThatContainsName = __instance.GetEnemyThatContainsName("Duck"); __instance.GetEnemyListCurrent().Add(enemyThatContainsName); __instance.GetEnemyList().Add(enemyThatContainsName); return false; } return true; } } [HarmonyPatch(typeof(EnemyHealth))] public class EnemyHealthPatch { [HarmonyPatch("Update")] [HarmonyPrefix] private static void Update(EnemyHealth __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && ModConfig.EnableImmortalEnemy.Value) { EnemyParent componentInParent = ((Component)__instance).GetComponentInParent<EnemyParent>(); if ((Object)(object)componentInParent != (Object)null && LevelStats.ImmortalEnemies.Contains(componentInParent)) { Traverse.Create((object)__instance).Field("deadImpulse").SetValue((object)false); } } } } [HarmonyPatch(typeof(EnemyParent))] public class EnemyParentPatch { private static List<string> ImmortalEnemies = new List<string> { "Head", "Robe", "Hunter", "Beamer" }; [HarmonyPatch("Awake")] [HarmonyPrefix] private static void Awake(EnemyParent __instance) { LevelStats.EnemyTotal++; } [HarmonyPatch("SpawnRPC")] [HarmonyPostfix] private static void SpawnRPC(EnemyParent __instance) { EnemyParent __instance2 = __instance; LevelStats.EnemyTotal++; if (SemiFunc.IsMasterClientOrSingleplayer() && ModConfig.EnableImmortalEnemy.Value && ImmortalEnemies.Any((string name) => ((Object)((Component)__instance2).gameObject).name.Contains(name)) && Helpers.Chance(ModConfig.ImmortalEnemyChance.Value)) { LevelStats.ImmortalEnemies.Add(__instance2); } } [HarmonyPatch("DespawnRPC")] [HarmonyPostfix] private static void DespawnRPC(EnemyParent __instance) { LevelStats.EnemyTotal--; if (SemiFunc.IsMasterClientOrSingleplayer() && LevelStats.ImmortalEnemies.Contains(__instance)) { LevelStats.ImmortalEnemies.Remove(__instance); } } } [HarmonyPatch(typeof(EnemyValuable))] public class EnemyValuablePatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void Start(EnemyValuable __instance) { LevelStats.EnemyKills++; ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>(); if ((Object)(object)component != (Object)null) { LevelStats.Orbs.Add(component); } } } [HarmonyPatch(typeof(ExtractionPoint))] public class ExtractionPointPatch { [HarmonyPatch("ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruck")] [HarmonyPostfix] private static void ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruck() { LevelStats.FirstExtractionPointOpened = true; } } [HarmonyPatch(typeof(LevelGenerator))] internal class LevelGeneratorPatch { private static int GetNewModuleCount() { if (!SemiFunc.RunIsLevel() || !ModConfig.EnableModuleScaling.Value) { return LevelStats.CurrentModCount; } return new LevelLerpBuilder().AddScalar(2f, 4 + LevelStats.CurrentLevel).Add(6f, 8f).Add(10f, 12f) .Add(20f, 16f) .Add(50f, 20f) .Add(100f, 25f) .GetIntValue(30f, 6f); } public static int GetNewExtractionCount() { if (!SemiFunc.RunIsLevel()) { return 0; } if (!ModConfig.EnableExtractionScaling.Value) { return LevelStats.CurrentExtractionCount; } int currentLevel = LevelStats.CurrentLevel; if (1 == 0) { } int result = ((currentLevel <= 20) ? ((currentLevel <= 10) ? ((currentLevel <= 3) ? ((currentLevel > 2) ? 1 : 0) : ((currentLevel > 5) ? 3 : 2)) : ((currentLevel > 15) ? 5 : 4)) : ((currentLevel <= 50) ? ((currentLevel > 30) ? 7 : 6) : ((currentLevel > 100) ? 9 : 8))); if (1 == 0) { } return result; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TileGenerationTranspiler(IEnumerable<CodeInstruction> inst) { //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(inst); if (list.Count <= 20) { return list; } int num = -1; 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) { return list; } 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) { return list; } List<CodeInstruction> list2 = new List<CodeInstruction>(); list2.Add(new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelGeneratorPatch), "GetNewModuleCount", (Type[])null, (Type[])null))); list2.Add(new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(LevelGenerator), "ModuleAmount"))); List<CodeInstruction> collection = list2; list2 = new List<CodeInstruction>(); list2.Add(new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelGeneratorPatch), "GetNewExtractionCount", (Type[])null, (Type[])null))); list2.Add(new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(LevelGenerator), "ExtractionAmount"))); List<CodeInstruction> collection2 = list2; list.InsertRange(num2, collection2); list.InsertRange(num, collection); return list; } [HarmonyPatch("GenerateDone")] [HarmonyPostfix] private static void GenerateDonePostfix(ref int ___ModuleAmount, ref int ___ExtractionAmount) { LevelStats.Carts = (from cart in Object.FindObjectsOfType<PhysGrabCart>() where (Object)(object)cart != (Object)null select cart).ToList(); CartInventory.Instance.SaveManager.UpdateSaveId(); CartInventory.Instance.SaveManager.Load(); } } [HarmonyPatch(typeof(MapModule))] internal class MapModulePatch { [HarmonyPatch("Hide")] [HarmonyPrefix] private static void HideP(ref bool ___animating) { if (!___animating) { LevelStats.AddModuleExplored(); } } } [HarmonyPatch(typeof(Map))] internal class MapPatch { [HarmonyPatch("AddRoomVolume")] [HarmonyPostfix] private static void AddRoomVolumeP(ref Map __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { LevelStats.TotalModules = __instance.MapModules.Count; } } } [HarmonyPatch(typeof(MapToolController))] public class MapToolControllerPatch { public static bool MapIsOpen; [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdateP2(ref bool ___Active, ref PhotonView ___photonView) { if (!GameManager.Multiplayer() || ___photonView.IsMine) { MapIsOpen = ___Active; } } } [HarmonyPatch(typeof(PhysGrabCart))] internal class PhysGrabCartPatch { private static float objectInCartCheckTimer = 0.5f; [HarmonyPatch("Update")] [HarmonyPostfix] private static void Update(PhysGrabCart __instance, Transform ___inCart) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if ((double)objectInCartCheckTimer > 0.0) { objectInCartCheckTimer -= Time.deltaTime; return; } List<PhysGrabObject> list = new List<PhysGrabObject>(); Collider[] array = Physics.OverlapBox(___inCart.position, ___inCart.localScale * ModConfig.CartVacuumCleanerScale.Value, ___inCart.rotation); Collider[] array2 = array; foreach (Collider val in array2) { if (((Component)val).gameObject.layer == LayerMask.NameToLayer("PhysGrabObject")) { PhysGrabObject componentInParent = ((Component)val).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent != (Object)null && !list.Contains(componentInParent)) { list.Add(componentInParent); } } } ObjectsInCart(__instance, list); } private static void ObjectsInCart(PhysGrabCart cart, List<PhysGrabObject> cartItems) { if (!CartInventory.Instance.IsLoaded) { return; } List<ValuableAndPhysic> list = (from x in cartItems where (Object)(object)x != (Object)null && (Object)(object)((Component)x).GetComponent<ValuableObject>() != (Object)null select x into v select new ValuableAndPhysic(((Component)v).GetComponent<ValuableObject>(), v)).ToList(); if (list.Count == 0) { return; } List<ValuableAndPhysic> source = list.Where((ValuableAndPhysic v) => SpawnHelper.SpawnedBags.Contains(v.Valuable)).ToList(); LevelStats.CartValuables[cart] = list.Select((ValuableAndPhysic vp) => vp.Valuable).ToList(); float num = 0f; if (!ModConfig.EnableValuableConvert.Value || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } foreach (ValuableAndPhysic item in list) { float dollarValue = item.Valuable.GetDollarValue(); if (!SpawnHelper.SpawnedBags.Contains(item.Valuable)) { num += dollarValue; cartItems.Remove(item.Physic); item.Physic.DestroyPhysGrabObject(); } } if (!source.Any()) { SpawnHelper.SpawnTaxBagInCart(cart, (int)num); } else if (source.Count() > 1) { foreach (ValuableAndPhysic item2 in source.Skip(1)) { float dollarValue2 = item2.Valuable.GetDollarValue(); num += dollarValue2; cartItems.Remove(item2.Physic); SpawnHelper.SpawnedBags.Remove(item2.Valuable); item2.Physic.DestroyPhysGrabObject(); } } if (num > 0f && source.Any()) { ValuableAndPhysic valuableAndPhysic = source.First(); float dollarValue3 = valuableAndPhysic.Valuable.GetDollarValue(); float value = num + dollarValue3; valuableAndPhysic.Valuable.SetDollarValue(value); } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector))] public class PhysGrabObjectImpactDetectorPatches { [HarmonyPatch("BreakRPC")] [HarmonyPostfix] private static void StartPostFix(float valueLost, PhysGrabObjectImpactDetector? __instance, bool _loseValue) { if (!_loseValue) { return; } LevelStats.TotalLost += valueLost; LevelStats.UpdateLevelDollars(); ValuableObject val = ((__instance != null) ? ((Component)__instance).GetComponent<ValuableObject>() : null); if (ModConfig.CarefulMode.Value && (Object)(object)val != (Object)null && (!LevelStats.Orbs.Contains(val) || ModConfig.CarefulOrbDamage.Value)) { LevelStats.TotalValuablesDamage += valueLost; if (SemiFunc.IsMasterClientOrSingleplayer()) { CarefulHelper.RollSpawn(val); } } } [HarmonyPatch(typeof(PhysGrabObject), "DestroyPhysGrabObjectRPC")] [HarmonyPostfix] public static void DestroyPhysGrabObjectPostfix(PhysGrabObject __instance) { if (SemiFunc.RunIsLevel()) { ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>(); if ((Object)(object)component != (Object)null) { LevelStats.RemoveValuableObject(component); CarefulHelper.OnDestroy(component); } } } } [HarmonyPatch(typeof(PlayerController))] public class PlayerControllerPatch { public static GameObject? GrabbedObject = null; public static bool IsGrab = false; private static float LastSplit; private static readonly List<string> mouseBtns = new List<string> { "leftButton", "rightButton", "middleButton", "forwardButton", "backButton" }; [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePatch(PlayerController __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)ChatManagerPatch.ChatState != 1) { if (IsButtonPressed(ModConfig.TruckExtractionKey.Value)) { ExtractDollars(); } if (IsButtonPressed(ModConfig.BagSplitKey.Value)) { SplitBags(); } if (IsButtonPressed(ModConfig.InternetShopKey.Value)) { ShopUI.ShowPopup(); } } } [HarmonyPatch("FixedUpdate")] [HarmonyPostfix] private static void PlayerGrabItemPatch(PlayerController __instance) { if (!SemiFunc.RunIsShop() && !((Object)(object)__instance == (Object)null)) { if (__instance.physGrabActive && (Object)(object)__instance.physGrabObject != (Object)null) { GrabbedObject = __instance.physGrabObject; IsGrab = true; } else { IsGrab = false; } } } private static void ExtractDollars() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (CartInventory.Instance.SaveManager.Data.TrackDollars == 0) { return; } CartInventory.Instance.SaveManager.UpdateSaveId(); CartInventory.Instance.SaveManager.Load(); int num = 100000; PhysGrabCart val = null; foreach (PhysGrabCart cart in LevelStats.Carts) { if ((Object)(object)cart != (Object)null) { int num2 = Mathf.RoundToInt(Vector3.Distance(((Component)PlayerController.instance).transform.position, ((Component)cart).transform.position)); if (num2 < num) { num = num2; val = cart; } } } if ((Object)(object)val != (Object)null) { SpawnHelper.SpawnTaxBagInCart(val, CartInventory.Instance.SaveManager.Data.TrackDollars); CartInventory.Instance.SaveManager.Data.TrackDollars = 0; CartInventory.Instance.SaveManager.Save(); } } private static void SplitBags() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (LevelStats.Time - LastSplit < 3f || !IsGrab) { return; } ValuableObject component = GrabbedObject.GetComponent<ValuableObject>(); if ((Object)(object)component != (Object)null && SpawnHelper.SpawnedBags.Contains(component)) { float dollarValue = component.GetDollarValue(); if (!(dollarValue < 50f)) { float num = dollarValue / 2f; Vector3 spawnPosition = default(Vector3); ((Vector3)(ref spawnPosition))..ctor(((Component)component).transform.position.x, ((Component)component).transform.position.y + 1f, ((Component)component).transform.position.z); SpawnHelper.SpawnTaxBag(spawnPosition, (int)num); component.SetDollarValue(num); LastSplit = LevelStats.Time; } } } private static bool IsButtonPressed(string btn) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return ((!mouseBtns.Contains(btn)) ? ((ButtonControl)((InputControl)Keyboard.current)[btn]) : ((ButtonControl)((InputControl)Mouse.current)[btn])).isPressed; } } [HarmonyPatch(typeof(RunManager))] internal class RunManagerPatch { private static bool _goingToManiMenu; private static Level _nextLevel; [HarmonyPatch("ChangeLevel")] [HarmonyPrefix] private static void ChangeLevelPrefix(RunManager __instance, ChangeLevelType _changeLevelType) { if (CartInventory.Instance.IsLoaded) { SpawnHelper.SpawnedBags.Clear(); LevelStats.Clear(); } } [HarmonyPatch("ChangeLevel")] [HarmonyPostfix] private static void ChangeLevelPostfix(RunManager __instance, bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (ModConfig.SkipShopLevel.Value) { bool flag = false; if ((Object)(object)__instance.levelCurrent == (Object)(object)__instance.levelShop) { __instance.levelCurrent = __instance.levelLobby; _nextLevel = __instance.levelLobby; flag = true; } if ((Object)(object)_nextLevel != (Object)null) { Level nextLevel = _nextLevel; Level levelCurrent = __instance.levelCurrent; __instance.levelCurrent = nextLevel; _nextLevel = levelCurrent; flag = true; } if (SemiFunc.RunIsLevel()) { _nextLevel = null; } if (flag && GameManager.Multiplayer()) { RunManagerPUN value = Traverse.Create((object)__instance).Field("runManagerPUN").GetValue<RunManagerPUN>(); PhotonView value2 = Traverse.Create((object)value).Field("photonView").GetValue<PhotonView>(); value2.RPC("UpdateLevelRPC", (RpcTarget)4, new object[3] { ((Object)__instance.levelCurrent).name, __instance.levelsCompleted, Traverse.Create((object)__instance).Field("gameOver").GetValue<bool>() }); } } CartInventory.Instance.SaveManager.UpdateSaveId(); if (SemiFunc.RunIsLevel() && LevelStats.CurrentLevel > 1) { ChallengeManager.RollChallenge(); } } [HarmonyPatch("UpdateLevel")] [HarmonyPostfix] private static void UpdateLevelPostfix(RunManager __instance, string _levelName, int _levelsCompleted, bool _gameOver) { CartInventory.Instance.SaveManager.UpdateSaveId(); } [HarmonyPatch("ResetProgress")] [HarmonyPostfix] private static void ResetProgressPostfix(RunManager __instance) { if (SemiFunc.IsMasterClientOrSingleplayer()) { CartInventory.Instance.SaveManager.UpdateSaveId(); } } } [HarmonyPatch(typeof(StatsManager), "SaveFileDelete")] public class SaveFileDeletionPatch { [HarmonyPrefix] private static bool Prefix(string saveFileName) { CartInventory.Instance.SaveManager.Delete(); return true; } } [HarmonyPatch(typeof(StatsManager))] public class StatsManagerPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdateP() { LevelStats.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_0002: Unknown result type (might be due to invalid IL or missing references) LevelStats.TruckScreenState = (PlayerChatBoxState)0; } [HarmonyPatch("PlayerChatBoxStateUpdateRPC")] [HarmonyPostfix] private static void TruckScreenText_PlayerChatBoxStateUpdateRPC(ref PlayerChatBoxState _state) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) LevelStats.TruckScreenState = _state; } } [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>(); public static float NewValueCount() { if (!ModConfig.EnableValuableScaling.Value) { return TotalMaxValue; } return new LevelLerpBuilder().Add(7f, 180f).Add(11f, 250f).Add(50f, 700f) .Add(100f, 1500f) .Add(1000f, 5000f) .Add(2000f, 10000f) .GetValue(10000f, 30f); } private static int MultiplyItemCount(int inAmount) { if (!ModConfig.EnableValuableScaling.Value) { return inAmount; } float value = new LevelLerpBuilder().AddScalar(2f, 1f).Add(4f, 1.4f).Add(6f, 1.8f) .Add(10f, 2f) .Add(15f, 2.4f) .Add(20f, 2.7f) .Add(30f, 3f) .Add(50f, 3.6f) .Add(75f, 4f) .Add(100f, 4.7f) .GetValue(5f); return Mathf.RoundToInt((float)inAmount * value); } private static int NewTotalItemCount() { return MultiplyItemCount(TotalMaxAmount); } private static int NewTinyItemCount() { if (ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.BigItems)) { return 0; } return MultiplyItemCount(TinyMaxAmount); } private static int NewSmallItemCount() { if (ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.BigItems)) { return 0; } return MultiplyItemCount(SmallMaxAmount); } private static int NewMediumItemCount() { if (ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.BigItems)) { return 0; } return MultiplyItemCount(MediumMaxAmount); } private static int NewBigItemCount() { return MultiplyItemCount(BigMaxAmount); } private static int NewWideItemCount() { if (ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.BigItems)) { return 0; } return MultiplyItemCount(WideMaxAmount); } private static int NewTallItemCount() { if (ChallengeManager.CurrentChallengeIs(global::CartInventory.Challenges.Challenges.BigItems)) { return 0; } 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) { List<CodeInstruction> list = new List<CodeInstruction>(inst); if (list.Count <= 20) { 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) { return list; } List<CodeInstruction> list2 = new List<CodeInstruction>(); list2.SetField(typeof(ValuableDirectorPatch), "NewValueCount", typeof(ValuableDirector), "totalMaxValue").SetField(typeof(ValuableDirectorPatch), "NewTotalItemCount", typeof(ValuableDirector), "totalMaxAmount").SetField(typeof(ValuableDirectorPatch), "NewSmallItemCount", typeof(ValuableDirector), "smallMaxAmount") .SetField(typeof(ValuableDirectorPatch), "NewMediumItemCount", typeof(ValuableDirector), "mediumMaxAmount") .SetField(typeof(ValuableDirectorPatch), "NewBigItemCount", typeof(ValuableDirector), "bigMaxAmount") .SetField(typeof(ValuableDirectorPatch), "NewWideItemCount", typeof(ValuableDirector), "wideMaxAmount") .SetField(typeof(ValuableDirectorPatch), "NewVeryTallItemCount", typeof(ValuableDirector), "tallMaxAmount") .SetField(typeof(ValuableDirectorPatch), "NewTallItemCount", typeof(ValuableDirector), "tallMaxAmount") .SetField(typeof(ValuableDirectorPatch), "NewTinyItemCount", typeof(ValuableDirector), "tinyMaxAmount"); list.InsertRange(num, list2); return list; } } [HarmonyPatch(typeof(ValuableObject))] public static class ValuableObjectPatch { private static float Time; [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start() { } [HarmonyPatch("DollarValueSetLogic")] [HarmonyPostfix] [HarmonyPriority(1000)] private static void DollarValueSetLogic(ref ValuableObject __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && ModConfig.EnableValuableScaling.Value && !SpawnHelper.SpawnedBags.Contains(__instance) && !LevelStats.ValuableObjects.Contains(__instance)) { Traverse dollarTraverse = __instance.GetDollarTraverse(); float value = dollarTraverse.GetValue<float>(); if ((double)value <= 1000.0) { dollarTraverse.SetValue((object)(float)((double)value * 1.7)); } else if ((double)value <= 5000.0) { dollarTraverse.SetValue((object)(float)((double)value * 1.5)); } else if ((double)value <= 10000.0) { dollarTraverse.SetValue((object)(float)((double)value * 1.3)); } else { dollarTraverse.SetValue((object)(float)((double)value * 1.1)); } } LevelStats.RegisterValuableObject(__instance); } [HarmonyPatch("DollarValueSetRPC")] [HarmonyPostfix] private static void DollarValueSetRPC(ValuableObject __instance) { LevelStats.RegisterValuableObject(__instance); } } } namespace CartInventory.Extensions { public static class EnemyDirectorExtensions { public static List<EnemySetup> GetEnemies(this EnemyDirector enemyDirector) { List<EnemySetup> enemiesDifficulty = enemyDirector.enemiesDifficulty1; List<EnemySetup> enemiesDifficulty2 = enemyDirector.enemiesDifficulty2; List<EnemySetup> enemiesDifficulty3 = enemyDirector.enemiesDifficulty3; List<EnemySetup> list = new List<EnemySetup>(enemiesDifficulty.Count + enemiesDifficulty2.Count + enemiesDifficulty3.Count); list.AddRange(enemiesDifficulty); list.AddRange(enemiesDifficulty2); list.AddRange(enemiesDifficulty3); return list; } public static bool TryGetEnemyByName(this EnemyDirector enemyDirector, string name, [NotNullWhen(true)] out EnemySetup? enemySetup) { enemySetup = enemyDirector.GetEnemyByName(name); return (Object)(object)enemySetup != (Object)null; } public static EnemySetup? GetEnemyByName(this EnemyDirector enemyDirector, string name) { string name2 = name; return ((IEnumerable<EnemySetup>)enemyDirector.GetEnemies()).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup x) => ((Object)x).name.Equals(name2))); } public static bool TryGetEnemyThatContainsName(this EnemyDirector enemyDirector, string name, out EnemySetup? enemySetup) { enemySetup = enemyDirector.GetEnemyThatContainsName(name); return (Object)(object)enemySetup != (Object)null; } public static EnemySetup? GetEnemyThatContainsName(this EnemyDirector enemyDirector, string name) { string name2 = name; return ((IEnumerable<EnemySetup>)enemyDirector.GetEnemies()).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup x) => ((Object)x).name.Contains(name2))); } public static List<EnemySetup> GetEnemyList(this EnemyDirector director) { return Traverse.Create((object)director).Field("enemyList").GetValue<List<EnemySetup>>(); } public static List<EnemySetup> GetEnemyListCurrent(this EnemyDirector director) { return Traverse.Create((object)director).Field("enemyListCurrent").GetValue<List<EnemySetup>>(); } } public static class ListExtension { public static List<CodeInstruction> SetField(this List<CodeInstruction> list, Type type, string method, Type setType, string fieldName) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown list.Add(new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(type, method, (Type[])null, (Type[])null))); list.Add(new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(setType, fieldName))); return list; } } public static class StringExtension { public static string FormatDollars(this int nuber) { return (nuber > 0) ? nuber.ToString("#,#$").Replace(",", " ") : "0$"; } public static string FormatDollars(this float nuber) { return (nuber > 0f) ? nuber.ToString("#,#$").Replace(",", " ") : "0$"; } public static string GetTimeString(this float seconds) { seconds = Mathf.Clamp(seconds, 0f, 360000f); int num = (int)((double)seconds * 1000.0) % 1000; int num2 = (int)seconds % 60; int num3 = (int)((double)seconds / 60.0) % 60; return $"{(int)((double)seconds / 3600.0):00}:{num3:00}:{num2:00}<size=75%>.{num:000}</size>"; } } public static class ValuableObjectExtension { public static void SetDollarValue(this ValuableObject valuable, float value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) valuable.DollarValueSetRPC(value, default(PhotonMessageInfo)); if (SemiFunc.IsMasterClient()) { Traverse.Create((object)valuable).Field("photonView").GetValue<PhotonView>() .RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { value }); } } public static float GetDollarValue(this ValuableObject valuable) { return Traverse.Create((object)valuable).Field("dollarValueCurrent").GetValue<float>(); } public static Traverse GetDollarTraverse(this ValuableObject valuable) { return Traverse.Create((object)valuable).Field("dollarValueCurrent"); } } } namespace CartInventory.DTO { public class SaveData { public int TrackDollars { get; set; } = 0; } public class ValuableAndPhysic { public ValuableObject Valuable { get; } public PhysGrabObject Physic { get; } public ValuableAndPhysic(ValuableObject valuable, PhysGrabObject physic) { Valuable = valuable; Physic = physic; base..ctor(); } } } namespace CartInventory.Challenges { public class ChallengeManager { public static Challenges CurrentChallenge; public static bool CurrentChallengeIs(Challenges challenge) { return CurrentChallenge == challenge; } public static string CurrentChallengeName() { return CurrentChallenge.ToString(); } public static void RollChallenge() { Challenges[] array = Enum.GetValues(typeof(Challenges)).Cast<Challenges>().ToArray(); CurrentChallenge = array[Random.Range(0, array.Length)]; } } public enum Challenges { None, FastExtraction, MoneyTime, BigItems, DuckRaid } }