using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using KeybindLib.Classes; using MoreUpgrades.Classes; using MoreUpgrades.Compatibility; using MoreUpgrades.Patches; using MoreUpgrades.Properties; using Photon.Pun; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("MoreUpgrades")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MoreUpgrades")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5e12a72d-c200-488d-940a-653d1003d96e")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace MoreUpgrades { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("bulletbot.moreupgrades", "MoreUpgrades", "1.7.3")] internal class Plugin : BaseUnityPlugin { private const string modGUID = "bulletbot.moreupgrades"; private const string modName = "MoreUpgrades"; private const string modVer = "1.7.3"; internal static Plugin instance; public ManualLogSource logger; private readonly Harmony harmony = new Harmony("bulletbot.moreupgrades"); public ConfigEntry importUpgrades; public ConfigEntry excludeUpgradeIds; public AssetBundle assetBundle; public List upgradeItems; public bool updateTracker; internal void PatchAll(string name) { (from x in Assembly.GetExecutingAssembly().GetTypes() where x.Namespace == typeof(Plugin).Namespace + "." + name select x).ToList().ForEach(delegate(Type x) { harmony.PatchAll(x); }); } private GameObject GetVisualsFromComponent(Component component) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown GameObject val = null; if (component is EnemyParent) { EnemyParent val2 = (EnemyParent)(object)((component is EnemyParent) ? component : null); Enemy val3 = (Enemy)AccessTools.Field(typeof(EnemyParent), "Enemy").GetValue(component); if (val2.enemyName != "Bella") { try { val = ((Component)((Component)val2).GetComponentInChildren().VisionTransform).gameObject; } catch { } if ((Object)(object)val == (Object)null) { try { val = ((Component)val2.EnableObject.GetComponentInChildren()).gameObject; } catch { } } } else { val = ((Component)((Component)val3).GetComponentInChildren().followTargetTransform).gameObject; } if ((Object)(object)val == (Object)null) { val = ((Component)val3).gameObject; } } else if (component is PlayerAvatar) { PlayerAvatar val4 = (PlayerAvatar)(object)((component is PlayerAvatar) ? component : null); val = ((Component)val4.playerAvatarVisuals).gameObject; } return val; } internal void RegisterToMap(Component component) { if ((Object)(object)Map.Instance == (Object)null) { return; } GameObject visualsFromComponent = GetVisualsFromComponent(component); if ((Object)(object)visualsFromComponent == (Object)null) { return; } string upgradeItemName = null; if (component is EnemyParent) { upgradeItemName = "Map Enemy Tracker"; } else { if (!(component is PlayerAvatar)) { return; } upgradeItemName = "Map Player Tracker"; } UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == upgradeItemName); if (upgradeItem != null) { List variable = upgradeItem.GetVariable>("Map Infos"); if (!variable.Any((MapInfo x) => (Object)(object)x.component == (Object)(object)component)) { GameObject val = Object.Instantiate(Map.Instance.CustomObject, Map.Instance.OverLayerParent); ((Object)val).name = ((Object)visualsFromComponent).name; MapCustomEntity component2 = val.GetComponent(); component2.Parent = visualsFromComponent.transform; variable.Add(new MapInfo { component = component, mapCustomEntity = component2 }); updateTracker = true; } } } internal void ShowToMap(Component component) { UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Enemy Tracker"); UpgradeItem upgradeItem2 = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Player Tracker"); if (upgradeItem == null && upgradeItem2 == null) { return; } List list = upgradeItem?.GetVariable>("Map Infos"); List list2 = upgradeItem2?.GetVariable>("Map Infos"); if (list == null && list2 == null) { return; } MapInfo mapInfo = list?.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component) ?? list2?.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component); if (mapInfo == null) { return; } bool flag = component is EnemyParent; bool flag2 = component is PlayerAvatar; if (!flag && !flag2) { return; } if (flag) { Component obj = component; EnemyParent val = (EnemyParent)(object)((obj is EnemyParent) ? obj : null); if ((from x in upgradeItem.GetConfig("Exclude Enemies").Split(new char[1] { ',' }) select x.Trim() into x where !string.IsNullOrEmpty(x) select x).Contains(val.enemyName)) { return; } } mapInfo.visible = true; updateTracker = true; } internal void HideFromMap(Component component) { UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Enemy Tracker"); UpgradeItem upgradeItem2 = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Player Tracker"); if (upgradeItem == null && upgradeItem2 == null) { return; } List list = upgradeItem?.GetVariable>("Map Infos"); List list2 = upgradeItem2?.GetVariable>("Map Infos"); if (list == null && list2 == null) { return; } MapInfo mapInfo = list?.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component) ?? list2?.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component); if (mapInfo == null) { return; } bool flag = component is EnemyParent; bool flag2 = component is PlayerAvatar; if (!flag && !flag2) { return; } if (flag) { Component obj = component; EnemyParent val = (EnemyParent)(object)((obj is EnemyParent) ? obj : null); if ((from x in upgradeItem.GetConfig("Exclude Enemies").Split(new char[1] { ',' }) select x.Trim() into x where !string.IsNullOrEmpty(x) select x).Contains(val.enemyName)) { return; } } mapInfo.visible = false; updateTracker = true; } internal void SwapOnMap(Component component, Component fromComponent) { UpgradeItem mapEnemyTracker = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Enemy Tracker"); UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Player Tracker"); if (mapEnemyTracker == null || upgradeItem == null) { return; } List variable = mapEnemyTracker.GetVariable>("Map Infos"); List variable2 = upgradeItem.GetVariable>("Map Infos"); if (variable == null || variable2 == null) { return; } MapInfo mapInfo = variable.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component) ?? variable2.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component); MapInfo mapInfo2 = variable.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)fromComponent) ?? variable2.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)fromComponent); if (mapInfo == null || mapInfo2 == null) { return; } bool flag = component is PlayerAvatar || component is EnemyParent; bool flag2 = fromComponent is PlayerAvatar || fromComponent is EnemyParent; if (!flag || !flag2) { return; } if (component is EnemyParent || fromComponent is EnemyParent) { List list = new List(); Component obj = component; EnemyParent val = (EnemyParent)(object)((obj is EnemyParent) ? obj : null); if (val != null) { list.Add(val.enemyName); } Component obj2 = fromComponent; EnemyParent val2 = (EnemyParent)(object)((obj2 is EnemyParent) ? obj2 : null); if (val2 != null) { list.Add(val2.enemyName); } if (list.Any((string x) => (from y in mapEnemyTracker.GetConfig("Exclude Enemies").Split(new char[1] { ',' }) select y.Trim() into y where !string.IsNullOrEmpty(y) select y).Contains(x))) { return; } } if (variable.Contains(mapInfo) && variable2.Contains(mapInfo2)) { variable.Remove(mapInfo); variable.Add(mapInfo2); variable2.Remove(mapInfo2); variable2.Add(mapInfo); } else if (variable.Contains(mapInfo2) && variable2.Contains(mapInfo)) { variable.Remove(mapInfo2); variable.Add(mapInfo); variable2.Remove(mapInfo); variable2.Add(mapInfo2); } updateTracker = true; } private void Awake() { //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) instance = this; logger = Logger.CreateLogSource("MoreUpgrades"); assetBundle = AssetBundle.LoadFromMemory(Resources.moreupgrades); if ((Object)(object)assetBundle == (Object)null) { logger.LogError((object)"Something went wrong when loading the asset bundle."); return; } importUpgrades = ((BaseUnityPlugin)this).Config.Bind("! REPOLib Configuration !", "Import Upgrades", false, "Whether to import the upgrades from REPOLib."); excludeUpgradeIds = ((BaseUnityPlugin)this).Config.Bind("! REPOLib Configuration !", "Exclude Upgrade IDs", "", "Exclude specific REPOLib upgrades by listing their IDs, seperated by commas.\nThis setting only has an effect if 'Import Upgrades' is enabled."); upgradeItems = new List(); UpgradeItem.Base @base = new UpgradeItem.Base { name = "Sprint Usage", minPrice = 9000f, maxPrice = 14000f, maxAmount = 10, maxAmountInShop = 2 }; UpgradeItem sprintUsage = null; @base.onStart = (Action)Delegate.Combine(@base.onStart, new Action(UpdateSprintUsage)); @base.onUpgrade = (Action)Delegate.Combine(@base.onUpgrade, new Action(UpdateSprintUsage)); sprintUsage = new UpgradeItem(@base); sprintUsage.AddConfig("Scaling Factor", 0.9f, "Formula: energySprintDrain * (scalingFactor ^ upgradeLevel))"); upgradeItems.Add(sprintUsage); UpgradeItem.Base base2 = new UpgradeItem.Base { name = "Valuable Count", minPrice = 30000f, maxPrice = 40000f, maxPurchaseAmount = 1, priceIncreaseScaling = 0f }; UpgradeItem valuableCount = null; base2.onVariablesStart = (Action)Delegate.Combine(base2.onVariablesStart, (Action)delegate { valuableCount.AddVariable("Current Valuables", new List()); valuableCount.AddVariable("Changed", value: false); valuableCount.AddVariable("Previous Count", 0); valuableCount.AddVariable("Previous Value", 0); valuableCount.AddVariable("Text Length", 0); }); base2.onUpdate = (Action)Delegate.Combine(base2.onUpdate, (Action)delegate { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown if (!SemiFunc.RunIsLobby() && !SemiFunc.RunIsShop()) { PlayerAvatar playerAvatarScript4 = PlayerController.instance.playerAvatarScript; if ((Object)(object)MissionUI.instance != (Object)null && (Object)(object)playerAvatarScript4 != (Object)null && valuableCount.playerUpgrade.GetLevel(playerAvatarScript4) > 0) { TextMeshProUGUI val4 = (TextMeshProUGUI)AccessTools.Field(typeof(MissionUI), "Text").GetValue(MissionUI.instance); string text = (string)AccessTools.Field(typeof(MissionUI), "messagePrev").GetValue(MissionUI.instance); List variable4 = valuableCount.GetVariable>("Current Valuables"); bool variable5 = valuableCount.GetVariable("Changed"); int variable6 = valuableCount.GetVariable("Previous Count"); int variable7 = valuableCount.GetVariable("Previous Value"); int variable8 = valuableCount.GetVariable("Text Length"); int count = variable4.Count; bool config = valuableCount.GetConfig("Display Total Value"); int num8 = (config ? variable4.Select((ValuableObject x) => (int)(float)AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent").GetValue(x)).Sum() : 0); if (!string.IsNullOrEmpty(((TMP_Text)val4).text) && (variable5 || variable6 != count || variable7 != num8)) { string text2 = ((TMP_Text)val4).text; if (!variable5 && (variable6 != count || variable7 != num8)) { text2 = text2.Substring(0, text2.Length - variable8); } string text3 = $"\nValuables: {count}" + (config ? (" ($" + SemiFunc.DollarGetString(num8) + ")") : ""); text2 += text3; valuableCount.SetVariable("Previous Count", count); valuableCount.SetVariable("Previous Value", num8); valuableCount.SetVariable("Text Length", text3.Length); ((TMP_Text)val4).text = text2; AccessTools.Field(typeof(MissionUI), "messagePrev").SetValue(MissionUI.instance, text2); if (variable5) { valuableCount.SetVariable("Changed", value: false); } } } } }); valuableCount = new UpgradeItem(base2); valuableCount.AddConfig("Display Total Value", defaultValue: true, "Whether to display the total value next to the valuable counter."); valuableCount.AddConfig("Ignore Money Bags", defaultValue: false, "Whether to ignore the money bags from the extraction points."); upgradeItems.Add(valuableCount); Sprite mapTracker = assetBundle.LoadAsset("Map Tracker"); float trackerDelay = 0.2f; UpgradeItem.Base base3 = new UpgradeItem.Base { name = "Map Enemy Tracker", minPrice = 50000f, maxPrice = 60000f, maxPurchaseAmount = 1, priceIncreaseScaling = 0f }; UpgradeItem mapEnemyTracker = null; base3.onVariablesStart = (Action)Delegate.Combine(base3.onVariablesStart, (Action)delegate { mapEnemyTracker.AddVariable("Map Infos", new List()); }); base3.onUpdate = (Action)Delegate.Combine(base3.onUpdate, (Action)delegate { if (updateTracker || Time.time % trackerDelay < Time.deltaTime) { UpdateTracker(mapEnemyTracker); } }); mapEnemyTracker = new UpgradeItem(base3); mapEnemyTracker.AddConfig("Arrow Icon", defaultValue: true, "Whether the icon should appear as an arrow showing direction instead of a dot."); mapEnemyTracker.AddConfig("Color", Color.red, "The color of the icon."); mapEnemyTracker.AddConfig("Exclude Enemies", "", "Exclude specific enemies from displaying their icon by listing their names.\nExample: 'Gnome, Clown', seperated by commas."); upgradeItems.Add(mapEnemyTracker); UpgradeItem.Base base4 = new UpgradeItem.Base { name = "Map Player Tracker", minPrice = 30000f, maxPrice = 40000f, minPlayerCount = 2, maxPurchaseAmount = 1, priceIncreaseScaling = 0f }; UpgradeItem mapPlayerTracker = null; base4.onVariablesStart = (Action)Delegate.Combine(base4.onVariablesStart, (Action)delegate { mapPlayerTracker.AddVariable("Map Infos", new List()); }); base4.onUpdate = (Action)Delegate.Combine(base4.onUpdate, (Action)delegate { if (updateTracker || Time.time % trackerDelay < Time.deltaTime) { UpdateTracker(mapPlayerTracker); } }); mapPlayerTracker = new UpgradeItem(base4); mapPlayerTracker.AddConfig("Arrow Icon", defaultValue: true, "Whether the icon should appear as an arrow showing direction instead of a dot."); mapPlayerTracker.AddConfig("Player Color", defaultValue: false, "Whether the icon should be colored as the player."); mapPlayerTracker.AddConfig("Color", Color.blue, "The color of the icon."); upgradeItems.Add(mapPlayerTracker); UpgradeItem.Base base5 = new UpgradeItem.Base { name = "Item Resist", maxAmount = 10, maxAmountInShop = 2, minPrice = 4000f, maxPrice = 6000f }; UpgradeItem itemResist = null; base5.onVariablesStart = (Action)Delegate.Combine(base5.onVariablesStart, (Action)delegate { itemResist.AddVariable("Last Player Grabbed", new Dictionary()); }); itemResist = new UpgradeItem(base5); itemResist.AddConfig("Scaling Factor", 0.9f, "Formula: valueLost * (scalingFactor ^ upgradeLevel)"); itemResist.AddConfig("Print Valuables", defaultValue: false, "If enabled, the valuable name will be printed to the console that is being grabbed."); itemResist.AddConfig("Exclude Valuables", "", "Exclude specific valuables by listing their names, seperated by commas."); upgradeItems.Add(itemResist); UpgradeItem.Base base6 = new UpgradeItem.Base { name = "Map Zoom", minPrice = 20000f, maxPrice = 35000f, maxAmount = 2, maxAmountInShop = 1, maxPurchaseAmount = 2 }; UpgradeItem mapZoom = null; base6.onStart = (Action)Delegate.Combine(base6.onStart, new Action(UpdateMapZoom)); base6.onUpgrade = (Action)Delegate.Combine(base6.onUpgrade, new Action(UpdateMapZoom)); mapZoom = new UpgradeItem(base6); mapZoom.AddConfig("Scaling Factor", 0.75f, "Formula: defaultMapZoom + upgradeLevel * scalingFactor"); upgradeItems.Add(mapZoom); UpgradeItem upgradeItem2 = new UpgradeItem(new UpgradeItem.Base { name = "Autoscan", minPrice = 45000f, maxPrice = 50000f, maxAmount = 3, maxAmountInShop = 1, maxPurchaseAmount = 3 }); upgradeItem2.AddConfig("Silent Scanning", defaultValue: false, "Whether the scanned items should be silent or not."); upgradeItem2.AddConfig("Scaling Factor", 5f, "Formula: upgradeLevel * scalingFactor"); upgradeItems.Add(upgradeItem2); UpgradeItem upgradeItem3 = new UpgradeItem(new UpgradeItem.Base { name = "Item Value", minPrice = 75000f, maxPrice = 82500f, maxAmount = 10, maxAmountInShop = 2 }); upgradeItem3.AddConfig("Scaling Factor", 0.05f, "This variable is based on the host!\nFormula: itemValue * (1 + upgradeLevel * scalingFactor)"); upgradeItems.Add(upgradeItem3); UpgradeItem.Base base7 = new UpgradeItem.Base { name = "Extra Life", minPrice = 150000f, maxPrice = 225000f, maxAmount = 10, maxAmountInShop = 2 }; Keybind reviveKeybind = Keybinds.Bind("Revive", "/r"); base7.onUpdate = (Action)Delegate.Combine(base7.onUpdate, (Action)delegate { //IL_0031: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar playerAvatarScript3 = PlayerController.instance.playerAvatarScript; if (!((Object)(object)playerAvatarScript3 == (Object)null) && SemiFunc.NoTextInputsActive() && InputManager.instance.KeyUp(reviveKeybind.inputKey)) { MoreUpgradesManager.instance.Revive(playerAvatarScript3); } }); UpgradeItem upgradeItem4 = new UpgradeItem(base7); upgradeItem4.AddConfig("Singleplayer Invincibility Timer", 3f, "This variable is based on the host! After reviving, you will be given a short invincibility period."); upgradeItem4.AddConfig("Multiplayer Invincibility Timer", 0f, "This variable is based on the host! After reviving, you will be given a short invincibility period."); upgradeItems.Add(upgradeItem4); UpgradeItem.Base base8 = new UpgradeItem.Base { name = "Map Cosmetics Tracker", minPrice = 45000f, maxPrice = 60000f, maxPurchaseAmount = 1, priceIncreaseScaling = 0f }; UpgradeItem mapCosmeticsTracker = new UpgradeItem(base8); base8.onVariablesStart = (Action)Delegate.Combine(base8.onVariablesStart, (Action)delegate { mapCosmeticsTracker.AddVariable("Blink Timer", 0f); mapCosmeticsTracker.AddVariable("Cosmetic LED Infos", new List()); }); base8.onUpdate = (Action)Delegate.Combine(base8.onUpdate, (Action)delegate { //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar playerAvatarScript2 = PlayerController.instance.playerAvatarScript; if (!((Object)(object)playerAvatarScript2 == (Object)null)) { List variable2 = mapCosmeticsTracker.GetVariable>("Cosmetic LED Infos"); bool flag2 = mapCosmeticsTracker.playerUpgrade.GetLevel(playerAvatarScript2) > 0 && SemiFunc.RunIsLevel(); foreach (CosmeticLEDInfo item in variable2) { item.ledObject.SetActive(flag2); } if (flag2) { if ((bool)AccessTools.Field(typeof(MapToolController), "Active").GetValue(MapToolController.instance)) { float num = 0f; if (variable2.Any((CosmeticLEDInfo x) => (Object)(object)x.cosmeticWorldObject != (Object)null || x.isExtracted || x.isDestroyed)) { num = mapCosmeticsTracker.GetVariable("Blink Timer") + Time.deltaTime; mapCosmeticsTracker.SetVariable("Blink Timer", num); } Vector3 position = ((Component)playerAvatarScript2).transform.position; { foreach (CosmeticLEDInfo item2 in variable2) { Color val3 = Color.black; if (item2.isExtracted) { val3 = item2.color; } else if (item2.isDestroyed) { float num2 = 0.35f; float num3 = (Mathf.Sin(num * 1.25f * (float)Math.PI * 2f) + 1f) * 0.5f; num3 = Mathf.Pow(num3, 1f / num2); val3 = item2.color * (1f - num3) + Color.red * num3; } else if ((Object)(object)item2.cosmeticWorldObject != (Object)null) { float num4 = Vector3.Distance(position, ((Component)item2.cosmeticWorldObject).transform.position); float num5 = Mathf.InverseLerp(30f, 5f, num4); float num6 = Mathf.Lerp(1f, 2.75f, num5); float num7 = (Mathf.Sin(num * num6 * (float)Math.PI * 2f) + 1f) * 0.5f; num7 = Mathf.SmoothStep(0f, 1f, num7); val3 = item2.color * num7; } item2.ledMaterial.SetColor("_EmissionColor", val3); } return; } } float variable3 = mapCosmeticsTracker.GetVariable("Blink Timer"); if (variable3 != 0f) { mapCosmeticsTracker.SetVariable("Blink Timer", 0f); foreach (CosmeticLEDInfo item3 in variable2) { item3.ledMaterial.SetColor("_EmissionColor", Color.black); } } } } }); upgradeItems.Add(mapCosmeticsTracker); SceneManager.activeSceneChanged += delegate { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown if (!((Object)(object)RunManager.instance == (Object)null) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelMainMenu) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobbyMenu) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelSplashScreen)) { GameObject val2 = new GameObject("More Upgrades Manager"); val2.AddComponent(); } }; logger.LogMessage((object)"MoreUpgrades has started."); PatchAll("Patches"); if (REPOLib.IsLoaded()) { REPOLib.OnAwake(); } void UpdateMapZoom(PlayerAvatar playerAvatar, int level) { if (!((Object)(object)PlayerController.instance.playerAvatarScript != (Object)(object)playerAvatar)) { MapPatch.mapCamera.orthographicSize = MapPatch.defaultMapZoom + (float)level * mapZoom.GetConfig("Scaling Factor"); } } void UpdateSprintUsage(PlayerAvatar playerAvatar, int level) { if (!((Object)(object)PlayerController.instance.playerAvatarScript != (Object)(object)playerAvatar)) { string key = "Energy Sprint Drain"; if (!sprintUsage.HasVariable(key)) { sprintUsage.AddVariable(key, PlayerController.instance.EnergySprintDrain); } PlayerController.instance.EnergySprintDrain = sprintUsage.GetVariable(key) * Mathf.Pow(sprintUsage.GetConfig("Scaling Factor"), (float)level); } } void UpdateTracker(UpgradeItem upgradeItem) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_00e9: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar playerAvatarScript = PlayerController.instance.playerAvatarScript; if ((Object)(object)playerAvatarScript != (Object)null) { bool flag = upgradeItem.playerUpgrade.GetLevel(playerAvatarScript) > 0; PlayerDeathHead val = (PlayerDeathHead)AccessTools.Field(typeof(PlayerAvatar), "playerDeathHead").GetValue(playerAvatarScript); List variable = upgradeItem.GetVariable>("Map Infos"); foreach (MapInfo item4 in variable) { MapCustomEntity mapCustomEntity = item4.mapCustomEntity; SpriteRenderer spriteRenderer = mapCustomEntity.spriteRenderer; if (flag) { Transform parent = mapCustomEntity.Parent; if (Map.Instance.Active) { Map.Instance.CustomPositionSet(((Component)mapCustomEntity).transform, parent); } spriteRenderer.sprite = (upgradeItem.GetConfig("Arrow Icon") ? mapTracker : val.mapCustom.sprite); Color color = upgradeItem.GetConfig("Color"); if (upgradeItem.upgradeBase.name == "Map Player Tracker" && upgradeItem.GetConfig("Player Color")) { color = (Color)AccessTools.Field(typeof(PlayerAvatarVisuals), "color").GetValue(playerAvatarScript.playerAvatarVisuals); } MapLayer layerParent = Map.Instance.GetLayerParent(parent.position.y + 1f); if (layerParent.layer == Map.Instance.PlayerLayer) { color.a = 1f; } else { color.a = 0.3f; } spriteRenderer.color = color; } ((Renderer)spriteRenderer).enabled = flag && item4.visible; } } updateTracker = false; } } } } namespace MoreUpgrades.REPOLibPatches { [HarmonyPatch(typeof(REPOLibItemUpgrade))] internal class REPOLibItemUpgradePatch { [HarmonyPatch("Upgrade")] [HarmonyTranspiler] private static IEnumerable UpgradeTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(PlayerUpgrade), "AddLevel", new Type[2] { typeof(PlayerAvatar), typeof(int) }, (Type[])null), (string)null) }); val.RemoveInstructions(2); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(REPOLibItemUpgradePatch), "Upgrade", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } private static void Upgrade(PlayerUpgrade playerUpgrade, PlayerAvatar playerAvatar, int amount) { if ((Object)(object)MoreUpgradesManager.instance != (Object)null) { UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)playerUpgrade.Item); if (upgradeItem != null && upgradeItem.GetConfig("Allow Team Upgrades")) { foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { playerUpgrade.AddLevel(item, amount); } return; } } playerUpgrade.AddLevel(playerAvatar, amount); } } [HarmonyPatch(typeof(Upgrades))] internal class UpgradesPatch { [HarmonyPatch("RegisterUpgrades")] [HarmonyPostfix] private static void RegisterUpgrades(Dictionary ____playerUpgrades) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown if ((Object)(object)Plugin.instance.assetBundle == (Object)null || (Object)(object)StatsManager.instance == (Object)null) { return; } foreach (KeyValuePair pair in ____playerUpgrades) { UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)pair.Value.Item); if (upgradeItem != null) { StatsManager.instance.upgradesInfo["playerUpgrade" + pair.Key] = new UpgradeInfo { displayName = upgradeItem.upgradeBase.name }; string key = "appliedPlayerUpgrade" + pair.Key; Dictionary appliedPlayerDictionary = upgradeItem.appliedPlayerDictionary; SortedDictionary> sortedDictionary = (SortedDictionary>)AccessTools.Field(typeof(StatsManager), "dictionaryOfDictionaries").GetValue(StatsManager.instance); if (sortedDictionary.TryGetValue(key, out var value)) { appliedPlayerDictionary = value; continue; } appliedPlayerDictionary.Clear(); sortedDictionary[key] = appliedPlayerDictionary; } } } [HarmonyPatch("RegisterUpgrade")] [HarmonyPostfix] private static void RegisterUpgrade(ref PlayerUpgrade __result) { if (!((Object)(object)Plugin.instance.assetBundle == (Object)null) && __result != null && Plugin.instance.importUpgrades.Value && !(from x in Plugin.instance.excludeUpgradeIds.Value.Split(new char[1] { ',' }) select x.Trim() into x where !string.IsNullOrEmpty(x) select x).Contains(__result.UpgradeId)) { Plugin.instance.upgradeItems.Add(new UpgradeItem(__result)); } } } } namespace MoreUpgrades.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { ResourceManager resourceManager = new ResourceManager("MoreUpgrades.Properties.Resources", typeof(Resources).Assembly); resourceMan = resourceManager; } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] moreupgrades { get { object @object = ResourceManager.GetObject("moreupgrades", resourceCulture); return (byte[])@object; } } internal Resources() { } } } namespace MoreUpgrades.Patches { [HarmonyPatch(typeof(ItemAttributes))] internal class ItemAttributesPatch { [HarmonyPatch("GetValue")] [HarmonyTranspiler] private static IEnumerable GetValueTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(ShopManager), "instance"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier"), (string)null) }; val.MatchForward(false, array); val.RemoveInstructions(array.Length); val.Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ItemAttributes), "item")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MoreUpgradesAPI), "ItemValueMultiplier", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } } [HarmonyPatch(typeof(Map))] internal class MapPatch { public static Camera mapCamera; public static float defaultMapZoom; [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake(ref Transform ___playerTransformTarget) { mapCamera = ((Component)___playerTransformTarget).GetComponentInChildren(); defaultMapZoom = mapCamera.orthographicSize; } } [HarmonyPatch(typeof(CosmeticWorldObject))] internal class CosmeticWorldObjectPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start(CosmeticWorldObject __instance, Color ___blinkMaterialDefault) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Cosmetics Tracker"); if (upgradeItem == null) { return; } List variable = upgradeItem.GetVariable>("Cosmetic LED Infos"); foreach (CosmeticLEDInfo item in variable) { if (item.isExtracted || item.isDestroyed || (Object)(object)item.cosmeticWorldObject == (Object)null) { item.isExtracted = false; item.isDestroyed = false; item.color = ___blinkMaterialDefault; item.cosmeticWorldObject = __instance; break; } } } [HarmonyPatch("ExtractRPC")] [HarmonyPostfix] private static void ExtractRPC(CosmeticWorldObject __instance) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Cosmetics Tracker"); if (upgradeItem == null) { return; } List variable = upgradeItem.GetVariable>("Cosmetic LED Infos"); foreach (CosmeticLEDInfo item in variable) { if ((Object)(object)item.cosmeticWorldObject == (Object)(object)__instance) { item.isExtracted = true; break; } } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector))] internal class PhysGrabObjectImpactDetectorPatch { [HarmonyPatch("Break")] [HarmonyPrefix] private static void Break(PhysGrabObjectImpactDetector __instance, PhysGrabObject ___physGrabObject, bool ___isValuable, ref float valueLost) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null || !___isValuable) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Item Resist"); if (upgradeItem == null || (from x in upgradeItem.GetConfig("Exclude Valuables").Split(new char[1] { ',' }) select x.Trim() into x where !string.IsNullOrEmpty(x) select x).Contains(((Object)___physGrabObject).name.Replace("(Clone)", ""))) { return; } List playerGrabbing = ___physGrabObject.playerGrabbing; if (playerGrabbing != null && playerGrabbing.Count > 0) { List list = playerGrabbing.Select((PhysGrabber player) => player.playerAvatar).ToList(); int num = 0; foreach (PlayerAvatar item in list) { num += upgradeItem.playerUpgrade.GetLevel(item); } valueLost = ReduceValueLost(upgradeItem, valueLost, num); } else { Dictionary variable = upgradeItem.GetVariable>("Last Player Grabbed"); if (variable.TryGetValue(___physGrabObject, out var value)) { valueLost = ReduceValueLost(upgradeItem, valueLost, upgradeItem.playerUpgrade.GetLevel(value)); } } } private static float ReduceValueLost(UpgradeItem upgradeItem, float valueLost, int level) { return valueLost * Mathf.Pow(upgradeItem.GetConfig("Scaling Factor"), (float)level); } } [HarmonyPatch(typeof(PhysGrabber))] internal class PhysGrabberPatch { [HarmonyPatch("RayCheck")] [HarmonyPostfix] private static void RayCheck(PlayerAvatar ___playerAvatar, LayerMask ___mask) { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MoreUpgradesManager.instance == (Object)null || (Object)(object)PlayerController.instance.playerAvatarScript != (Object)(object)___playerAvatar || (bool)AccessTools.Field(typeof(PlayerAvatar), "isDisabled").GetValue(___playerAvatar) || (bool)AccessTools.Field(typeof(PlayerAvatar), "deadSet").GetValue(___playerAvatar)) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Autoscan"); if (upgradeItem == null) { return; } int level = upgradeItem.playerUpgrade.GetLevel(___playerAvatar); if (level <= 0) { return; } Vector3 position = ___playerAvatar.playerTransform.position; Collider[] array = Physics.OverlapSphere(position, (float)level * upgradeItem.GetConfig("Scaling Factor"), LayerMask.op_Implicit(___mask), (QueryTriggerInteraction)2); Collider[] array2 = array; foreach (Collider val in array2) { ValuableObject componentInParent = ((Component)((Component)val).transform).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || (bool)AccessTools.Field(typeof(ValuableObject), "discovered").GetValue(componentInParent)) { continue; } if (upgradeItem.GetConfig("Silent Scanning")) { if (!GameManager.Multiplayer()) { AccessTools.Method(typeof(ValuableObject), "DiscoverRPC", (Type[])null, (Type[])null).Invoke(componentInParent, null); } else { ((PhotonView)AccessTools.Field(typeof(ValuableObject), "photonView").GetValue(componentInParent)).RPC("DiscoverRPC", (RpcTarget)0, Array.Empty()); } } else { componentInParent.Discover((State)0); } } } } [HarmonyPatch(typeof(MapToolController))] internal class MapToolControllerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start(Transform ___displaySpringTransform) { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Cosmetics Tracker"); if (upgradeItem != null) { List variable = upgradeItem.GetVariable>("Cosmetic LED Infos"); float num = 0.025f; float num2 = 0.1f; int num3 = ValuableDirector.instance.cosmeticWorldObjectsLevelLoopsMax + 1; float num4 = num2 + (float)(num3 - 1) * num * 0.5f; GameObject gameObject = ((Component)___displaySpringTransform.Find("LED - L")).gameObject; for (int i = 0; i < num3; i++) { GameObject val = Object.Instantiate(gameObject, ___displaySpringTransform, false); ((Object)val).name = "Left Side LED - Cosmetics Indicator " + (i + 1); Material val2 = Object.Instantiate(gameObject.GetComponent().material); ((Object)val2).name = "Dirt Finder - LED Cosmetics Indicator " + (i + 1); val2.SetColor("_Color", Color.black); val.GetComponent().material = val2; val.transform.localScale = new Vector3(1.25f, 1.25f, 1.25f); val.transform.localPosition = new Vector3(-0.0575f, 0f, num4 - (float)i * num); variable.Add(new CosmeticLEDInfo { ledObject = val, ledMaterial = val2 }); } } } } [HarmonyPatch(typeof(PlayerAvatar))] internal class PlayerAvatarPatch { [HarmonyPatch("LateStart")] [HarmonyPostfix] private static void LateStart(PlayerAvatar __instance) { if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)__instance == (Object)(object)PlayerController.instance.playerAvatarScript)) { Plugin.instance.RegisterToMap((Component)(object)__instance); Plugin.instance.ShowToMap((Component)(object)__instance); } } [HarmonyPatch("ReviveRPC")] [HarmonyPostfix] private static void ReviveRPC(PlayerAvatar __instance) { if (!((Object)(object)MoreUpgradesManager.instance == (Object)null)) { Plugin.instance.ShowToMap((Component)(object)__instance); } } [HarmonyPatch("PlayerDeathRPC")] [HarmonyPostfix] private static void PlayerDeathRPC(PlayerAvatar __instance) { if (!((Object)(object)MoreUpgradesManager.instance == (Object)null)) { Plugin.instance.HideFromMap((Component)(object)__instance); } } } [HarmonyPatch(typeof(EnemySlowMouth))] internal class EnemySlowMouthPatch { [HarmonyPatch("UpdateStateRPC")] [HarmonyPostfix] private static void UpdateStateRPC(EnemySlowMouth __instance, Enemy ___enemy) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0062: 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) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Invalid comparison between Unknown and I4 if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)___enemy == (Object)null)) { PlayerAvatar val = (PlayerAvatar)AccessTools.Field(typeof(EnemySlowMouth), "playerTarget").GetValue(__instance); EnemyParent val2 = (EnemyParent)AccessTools.Field(typeof(Enemy), "EnemyParent").GetValue(___enemy); State currentState = __instance.currentState; if ((int)currentState == 9) { Plugin.instance.HideFromMap((Component)(object)val2); Plugin.instance.SwapOnMap((Component)(object)val2, (Component)(object)val); } else if ((int)currentState == 11) { Plugin.instance.SwapOnMap((Component)(object)val, (Component)(object)val2); Plugin.instance.ShowToMap((Component)(object)val2); } } } } [HarmonyPatch(typeof(EnemyParent))] internal class EnemyParentPatch { [HarmonyPatch("Setup")] [HarmonyPostfix] private static void Setup(EnemyParent __instance) { if (!((Object)(object)MoreUpgradesManager.instance == (Object)null)) { Plugin.instance.RegisterToMap((Component)(object)__instance); } } [HarmonyPatch("SpawnRPC")] [HarmonyPostfix] private static void SpawnRPC(EnemyParent __instance) { if (!((Object)(object)MoreUpgradesManager.instance == (Object)null)) { Plugin.instance.ShowToMap((Component)(object)__instance); } } [HarmonyPatch("DespawnRPC")] [HarmonyPostfix] private static void DespawnRPC(EnemyParent __instance) { if (!((Object)(object)MoreUpgradesManager.instance == (Object)null)) { Plugin.instance.HideFromMap((Component)(object)__instance); } } } [HarmonyPatch(typeof(EnemyHealth))] internal class EnemyHealthPatch { [HarmonyPatch("DeathRPC")] [HarmonyPostfix] private static void DeathRPC(EnemyHealth __instance, Enemy ___enemy) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown if (!((Object)(object)MoreUpgradesManager.instance == (Object)null)) { Plugin.instance.HideFromMap((Component)(EnemyParent)AccessTools.Field(typeof(Enemy), "EnemyParent").GetValue(___enemy)); } } } [HarmonyPatch(typeof(MissionUI))] internal class MissionUIPatch { [HarmonyPatch("MissionText")] [HarmonyTranspiler] private static IEnumerable MissionTextTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(MissionUI), "messagePrev"), (string)null) }); val.Advance(1); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MissionUIPatch), "MissionText", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } private static void MissionText() { if (!((Object)(object)MoreUpgradesManager.instance == (Object)null)) { Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Valuable Count")?.SetVariable("Changed", value: true); } } } [HarmonyPatch(typeof(UpgradeStand))] internal class UpgradeStandPatch { [HarmonyPatch("GetWeightedUpgradeExcluding")] [HarmonyTranspiler] private static IEnumerable GetWeightedUpgradeExcludingTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Dictionary.ValueCollection.Enumerator), "get_Current", (Type[])null, (Type[])null), (string)null) }); object operand = val.Operand; val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Dictionary.ValueCollection.Enumerator), "get_Current", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_3, (object)null, (string)null) }); val.Advance(1); val.Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloc_3, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UpgradeStandPatch), "GetWeightedUpgradeExcluding", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Brtrue, operand) }); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(ShopManager), "instance"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier"), (string)null) }); val.RemoveInstructions(2); val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_3, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MoreUpgradesAPI), "ItemValueMultiplier", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } private static bool GetWeightedUpgradeExcluding(Item item) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return false; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)item); return upgradeItem != null && !upgradeItem.GetConfig("Enabled"); } } [HarmonyPatch(typeof(ValuableObject))] internal class ValuableObjectPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start(ValuableObject __instance) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Valuable Count"); if (upgradeItem != null && (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent()) || !upgradeItem.GetConfig("Ignore Money Bags"))) { List variable = upgradeItem.GetVariable>("Current Valuables"); if (!variable.Contains(__instance)) { variable.Add(__instance); } } } [HarmonyPatch("DollarValueSetLogic")] [HarmonyTranspiler] private static IEnumerable DollarValueSetLogicTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ValuableObject), "dollarValueOriginal"), (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent"), (string)null) }); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableObjectPatch), "DollarValueSetLogic", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } private static float DollarValueSetLogic(float dollarValueCurrent) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return dollarValueCurrent; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Item Value"); if (upgradeItem == null) { return dollarValueCurrent; } int num = 0; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { num = upgradeItem.playerUpgrade.GetLevel(player); } return dollarValueCurrent * (1f + (float)num * upgradeItem.GetConfig("Scaling Factor")); } } [HarmonyPatch(typeof(PhysGrabObject))] internal class PhysGrabObjectPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void Update(PhysGrabObject __instance, bool ___isValuable, PlayerAvatar ___lastPlayerGrabbing) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null || !___isValuable) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Item Resist"); if (upgradeItem == null || (from x in upgradeItem.GetConfig("Exclude Valuables").Split(new char[1] { ',' }) select x.Trim() into x where !string.IsNullOrEmpty(x) select x).Contains(((Object)__instance).name.Replace("(Clone)", "")) || !((Object)(object)___lastPlayerGrabbing != (Object)null)) { return; } Dictionary variable = upgradeItem.GetVariable>("Last Player Grabbed"); if (!variable.TryGetValue(__instance, out var value) || !((Object)(object)value == (Object)(object)___lastPlayerGrabbing)) { if (variable.ContainsKey(__instance)) { variable.Remove(__instance); } variable.Add(__instance, ___lastPlayerGrabbing); } } [HarmonyPatch("OnDestroy")] [HarmonyPostfix] private static void OnDestroy(PhysGrabObject __instance) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return; } ValuableObject component = ((Component)__instance).gameObject.GetComponent(); if ((Object)(object)component == (Object)null) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Valuable Count"); if (upgradeItem != null && (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent()) || !upgradeItem.GetConfig("Ignore Money Bags"))) { List variable = upgradeItem.GetVariable>("Current Valuables"); if (variable.Contains(component)) { variable.Remove(component); } } } [HarmonyPatch("DestroyPhysGrabObject")] [HarmonyPostfix] private static void DestroyPhysGrabObject(PhysGrabObject __instance) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return; } CosmeticWorldObject component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Cosmetics Tracker"); if (upgradeItem == null) { return; } List variable = upgradeItem.GetVariable>("Cosmetic LED Infos"); foreach (CosmeticLEDInfo item in variable) { if ((Object)(object)item.cosmeticWorldObject == (Object)(object)component) { item.isDestroyed = true; break; } } } [HarmonyPatch("GrabStarted")] [HarmonyPostfix] private static void GrabStarted(PhysGrabObject __instance, bool ___grabbedLocal, bool ___isValuable) { if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && ___grabbedLocal && ___isValuable) { UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Item Resist"); if (upgradeItem != null && upgradeItem.GetConfig("Print Valuables")) { Plugin.instance.logger.LogMessage((object)("Grabbed Valuable Name: " + ((Object)__instance).name.Replace("(Clone)", ""))); } } } } [HarmonyPatch(typeof(ShopManager))] internal class ShopManagerPatch { [HarmonyPatch("GetAllItemsFromStatsManager")] [HarmonyTranspiler] private static IEnumerable GetAllItemsFromStatsManagerTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Dictionary.ValueCollection.Enumerator), "get_Current", (Type[])null, (Type[])null), (string)null) }); object operand = val.Operand; val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Dictionary.ValueCollection.Enumerator), "get_Current", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }); val.Advance(1); val.Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ShopManagerPatch), "GetAllItemsFromStatsManager", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Brtrue, operand) }); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier"), (string)null) }); val.RemoveInstructions(2); val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MoreUpgradesAPI), "ItemValueMultiplier", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } private static bool GetAllItemsFromStatsManager(Item item) { if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return false; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)item); return upgradeItem != null && !upgradeItem.GetConfig("Enabled"); } [HarmonyPatch("UpgradeValueGet")] [HarmonyTranspiler] private static IEnumerable UpgradeValueGetTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "upgradeValueIncrease"), (string)null) }; val.MatchForward(false, array); val.RemoveInstructions(array.Length); val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_2, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MoreUpgradesAPI), "UpgradeValueIncrease", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } } } namespace MoreUpgrades.Compatibility { internal static class KeybindLib { internal const string modGUID = "bulletbot.keybindlib"; } internal static class REPOLib { internal const string modGUID = "REPOLib"; public static bool IsLoaded() { return Chainloader.PluginInfos.ContainsKey("REPOLib"); } public static void OnAwake() { Plugin.instance.PatchAll("REPOLibPatches"); } } } namespace MoreUpgrades.Classes { internal class CosmeticLEDInfo { public GameObject ledObject; public Material ledMaterial; public CosmeticWorldObject cosmeticWorldObject; public Color color; public bool isExtracted; public bool isDestroyed; } internal class MapInfo { public Component component; public MapCustomEntity mapCustomEntity; public bool visible; } public static class MoreUpgradesAPI { public static float ItemValueMultiplier(Item item) { float num = (float)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier").GetValue(ShopManager.instance); if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return num; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)item); if (upgradeItem == null) { return num; } float num2 = upgradeItem.GetConfig("Price Multiplier"); if (num2 < 0f) { num2 = num; } return num2; } public static float UpgradeValueIncrease(Item item) { float num = (float)AccessTools.Field(typeof(ShopManager), "upgradeValueIncrease").GetValue(ShopManager.instance); if ((Object)(object)MoreUpgradesManager.instance == (Object)null) { return num; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)item); if (upgradeItem == null) { return num; } float num2 = upgradeItem.GetConfig("Price Increase Scaling"); if (num2 < 0f) { num2 = num; } return num2; } } internal class MoreUpgradesManager : MonoBehaviour { [CompilerGenerated] private sealed class d__7 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public MoreUpgradesManager <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitUntil((Func)(() => SemiFunc.LevelGenDone())); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.checkPlayerUpgrades = 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(); } } internal static MoreUpgradesManager instance; private PhotonView photonView; private bool checkPlayerUpgrades; private void Awake() { instance = this; photonView = ((Component)this).gameObject.AddComponent(); photonView.ViewID = 876842; foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems) { upgradeItem.variables?.Clear(); upgradeItem.upgradeBase.onVariablesStart?.Invoke(); } if (SemiFunc.IsMasterClientOrSingleplayer()) { ((MonoBehaviour)this).StartCoroutine("WaitUntilLevel"); } } private void Update() { foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems) { upgradeItem.upgradeBase.onUpdate?.Invoke(); } } private void LateUpdate() { foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems) { upgradeItem.upgradeBase.onLateUpdate?.Invoke(); } } private void FixedUpdate() { foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems) { if (checkPlayerUpgrades) { int config = upgradeItem.GetConfig("Starting Amount"); if (config >= 0) { foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string key = SemiFunc.PlayerGetSteamID(item); if (!upgradeItem.appliedPlayerDictionary.ContainsKey(key)) { upgradeItem.appliedPlayerDictionary[key] = 0; } if (upgradeItem.appliedPlayerDictionary[key] != config) { upgradeItem.playerUpgrade.SetLevel(item, config); upgradeItem.appliedPlayerDictionary[key] = config; } } } if (upgradeItem.GetConfig("Sync Host Upgrades")) { PlayerAvatar localPlayerAvatar = SemiFunc.PlayerAvatarLocal(); int level = upgradeItem.playerUpgrade.GetLevel(localPlayerAvatar); foreach (PlayerAvatar item2 in from x in SemiFunc.PlayerGetAll() where (Object)(object)x != (Object)(object)localPlayerAvatar select x) { if (level != upgradeItem.playerUpgrade.GetLevel(item2)) { upgradeItem.playerUpgrade.SetLevel(item2, level); } } } } upgradeItem.upgradeBase.onFixedUpdate?.Invoke(); } } [IteratorStateMachine(typeof(d__7))] private IEnumerator WaitUntilLevel() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { <>4__this = this }; } public void Revive(PlayerAvatar playerAvatar) { string text = SemiFunc.PlayerGetSteamID(playerAvatar); if (text != null) { if (!SemiFunc.IsMultiplayer()) { ReviveRPC(text); return; } photonView.RPC("ReviveRPC", (RpcTarget)2, new object[1] { text }); } } [PunRPC] private void ReviveRPC(string steamId) { if (SemiFunc.RunIsShop() || SemiFunc.RunIsArena()) { return; } PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamId); if ((Object)(object)val == (Object)null || !(bool)AccessTools.Field(typeof(PlayerAvatar), "isDisabled").GetValue(val) || !(bool)AccessTools.Field(typeof(PlayerAvatar), "deadSet").GetValue(val)) { return; } UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Extra Life"); if (upgradeItem != null && upgradeItem.playerUpgrade.GetLevel(steamId) > 0) { upgradeItem.playerUpgrade.RemoveLevel(val, 1); val.Revive(false); PlayerHealth playerHealth = val.playerHealth; playerHealth.HealOther((int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(playerHealth) - 1, false); bool flag = SemiFunc.IsMultiplayer(); float config = upgradeItem.GetConfig((flag ? "Multiplayer" : "Singleplayer") + " Invincibility Timer"); if (!flag) { SetInvincibleRPC(steamId, config); return; } photonView.RPC("SetInvincibleRPC", (RpcTarget)0, new object[2] { steamId, config }); } } [PunRPC] private void SetInvincibleRPC(string steamId, float duration) { PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamId); if (!((Object)(object)val == (Object)null) && (bool)AccessTools.Field(typeof(PlayerAvatar), "isDisabled").GetValue(val) && (bool)AccessTools.Field(typeof(PlayerAvatar), "deadSet").GetValue(val)) { val.playerHealth.InvincibleSet(duration); } } } internal class UpgradeItem { internal class Base { public string name = null; public float minPrice = 1000f; public float maxPrice = 1000f; public int maxAmount = 1; public int maxAmountInShop = 1; public int minPlayerCount = 1; public int maxPurchaseAmount = 0; public float priceIncreaseScaling = -1f; public Action onStart; public Action onUpgrade; public Action onVariablesStart; public Action onUpdate; public Action onLateUpdate; public Action onFixedUpdate; public List excludeConfigs = new List(); } private bool isRepoLibImported; private string sectionName; public Base upgradeBase; public PlayerUpgrade playerUpgrade; private Dictionary configEntries; public Dictionary appliedPlayerDictionary; public Dictionary variables; public bool AddConfig(string key, T defaultValue, string description = "") { if (configEntries.ContainsKey(key)) { Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' already exists. Duplicates are not allowed.")); return false; } if (upgradeBase.excludeConfigs.Contains(key)) { return false; } configEntries.Add(key, (ConfigEntryBase)(object)((BaseUnityPlugin)Plugin.instance).Config.Bind(sectionName, key, defaultValue, description)); return true; } public bool SetConfig(string key, T value) { if (!configEntries.TryGetValue(key, out var value2)) { Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' does not exist. Returning default value.")); return false; } if (value2 is ConfigEntry val) { val.Value = value; return true; } Plugin.instance.logger.LogWarning((object)("Type mismatch for config entry '" + key + "'. Expected: " + value2.SettingType.FullName + ", but got: " + typeof(T).FullName + ". Returning default value.")); return false; } public T GetConfig(string key) { if (!configEntries.TryGetValue(key, out var value)) { Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' does not exist. Returning default value.")); return default(T); } if (value is ConfigEntry val) { return val.Value; } Plugin.instance.logger.LogWarning((object)("Type mismatch for config entry '" + key + "'. Expected: " + value.SettingType.FullName + ", but got: " + typeof(T).FullName + ". Returning default value.")); return default(T); } public bool HasVariable(string key) { object value; return variables.TryGetValue(key, out value); } public bool AddVariable(string key, T value) { if (HasVariable(key)) { Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' already exists. Duplicates are not allowed.")); return false; } variables.Add(key, value); return true; } public bool SetVariable(string key, T value) { if (!variables.TryGetValue(key, out var value2)) { Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' does not exist.")); return false; } if (value2 is T) { variables[key] = value; return true; } Plugin.instance.logger.LogWarning((object)("Type mismatch for variable '" + key + "'. Expected: " + value2.GetType().FullName + ", but got: " + typeof(T).FullName + ".")); return false; } public T GetVariable(string key) { if (!variables.TryGetValue(key, out var value)) { Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' does not exist. Returning default value.")); return default(T); } if (value is T result) { return result; } Plugin.instance.logger.LogWarning((object)("Type mismatch for variable '" + key + "'. Expected: " + value.GetType().FullName + ", but got: " + typeof(T).FullName + ". Returning default value.")); return default(T); } private void SetupConfig() { configEntries = new Dictionary(); AddConfig("Enabled", defaultValue: true, "Whether the upgrade item can appear in the shop."); AddConfig("Minimum Price", upgradeBase.minPrice, "The minimum cost to purchase the upgrade item."); AddConfig("Maximum Price", upgradeBase.maxPrice, "The maximum cost to purchase the upgrade item."); AddConfig("Max Amount", upgradeBase.maxAmount, "The maximum number of times the upgrade item can appear in the truck."); AddConfig("Max Amount In Shop", upgradeBase.maxAmountInShop, "The maximum number of times the upgrade item can appear in the shop."); AddConfig("Min Player Count", upgradeBase.minPlayerCount, "The minimum number of players required for the upgrade item to appear in the shop."); AddConfig("Max Purchase Amount", upgradeBase.maxPurchaseAmount, "The maximum number of times the upgrade item can be purchased before it is no longer available in the shop.\nSet to 0 to disable the limit."); AddConfig("Price Increase Scaling", upgradeBase.priceIncreaseScaling, "The scale of the price increase based on the total number of upgrade item purchased.\nSet this value under 0 to use the default scaling."); AddConfig("Price Multiplier", isRepoLibImported ? (-1f) : 1f, "The multiplier of the price.\nSet this value under 0 to use the default multiplier."); AddConfig("Allow Team Upgrades", defaultValue: false, "Whether the upgrade item applies to the entire team instead of just one player."); AddConfig("Sync Host Upgrades", defaultValue: false, "Whether the host should sync the item upgrade for the entire team."); AddConfig("Starting Amount", 0, "The number of times the upgrade item is applied at the start of the game."); } internal UpgradeItem(Base upgradeBase) { //IL_0040: 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_004f: Unknown result type (might be due to invalid IL or missing references) sectionName = upgradeBase.name; this.upgradeBase = upgradeBase; appliedPlayerDictionary = new Dictionary(); variables = new Dictionary(); SetupConfig(); Item val = ScriptableObject.CreateInstance(); val.itemType = (itemType)3; val.emojiIcon = (emojiIcon)11; val.itemVolume = (itemVolume)6; string name = (((Object)val).name = "Modded Item Upgrade Player " + upgradeBase.name); val.itemName = upgradeBase.name + " Upgrade"; Value val2 = ScriptableObject.CreateInstance(); val2.valueMin = GetConfig("Minimum Price"); val2.valueMax = GetConfig("Maximum Price"); val.value = val2; val.maxAmount = GetConfig("Max Amount"); val.maxAmountInShop = GetConfig("Max Amount In Shop"); val.minPlayerCount = GetConfig("Min Player Count"); val.maxPurchaseAmount = GetConfig("Max Purchase Amount"); val.maxPurchase = val.maxPurchaseAmount > 0; GameObject val3 = Plugin.instance.assetBundle.LoadAsset(upgradeBase.name); ((Object)val3).name = name; REPOLibItemUpgrade component = val3.GetComponent(); AccessTools.Field(typeof(REPOLibItemUpgrade), "_upgradeId").SetValue(component, upgradeBase.name); ItemAttributes component2 = val3.GetComponent(); component2.item = val; Items.RegisterItem(component2); playerUpgrade = Upgrades.RegisterUpgrade(upgradeBase.name, val, upgradeBase.onStart, upgradeBase.onUpgrade); } internal UpgradeItem(PlayerUpgrade playerUpgrade) { isRepoLibImported = true; Item item = playerUpgrade.Item; upgradeBase = new Base { name = playerUpgrade.UpgradeId, minPrice = item.value.valueMin, maxPrice = item.value.valueMax, maxAmount = item.maxAmount, maxAmountInShop = item.maxAmountInShop, minPlayerCount = item.minPlayerCount, maxPurchaseAmount = item.maxPurchaseAmount }; sectionName = upgradeBase.name + " (REPOLib)"; appliedPlayerDictionary = new Dictionary(); SetupConfig(); item.value.valueMin = GetConfig("Minimum Price"); item.value.valueMax = GetConfig("Maximum Price"); item.maxAmount = GetConfig("Max Amount"); item.maxAmountInShop = GetConfig("Max Amount In Shop"); item.minPlayerCount = GetConfig("Min Player Count"); item.maxPurchaseAmount = GetConfig("Max Purchase Amount"); item.maxPurchase = item.maxPurchaseAmount > 0; this.playerUpgrade = playerUpgrade; } } }