Decompiled source of BiggerBazaar v1.13.13
BiggerBazaar.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Mono.Cecil.Cil; using MonoMod.Utils; using On.EntityStates.CaptainSupplyDrop; using On.RoR2; using R2API.Utils; using RoR2; using ShareSuite; using Unity; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("BiggerBazaar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BiggerBazaar")] [assembly: AssemblyTitle("BiggerBazaar")] [assembly: AssemblyVersion("1.0.0.0")] namespace BiggerBazaar; internal class Bazaar : MonoBehaviour { private List<BazaarItem> bazaarItems = new List<BazaarItem>(); private List<GameObject> displayItems = new List<GameObject>(); private List<Vector3> bazaarItemPositions = new List<Vector3>(); private List<Vector3> bazaarItemRotations = new List<Vector3>(); private List<BazaarPlayer> bazaarPlayers = new List<BazaarPlayer>(); private readonly Random r = new Random(); private int bazaarItemAmount = ((ModConfig.chestAmount.Value >= 1 && ModConfig.chestAmount.Value <= 6) ? ModConfig.chestAmount.Value : 6); private GameObject moneyLunarPod; private Vector3 moneyPodPosition = new Vector3(-118.9f, -23.4f, -45.4f); public bool isUsingexperimentalScaling; private int priceScaledLunarPodBaseCost; private Dictionary<ItemTier, float> tierRatio = new Dictionary<ItemTier, float>(); private BarrelInteraction barrelInteraction; public float CurrentDifficultyCoefficient { get; set; } public Bazaar() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) FillBazaarItemPositionsAndRotations(); } private void SpawnBazaarItemAt(Vector3 position, Vector3 rotation, PickupTier pickupTier, int cost, BiggerBazaar biggerBazaar) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002c: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0062: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_01ea: Unknown result type (might be due to invalid IL or missing references) SpawnCard val = ((ModConfig.chestCostType.Value != 0) ? Resources.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscLunarChest") : Resources.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscChest1")); DirectorPlacementRule val2 = new DirectorPlacementRule(); val2.placementMode = (PlacementMode)0; GameObject spawnedInstance = val.DoSpawn(position, Quaternion.Euler(new Vector3(0f, 0f, 0f)), new DirectorSpawnRequest(val, val2, Run.instance.runRNG)).spawnedInstance; spawnedInstance.transform.eulerAngles = rotation; List<PickupIndex> availableItems = GetAvailableItems(pickupTier); int index = r.Next(availableItems.Count); PickupIndex val3 = availableItems[index]; GameObject val4 = Object.Instantiate<GameObject>(Resources.Load<GameObject>("Prefabs/NetworkedObjects/GenericPickup"), position, Quaternion.identity); ((Component)val4.GetComponent<GenericPickupController>()).transform.Translate(-2f, 4f, -3f, (Space)0); displayItems.Add(val4); NetworkServer.Spawn(val4); GenericPickupController component = val4.GetComponent<GenericPickupController>(); val4.GetComponent<GenericPickupController>().NetworkpickupIndex = PickupIndex.none; ((MonoBehaviour)biggerBazaar).StartCoroutine(DelayPickupIndexSetupForDisplayItems(component, val3)); PurchaseInteraction component2 = spawnedInstance.GetComponent<PurchaseInteraction>(); if (ModConfig.chestCostType.Value == 1) { component2.costType = (CostTypeIndex)3; component2.Networkcost = cost; } else if (cost == -1) { if (ModConfig.nextLevelChestPriceScaling.Value) { component2.Networkcost = Run.instance.GetDifficultyScaledCost(component2.cost); component2.Networkcost = (int)((float)component2.Networkcost * ModConfig.GetTierUnitConfig(pickupTier).cost); } else { component2.Networkcost = GetDifficultyScaledCostFromItemTier(component2.cost); component2.Networkcost = (int)((float)component2.Networkcost * ModConfig.GetTierUnitConfig(pickupTier).cost); } } else { component2.Networkcost = GetDifficultyScaledCost(cost); } BazaarItem bazaarItem = new BazaarItem(); bazaarItem.chestBehavior = spawnedInstance.GetComponent<ChestBehavior>(); bazaarItem.genericPickupController = val4.GetComponent<GenericPickupController>(); bazaarItem.pickupIndex = val3; bazaarItem.purchaseCount = 0; bazaarItem.maxPurchases = ModConfig.GetTierUnitConfig(pickupTier).maxChestPurchases; bazaarItems.Add(bazaarItem); } private IEnumerator DelayPickupIndexSetupForDisplayItems(GenericPickupController gpc_, PickupIndex rPickupIndex) { //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 (object)new WaitForSeconds(2f); gpc_.NetworkpickupIndex = rPickupIndex; } private List<PickupIndex> GetAvailableItems(PickupTier pickupTier) { return pickupTier switch { PickupTier.Tier1 => Run.instance.availableTier1DropList, PickupTier.Tier2 => Run.instance.availableTier2DropList, PickupTier.Tier3 => Run.instance.availableTier3DropList, PickupTier.Boss => Run.instance.availableBossDropList, PickupTier.Lunar => Run.instance.availableLunarItemDropList, PickupTier.Equipment => Run.instance.availableEquipmentDropList, PickupTier.LunarEquipment => Run.instance.availableLunarEquipmentDropList, _ => null, }; } private void SpawnMoneyLunarPod(Vector3 moneyPodPosition) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0013: 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_001b: 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) //IL_0036: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) SpawnCard val = Resources.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscLunarChest"); DirectorPlacementRule val2 = new DirectorPlacementRule(); val2.placementMode = (PlacementMode)0; moneyLunarPod = val.DoSpawn(moneyPodPosition, Quaternion.identity, new DirectorSpawnRequest(val, val2, Run.instance.runRNG)).spawnedInstance; PurchaseInteraction component = moneyLunarPod.GetComponent<PurchaseInteraction>(); component.costType = (CostTypeIndex)3; component.Networkcost = 1; displayItems.Add(moneyLunarPod); } private void FillBazaarItemPositionsAndRotations() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) bazaarItemPositions.Add(new Vector3(-99.1f, -26f, -54.6f)); bazaarItemPositions.Add(new Vector3(-95f, -26.2f, -57.7f)); bazaarItemPositions.Add(new Vector3(-90.9f, -26f, -60.7f)); bazaarItemPositions.Add(new Vector3(-86.5f, -26.2f, -63.8f)); bazaarItemPositions.Add(new Vector3(-82.3f, -25f, -67f)); bazaarItemPositions.Add(new Vector3(-78f, -24.7f, -70.3f)); bazaarItemRotations.Add(new Vector3(0f, 34.4f, 0f)); bazaarItemRotations.Add(new Vector3(0f, 35.2f, 0f)); bazaarItemRotations.Add(new Vector3(0f, 36f, 0f)); bazaarItemRotations.Add(new Vector3(0f, 37.4f, 0f)); bazaarItemRotations.Add(new Vector3(0f, 38.2f, 0f)); bazaarItemRotations.Add(new Vector3(0f, 37.2f, 0f)); } private List<PickupTier> PickRandomWeightedBazaarItemTiers(int bazaarItemAmount) { TierContainer tierContainer = new TierContainer(); List<PickupTier> list = new List<PickupTier>(); if (tierContainer.totalRarity == 0f) { return null; } for (int i = 0; i < bazaarItemAmount; i++) { double num = r.NextDouble() * (double)tierContainer.totalRarity; foreach (TemporaryTierUnit tierUnit in tierContainer.tierUnits) { if (num <= (double)tierUnit.rarity) { list.Add(tierUnit.pickupTier); break; } num -= (double)tierUnit.rarity; } } return list; } internal void ShareSuiteMoneyFix(Interactor activator, int money) { barrelInteraction.goldReward = money; barrelInteraction.expReward = 0u; barrelInteraction.OnInteractionBegin(activator); barrelInteraction.Networkopened = false; } private int GetDifficultyScaledCostFromItemTier(int baseCost) { return (int)((double)baseCost * (double)Mathf.Pow(CurrentDifficultyCoefficient, 1.25f)); } internal bool PlayerHasTierPurchasesLeft(PickupTier pickupTier, BazaarPlayer bazaarPlayer) { switch (pickupTier) { case PickupTier.Tier1: if (ModConfig.maxPlayerPurchasesTier1.Value == -1 || bazaarPlayer.tier1Purchases < ModConfig.maxPlayerPurchasesTier1.Value) { return true; } break; case PickupTier.Tier2: if (ModConfig.maxPlayerPurchasesTier2.Value == -1 || bazaarPlayer.tier2Purchases < ModConfig.maxPlayerPurchasesTier2.Value) { return true; } break; case PickupTier.Tier3: if (ModConfig.maxPlayerPurchasesTier3.Value == -1 || bazaarPlayer.tier3Purchases < ModConfig.maxPlayerPurchasesTier3.Value) { return true; } break; case PickupTier.Boss: if (ModConfig.maxPlayerPurchasesTierBoss.Value == -1 || bazaarPlayer.tierBossPurchases < ModConfig.maxPlayerPurchasesTierBoss.Value) { return true; } break; case PickupTier.Lunar: if (ModConfig.maxPlayerPurchasesTierLunar.Value == -1 || bazaarPlayer.tierLunarPurchases < ModConfig.maxPlayerPurchasesTierLunar.Value) { return true; } break; case PickupTier.Equipment: if (ModConfig.maxPlayerPurchasesTierEquipment.Value == -1 || bazaarPlayer.tierEquipmentPurchases < ModConfig.maxPlayerPurchasesTierEquipment.Value) { return true; } break; case PickupTier.LunarEquipment: if (ModConfig.maxPlayerPurchasesTierLunarEquipment.Value == -1 || bazaarPlayer.tierLunarEquipmentPurchases < ModConfig.maxPlayerPurchasesTierLunarEquipment.Value) { return true; } break; } return false; } private int GetDifficultyScaledCost(int baseCost) { return (int)((double)baseCost * (double)Mathf.Pow(CurrentDifficultyCoefficient, 1.25f)); } private uint GetDifficultyUnscaledCost(uint cost) { return (uint)((double)cost / (double)Mathf.Pow(CurrentDifficultyCoefficient, 1.25f)); } private void CreateBazaarPlayers() { for (int i = 0; i < PlayerCharacterMasterController.instances.Count; i++) { PlayerCharacterMasterController val = PlayerCharacterMasterController.instances[i]; BazaarPlayer item; if (!ModConfig.disableTransferMoney.Value) { item = new BazaarPlayer(val.networkUser, val.master.money); val.master.money = 0u; } else { item = new BazaarPlayer(val.networkUser, 0u); } bazaarPlayers.Add(item); } } public bool IsDisplayItem(GameObject gameObject) { if (displayItems.Contains(gameObject)) { return true; } return false; } public void ResetBazaarPlayers() { bazaarPlayers.Clear(); CreateBazaarPlayers(); } public List<BazaarItem> GetBazaarItems() { return bazaarItems; } public int GetBazaarItemAmount() { return bazaarItemAmount; } public bool IsChestStillAvailable(BazaarItem bazaarItem) { if (bazaarItem.maxPurchases == -1 || bazaarItem.purchaseCount < bazaarItem.maxPurchases) { return true; } return false; } public bool IsMoneyLunarPodAvailable() { return (Object)(object)moneyLunarPod != (Object)null; } public bool IsMoneyLunarPod(GameObject gameObject) { if ((Object)(object)moneyLunarPod != (Object)null && (Object)(object)gameObject == (Object)(object)((Component)moneyLunarPod.GetComponent<PurchaseInteraction>()).gameObject) { return true; } return false; } public bool IsMoneyLunarPod(Vector3 PodPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //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) Vector3 val = PodPosition - moneyPodPosition; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; float num = 3f; if (sqrMagnitude < num * num) { return true; } return false; } public bool PlayerHasPurchasesLeft(BazaarPlayer bazaarPlayer) { if (ModConfig.maxPlayerPurchases.Value > -1 && bazaarPlayer.chestPurchases >= ModConfig.maxPlayerPurchases.Value) { return false; } return true; } public BazaarPlayer GetBazaarPlayer(NetworkUser networkUser) { for (int i = 0; i < bazaarPlayers.Count; i++) { if ((Object)(object)bazaarPlayers[i].networkUser == (Object)(object)networkUser) { return bazaarPlayers[i]; } } return null; } public int GetLunarCoinExchangeMoney() { if (!isUsingexperimentalScaling) { return GetDifficultyScaledCost(ModConfig.lunarCoinWorth.Value); } return GetDifficultyScaledCost(priceScaledLunarPodBaseCost); } public List<BazaarPlayer> GetBazaarPlayers() { return bazaarPlayers; } private void ClearBazaarItems() { displayItems.Clear(); bazaarItems.Clear(); } public void StartBazaar(BiggerBazaar biggerBazaar) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) isUsingexperimentalScaling = false; if (!ModConfig.disableTransferMoney.Value) { for (int i = 0; i < PlayerCharacterMasterController.instances.Count; i++) { int num = 0; while (num < bazaarPlayers.Count) { if (!((Object)(object)bazaarPlayers[num].networkUser == (Object)(object)PlayerCharacterMasterController.instances[i].networkUser)) { num++; continue; } goto IL_004c; } continue; IL_004c: if (!ModConfig.IsShareSuiteMoneySharing()) { PlayerCharacterMasterController.instances[i].master.money = bazaarPlayers[num].money; continue; } ((MonoBehaviour)biggerBazaar).StartCoroutine(TriggerInteractorBarrelInteraction(PlayerCharacterMasterController.instances[i].master, (int)bazaarPlayers[num].money)); break; } } if (ModConfig.isShareSuiteLoaded) { SpawnCard val = Resources.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscBarrel1"); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(200f, 200f, 200f); DirectorPlacementRule val3 = new DirectorPlacementRule(); val3.placementMode = (PlacementMode)0; GameObject spawnedInstance = val.DoSpawn(val2, Quaternion.identity, new DirectorSpawnRequest(val, val3, Run.instance.runRNG)).spawnedInstance; barrelInteraction = spawnedInstance.GetComponent<BarrelInteraction>(); } ClearBazaarItems(); List<PickupTier> list = PickRandomWeightedBazaarItemTiers(bazaarItemAmount); if (!AreAnyItemsAvailable() || list == null) { return; } if (ModConfig.chestCostType.Value == 1) { for (int j = 0; j < list.Count; j++) { SpawnBazaarItemAt(bazaarItemPositions[j], bazaarItemRotations[j], list[j], ModConfig.GetTierUnitConfig(list[j]).costLunar, biggerBazaar); } } else { for (int k = 0; k < list.Count; k++) { SpawnBazaarItemAt(bazaarItemPositions[k], bazaarItemRotations[k], list[k], -1, biggerBazaar); } } if (ModConfig.maxLunarExchanges.Value != 0) { SpawnMoneyLunarPod(moneyPodPosition); } } [MethodImpl(MethodImplOptions.NoInlining)] private int GetShareSuiteSharedMoneyValue() { return MoneySharingHooks.SharedMoneyValue; } public static bool AreAnyItemsAvailable() { return Run.instance.availableTier1DropList.Count + Run.instance.availableTier2DropList.Count + Run.instance.availableTier3DropList.Count + Run.instance.availableBossDropList.Count + Run.instance.availableLunarItemDropList.Count + Run.instance.availableEquipmentDropList.Count + Run.instance.availableLunarEquipmentDropList.Count != 0; } public IEnumerator TriggerInteractorBarrelInteraction(CharacterMaster master, int money) { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)master.GetBody() != (Object)null)); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)((Component)master.GetBody()).gameObject.GetComponentInChildren<Interactor>() != (Object)null)); MoneySharingHooks.AddMoneyExternal(money); } public void CalcDifficultyCoefficient() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Run instance = Run.instance; float runStopwatch = instance.GetRunStopwatch(); DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(instance.selectedDifficulty); float num = Mathf.Floor(runStopwatch * (1f / 60f)); float num2 = (float)instance.participatingPlayerCount * 0.3f; float num3 = 0.7f + num2; float num4 = Mathf.Pow((float)instance.participatingPlayerCount, 0.2f); float num5 = 0.046f * difficultyDef.scalingValue * num4; _ = difficultyDef.scalingValue; float num6 = Mathf.Pow(1.15f, (float)instance.stageClearCount); CurrentDifficultyCoefficient = (num3 + num5 * num) * num6; } } internal class BazaarItem { public GenericPickupController genericPickupController; public ChestBehavior chestBehavior; public PickupIndex pickupIndex; public int purchaseCount; public int maxPurchases; } internal class BazaarPlayer { public uint money; public NetworkUser networkUser; public int lunarExchanges; public int chestPurchases; public int tier1Purchases; public int tier2Purchases; public int tier3Purchases; public int tierBossPurchases; public int tierLunarPurchases; public int tierEquipmentPurchases; public int tierLunarEquipmentPurchases; public BazaarPlayer(NetworkUser networkUser, uint money) { this.money = money; this.networkUser = networkUser; lunarExchanges = 0; chestPurchases = 0; tier1Purchases = 0; tier2Purchases = 0; tier3Purchases = 0; tierBossPurchases = 0; tierLunarPurchases = 0; tierEquipmentPurchases = 0; tierLunarEquipmentPurchases = 0; } internal void IncreaseTierPurchase(PickupTier pickupTier) { switch (pickupTier) { case PickupTier.Tier1: tier1Purchases++; break; case PickupTier.Tier2: tier2Purchases++; break; case PickupTier.Tier3: tier3Purchases++; break; case PickupTier.Boss: tierBossPurchases++; break; case PickupTier.Lunar: tierLunarPurchases++; break; case PickupTier.Equipment: tierEquipmentPurchases++; break; case PickupTier.LunarEquipment: tierLunarEquipmentPurchases++; break; } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.MagnusMagnuson.BiggerBazaar", "BiggerBazaar", "1.13.13")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class BiggerBazaar : BaseUnityPlugin { private Bazaar bazaar; private void Start() { foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos) { if (pluginInfo.Key == "com.funkfrog_sipondo.sharesuite") { ModConfig.SetShareSuiteReference(pluginInfo.Value.Instance); } else if (pluginInfo.Key == "com.Varna.EphemeralCoins") { ModConfig.SetEphemeralCoinsReference(pluginInfo.Value.Instance); } } } public void Awake() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown ModConfig.InitConfig(((BaseUnityPlugin)this).Config); bazaar = new Bazaar(); SceneExitController.Begin += new hook_Begin(SceneExitController_Begin); Run.AdvanceStage += new hook_AdvanceStage(Run_AdvanceStage); SceneDirector.Start += new hook_Start(SceneDirector_Start); PickupDisplay.SetPickupIndex += new hook_SetPickupIndex(PickupDisplay_SetPickupIndex); ChestBehavior.Open += new hook_Open(ChestBehavior_Open); ChestBehavior.PickFromList += new hook_PickFromList(ChestBehavior_PickFromList); PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(PurchaseInteraction_OnInteractionBegin); GenericPickupController.AttemptGrant += new hook_AttemptGrant(GenericPickupController_AttemptGrant); FireworkLauncher.FireMissile += new hook_FireMissile(FireworkLauncher_FireMissile); BazaarController.SetUpSeerStations += new hook_SetUpSeerStations(BazaarController_SetUpSeerStations); HackingMainState.PurchaseInteractionIsValidTarget += new hook_PurchaseInteractionIsValidTarget(HackingMainState_PurchaseInteractionIsValidTarget); } private bool HackingMainState_PurchaseInteractionIsValidTarget(orig_PurchaseInteractionIsValidTarget orig, PurchaseInteraction purchaseInteraction) { if (isCurrentStageBazaar()) { return false; } return orig.Invoke(purchaseInteraction); } private void SceneExitController_Begin(orig_Begin orig, SceneExitController self) { if (NetworkServer.active && Object.op_Implicit((Object)(object)self.destinationScene) && self.destinationScene.baseSceneName.Contains("bazaar") && !SceneInfo.instance.sceneDef.baseSceneName.Contains("bazaar")) { bazaar.ResetBazaarPlayers(); } orig.Invoke(self); } private void Run_AdvanceStage(orig_AdvanceStage orig, Run self, SceneDef nextScene) { if (!SceneExitController.isRunning && nextScene.baseSceneName == "bazaar") { bazaar.ResetBazaarPlayers(); } orig.Invoke(self, nextScene); } private void SceneDirector_Start(orig_Start orig, SceneDirector self) { if (NetworkServer.active) { if (isCurrentStageBazaar()) { ArtifactDef val = ArtifactCatalog.FindArtifactDef("Sacrifice"); bool flag = false; if (RunArtifactManager.instance.IsArtifactEnabled(val)) { if (!ModConfig.sacrificeArtifactAllowChests.Value) { orig.Invoke(self); } flag = true; RunArtifactManager.instance.SetArtifactEnabledServer(val, false); } if (Run.instance.stageClearCount == 0) { bazaar.ResetBazaarPlayers(); bazaar.CalcDifficultyCoefficient(); } bazaar.StartBazaar(this); if (flag) { RunArtifactManager.instance.SetArtifactEnabledServer(val, true); } if (ModConfig.BroadcastShopSettings.Value) { ((MonoBehaviour)this).StartCoroutine(BroadcastShopSettings()); } } else { bazaar.CurrentDifficultyCoefficient = Run.instance.difficultyCoefficient; } } orig.Invoke(self); } private void PickupDisplay_SetPickupIndex(orig_SetPickupIndex orig, PickupDisplay self, PickupIndex newPickupIndex, bool newHidden) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && isCurrentStageBazaar()) { List<BazaarItem> bazaarItems = bazaar.GetBazaarItems(); for (int i = 0; i < bazaarItems.Count; i++) { if ((Object)(object)bazaarItems[i].genericPickupController.pickupDisplay == (Object)(object)self) { orig.Invoke(self, bazaarItems[i].pickupIndex, newHidden); return; } } } orig.Invoke(self, newPickupIndex, newHidden); } private void ChestBehavior_Open(orig_Open orig, ChestBehavior self) { //IL_007a: 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) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && isCurrentStageBazaar()) { bool flag = false; if (!ModConfig.isShareSuiteLoaded || !ModConfig.isShareSuiteActive()) { if (!ModConfig.AddItemsDirectlyToInventory.Value) { flag = true; } } else if (ModConfig.ShareSuiteItemSharingEnabled.Value) { flag = true; } if (flag) { List<BazaarItem> bazaarItems = bazaar.GetBazaarItems(); for (int i = 0; i < bazaar.GetBazaarItemAmount(); i++) { if (((object)bazaarItems[i].chestBehavior).Equals((object?)self)) { PickupDropletController.CreatePickupDroplet(bazaarItems[i].pickupIndex, ((Component)self).transform.position + Vector3.up * 1.5f, Vector3.up * 20f + ((Component)self).transform.forward * 2f); bazaarItems[i].purchaseCount++; if (bazaar.IsChestStillAvailable(bazaarItems[i])) { ((Component)self).GetComponent<PurchaseInteraction>().SetAvailable(true); } return; } } } } orig.Invoke(self); } private void ChestBehavior_PickFromList(orig_PickFromList orig, ChestBehavior self, List<PickupIndex> dropList) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && isCurrentStageBazaar()) { foreach (BazaarItem bazaarItem in bazaar.GetBazaarItems()) { if ((Object)(object)bazaarItem.chestBehavior == (Object)(object)self) { List<PickupIndex> list = new List<PickupIndex> { bazaarItem.pickupIndex }; orig.Invoke(self, list); return; } } if (bazaar.IsMoneyLunarPod(((Component)self).gameObject)) { List<PickupIndex> list2 = new List<PickupIndex> { PickupIndex.none }; orig.Invoke(self, list2); return; } } orig.Invoke(self, dropList); } private void PurchaseInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Invalid comparison between Unknown and I4 //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Expected O, but got Unknown //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) int num2; List<BazaarItem> bazaarItems; CharacterMaster master2; int num3; if (isCurrentStageBazaar()) { NetworkUser val = Util.LookUpBodyNetworkUser(((Component)activator).gameObject); BazaarPlayer bazaarPlayer = bazaar.GetBazaarPlayer(val); if (!self.CanBeAffordedByInteractor(activator)) { return; } if (bazaar.IsMoneyLunarPodAvailable() && bazaar.IsMoneyLunarPod(((Component)self).gameObject)) { if (bazaarPlayer.lunarExchanges < ModConfig.maxLunarExchanges.Value || ModConfig.infiniteLunarExchanges) { bazaarPlayer.lunarExchanges++; int lunarCoinExchangeMoney = bazaar.GetLunarCoinExchangeMoney(); if (!ModConfig.IsShareSuiteMoneySharing()) { CharacterMaster master = ((Component)activator).GetComponent<CharacterBody>().master; master.money += (uint)lunarCoinExchangeMoney; } else { AddMoneyToShareSuitePool(lunarCoinExchangeMoney); } if (Object.op_Implicit((Object)(object)ModConfig.EphemeralCoins) && ModConfig.EphemeralCoins.GetPropertyValue<bool>("artifactEnabled")) { ModConfig.EphemeralCoins.InvokeMethod("takeCoinsFromUser", val, (uint)self.cost); } else { val.DeductLunarCoins((uint)self.cost); } int num = (int)((double)ModConfig.lunarCoinWorth.Value * (double)bazaar.CurrentDifficultyCoefficient); GameObject obj = Resources.Load<GameObject>("Prefabs/Effects/CoinEmitter"); EffectManager.SpawnEffect(obj, new EffectData { origin = ((Component)self).transform.position, genericFloat = num }, true); EffectManager.SpawnEffect(obj, new EffectData { origin = ((Component)self).transform.position, genericFloat = num }, true); Util.PlaySound("Play_UI_coin", ((Component)self).gameObject); } return; } num2 = -1; bazaarItems = bazaar.GetBazaarItems(); for (int i = 0; i < bazaarItems.Count; i++) { if ((Object)(object)bazaarItems[i].chestBehavior == (Object)null || !((object)((Component)bazaarItems[i].chestBehavior).GetComponent<PurchaseInteraction>()).Equals((object?)self)) { continue; } if (!bazaar.PlayerHasPurchasesLeft(bazaarPlayer)) { return; } PickupTier pickupTier = PickupIndexToPickupTier(bazaarItems[i].pickupIndex); if (!bazaar.PlayerHasTierPurchasesLeft(pickupTier, bazaarPlayer)) { return; } if ((Object)(object)ModConfig.ShareSuite != (Object)null && ModConfig.ShareSuiteTotalPurchaseSharing.Value) { bazaar.GetBazaarPlayers().ForEach(delegate(BazaarPlayer x) { x.chestPurchases++; }); } else { bazaarPlayer.chestPurchases++; } bazaarPlayer.IncreaseTierPurchase(pickupTier); num2 = i; break; } if (((ModConfig.isShareSuiteActive() && !ModConfig.ShareSuiteItemSharingEnabled.Value) || (!ModConfig.isShareSuiteActive() && ModConfig.AddItemsDirectlyToInventory.Value)) && num2 != -1) { master2 = ((Component)activator).GetComponent<CharacterBody>().master; if ((int)PickupCatalog.GetPickupDef(bazaarItems[num2].pickupIndex).equipmentIndex != -1) { num3 = 1; } else { num3 = 0; if (num3 == 0) { master2.inventory.GiveItem(PickupCatalog.GetPickupDef(bazaarItems[num2].pickupIndex).itemIndex, 1); goto IL_03b5; } } if ((ModConfig.isShareSuiteActive() && !ModConfig.isShareSuiteEquipmentSharing()) || (!ModConfig.isShareSuiteActive() && ModConfig.AddItemsDirectlyToInventory.Value)) { PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(master2.inventory.GetEquipmentIndex()), ((Component)master2.GetBody()).gameObject.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + ((Component)self).transform.forward * 2f); } master2.inventory.SetEquipmentIndex(PickupCatalog.GetPickupDef(bazaarItems[num2].pickupIndex).equipmentIndex); goto IL_03b5; } } orig.Invoke(self, activator); return; IL_03b5: if (ModConfig.chestCostType.Value == 1) { Util.LookUpBodyNetworkUser(master2.GetBody()).DeductLunarCoins((uint)self.cost); } else if (!ModConfig.IsShareSuiteMoneySharing()) { master2.money -= (uint)self.cost; } else { AddMoneyToShareSuitePool(-self.cost); } bazaarItems[num2].purchaseCount++; if (!bazaar.IsChestStillAvailable(bazaarItems[num2])) { ((Component)self).GetComponent<PurchaseInteraction>().SetAvailable(false); } Vector3 position = ((Component)self).transform.position; position.y -= 1f; EffectManager.SpawnEffect(Resources.Load<GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData { origin = position, rotation = Quaternion.identity, scale = 0.01f, color = Color32.op_Implicit(Color.yellow) }, true); if (num3 == 0) { PurchaseInteraction.CreateItemTakenOrb(((Component)self).gameObject.transform.position, ((Component)((Component)activator).GetComponent<CharacterBody>()).gameObject, PickupCatalog.GetPickupDef(bazaarItems[num2].pickupIndex).itemIndex); } else { PurchaseInteraction.CreateItemTakenOrb(((Component)self).gameObject.transform.position, ((Component)((Component)activator).GetComponent<CharacterBody>()).gameObject, PickupCatalog.GetPickupDef(bazaarItems[num2].pickupIndex).itemIndex); } } private void AddMoneyToShareSuitePool(int money) { MoneySharingHooks.AddMoneyExternal(money); } private void GenericPickupController_AttemptGrant(orig_AttemptGrant orig, GenericPickupController self, CharacterBody body) { if (!NetworkServer.active) { return; } if (isCurrentStageBazaar()) { if (!bazaar.IsDisplayItem(((Component)self).gameObject)) { orig.Invoke(self, body); } } else { orig.Invoke(self, body); } } private void FireworkLauncher_FireMissile(orig_FireMissile orig, FireworkLauncher self) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { if (isCurrentStageBazaar() && bazaar.IsMoneyLunarPod(((Component)self).gameObject.transform.position)) { self.remaining = 0; } else { orig.Invoke(self); } } } private bool isCurrentStageBazaar() { if ((Object)(object)SceneCatalog.mostRecentSceneDef == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("bazaar")) { return true; } return false; } private bool GenericPickupController_OnSerialize(orig_OnSerialize orig, GenericPickupController self, NetworkWriter writer, bool forceAll) { //IL_004b: 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) if (NetworkServer.active && isCurrentStageBazaar()) { List<BazaarItem> bazaarItems = bazaar.GetBazaarItems(); for (int i = 0; i < bazaarItems.Count; i++) { if (!((Object)(object)bazaarItems[i].genericPickupController == (Object)(object)self)) { continue; } if (forceAll) { GeneratedNetworkCode._WritePickupIndex_None(writer, bazaarItems[i].pickupIndex); writer.Write(self.Recycled); return true; } bool flag = false; if ((((Component)self).GetComponent<NetworkBehaviour>().GetFieldValue<uint>("m_SyncVarDirtyBits") & (true ? 1u : 0u)) != 0) { if (!flag) { writer.WritePackedUInt32(((Component)self).GetComponent<NetworkBehaviour>().GetFieldValue<uint>("m_SyncVarDirtyBits")); flag = true; } GeneratedNetworkCode._WritePickupIndex_None(writer, bazaarItems[i].pickupIndex); } if ((((Component)self).GetComponent<NetworkBehaviour>().GetFieldValue<uint>("m_SyncVarDirtyBits") & 2u) != 0) { if (!flag) { writer.WritePackedUInt32(((Component)self).GetComponent<NetworkBehaviour>().GetFieldValue<uint>("m_SyncVarDirtyBits")); flag = true; } writer.Write(self.Recycled); } if (!flag) { writer.WritePackedUInt32(((Component)self).GetComponent<NetworkBehaviour>().GetFieldValue<uint>("m_SyncVarDirtyBits")); } return flag; } } return orig.Invoke(self, writer, forceAll); } private void BazaarController_SetUpSeerStations(orig_SetUpSeerStations orig, BazaarController self) { orig.Invoke(self); if (ModConfig.modifyOriginalBazaar.Value) { SeerStationController[] seerStations = self.seerStations; for (int i = 0; i < seerStations.Length; i++) { ((Component)seerStations[i]).GetComponent<PurchaseInteraction>().Networkcost = ModConfig.seerLunarCost.Value; } ((MonoBehaviour)this).StartCoroutine(delayedPriceChangeLunarShop()); } } private IEnumerator delayedPriceChangeLunarShop() { yield return (object)new WaitForSeconds(2f); foreach (PurchaseInteraction instances in InstanceTracker.GetInstancesList<PurchaseInteraction>()) { if (((Object)instances).name.StartsWith("LunarShopTerminal") && instances.cost == 2) { instances.Networkcost = ModConfig.lunarBudLunarCost.Value; } } } private PickupTier PickupIndexToPickupTier(PickupIndex pickupIndex) { //IL_0000: 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_000c: Invalid comparison between Unknown and I4 //IL_0052: 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_0014: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected I4, but got Unknown if ((int)PickupCatalog.GetPickupDef(pickupIndex).equipmentIndex == -1 && 0 == 0) { ItemTier tier = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(pickupIndex).itemIndex).tier; return (int)tier switch { 0 => PickupTier.Tier1, 1 => PickupTier.Tier2, 2 => PickupTier.Tier3, 4 => PickupTier.Boss, 3 => PickupTier.Lunar, _ => PickupTier.None, }; } if (EquipmentCatalog.GetEquipmentDef(PickupCatalog.GetPickupDef(pickupIndex).equipmentIndex).isLunar) { return PickupTier.LunarEquipment; } return PickupTier.Equipment; } private IEnumerator BroadcastShopSettings() { yield return (object)new WaitForSeconds(2f); if (!Bazaar.AreAnyItemsAvailable()) { Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "No items available to spawn for Bigger Bazaar" }); yield break; } string text = ""; bool flag = false; string text2 = ""; if (ModConfig.maxChestPurchasesTier1.Value != -1) { flag = true; text2 = text2 + "<color=#FFFFFF>Tier1: " + ModConfig.maxChestPurchasesTier1.Value + "</color>"; } if (ModConfig.maxChestPurchasesTier2.Value != -1) { if (flag) { text2 += ", "; } flag = true; text2 = text2 + "<color=#08EB00>Tier2: " + ModConfig.maxChestPurchasesTier2.Value + "</color>"; } if (ModConfig.maxChestPurchasesTier3.Value != -1) { if (flag) { text2 += ", "; } flag = true; text2 = text2 + "<color=#FF0000>Tier3: " + ModConfig.maxChestPurchasesTier3.Value + "</color>"; } if (ModConfig.maxChestPurchasesTierBoss.Value != -1) { if (flag) { text2 += ", "; } flag = true; text2 = text2 + "<color=#EEF50B>Boss: " + ModConfig.maxChestPurchasesTierBoss.Value + "</color>"; } if (ModConfig.maxChestPurchasesTierLunar.Value != -1) { if (flag) { text2 += ", "; } flag = true; text2 = text2 + "<color=#5175DD>Lunar: " + ModConfig.maxChestPurchasesTierLunar.Value + "</color>"; } if (ModConfig.maxChestPurchasesTierEquipment.Value != -1) { if (flag) { text2 += ", "; } flag = true; text2 = text2 + "<color=#EC7E17>Equipment: " + ModConfig.maxChestPurchasesTierEquipment.Value + "</color>"; } if (ModConfig.maxChestPurchasesTierLunarEquipment.Value != -1) { if (flag) { text2 += ", "; } flag = true; text2 = text2 + "<color=#5175DD>Lunar Equipment: " + ModConfig.maxChestPurchasesTierLunarEquipment.Value + "</color>"; } if (flag) { text = text + "\nBazaar stock per chest by tier:\n" + text2 + "."; } bool flag2 = false; if (ModConfig.maxPlayerPurchases.Value != -1) { flag2 = true; text = ((!((Object)(object)ModConfig.ShareSuite != (Object)null) || !ModConfig.ShareSuiteTotalPurchaseSharing.Value) ? (text + "\nYou can buy a total of " + ModConfig.maxPlayerPurchases.Value + " items.") : (text + "\nYour party can buy a total of " + ModConfig.maxPlayerPurchases.Value + " items.")); } bool flag3 = false; string text3 = ""; if (ModConfig.maxPlayerPurchasesTier1.Value > 0) { flag3 = true; text3 = text3 + "<color=#FFFFFF>" + ModConfig.maxPlayerPurchasesTier1.Value + " Tier1</color>"; } if (ModConfig.maxPlayerPurchasesTier2.Value > 0) { if (flag3) { text3 += ", "; } flag3 = true; text3 = text3 + "<color=#08EB00>" + ModConfig.maxPlayerPurchasesTier2.Value + " Tier2</color>"; } if (ModConfig.maxPlayerPurchasesTier3.Value > 0) { if (flag3) { text3 += ", "; } flag3 = true; text3 = text3 + "<color=#FF0000>" + ModConfig.maxPlayerPurchasesTier3.Value + " Tier3</color>"; } if (ModConfig.maxPlayerPurchasesTierBoss.Value > 0) { if (flag3) { text3 += ", "; } flag3 = true; text3 = text3 + "<color=#EEF50B>" + ModConfig.maxPlayerPurchasesTierBoss.Value + " Boss</color>"; } if (ModConfig.maxPlayerPurchasesTierLunar.Value > 0) { if (flag3) { text3 += ", "; } flag3 = true; text3 = text3 + "<color=#5175DD>" + ModConfig.maxPlayerPurchasesTierLunar.Value + " Lunar</color>"; } if (ModConfig.maxPlayerPurchasesTierEquipment.Value > 0) { if (flag3) { text3 += ", "; } flag3 = true; text3 = text3 + "<color=#EC7E17>" + ModConfig.maxPlayerPurchasesTierEquipment.Value + " Equipment</color>"; } if (ModConfig.maxPlayerPurchasesTierLunarEquipment.Value > 0) { if (flag3) { text3 += ", "; } flag3 = true; text3 = text3 + "<color=#5175DD>" + ModConfig.maxPlayerPurchasesTierLunarEquipment.Value + " Lunar Equipment</color>"; } if (flag3) { text3 = "\nYou can only buy up to " + text3 + " items."; text += text3; } text = "--Bazaar Restrictions--<color=#BCBCBC><size=16px>" + text + "</size></color>"; if (flag2 || flag3 || flag) { Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = text }); } } } internal class ModConfig { public struct TierUnitConfig { public float rarity; public float cost; public int costLunar; public int maxChestPurchases; } public static ConfigEntry<int> lunarCoinWorth; public static ConfigEntry<int> maxLunarExchanges; public static ConfigEntry<int> chestAmount; public static ConfigEntry<int> chestCostType; public static ConfigEntry<float> tier1Cost; public static ConfigEntry<float> tier2Cost; public static ConfigEntry<float> tier3Cost; public static ConfigEntry<float> tierBossCost; public static ConfigEntry<float> tierLunarCost; public static ConfigEntry<float> tierEquipmentCost; public static ConfigEntry<float> tierLunarEquipmentCost; public static ConfigEntry<float> tier1Rarity; public static ConfigEntry<float> tier2Rarity; public static ConfigEntry<float> tier3Rarity; public static ConfigEntry<float> tierBossRarity; public static ConfigEntry<float> tierLunarRarity; public static ConfigEntry<float> tierEquipmentRarity; public static ConfigEntry<float> tierLunarEquipmentRarity; public static ConfigEntry<int> maxChestPurchasesTier1; public static ConfigEntry<int> maxChestPurchasesTier2; public static ConfigEntry<int> maxChestPurchasesTier3; public static ConfigEntry<int> maxChestPurchasesTierBoss; public static ConfigEntry<int> maxChestPurchasesTierLunar; public static ConfigEntry<int> maxChestPurchasesTierEquipment; public static ConfigEntry<int> maxChestPurchasesTierLunarEquipment; public static ConfigEntry<int> maxPlayerPurchases; public static ConfigEntry<int> maxPlayerPurchasesTier1; public static ConfigEntry<int> maxPlayerPurchasesTier2; public static ConfigEntry<int> maxPlayerPurchasesTier3; public static ConfigEntry<int> maxPlayerPurchasesTierBoss; public static ConfigEntry<int> maxPlayerPurchasesTierLunar; public static ConfigEntry<int> maxPlayerPurchasesTierEquipment; public static ConfigEntry<int> maxPlayerPurchasesTierLunarEquipment; public static ConfigEntry<bool> BroadcastShopSettings; public static ConfigEntry<bool> AddItemsDirectlyToInventory; public static ConfigEntry<bool> ShareSuiteItemSharingEnabled; public static ConfigEntry<bool> ShareSuiteTotalPurchaseSharing; public static ConfigEntry<bool> sacrificeArtifactAllowChests; public static bool infiniteLunarExchanges = false; public static bool isShareSuiteLoaded; public static ConfigEntry<bool> modifyOriginalBazaar; public static ConfigEntry<int> seerLunarCost; public static ConfigEntry<int> lunarBudLunarCost; public static ConfigEntry<int> tier1CostLunar; public static ConfigEntry<int> tier2CostLunar; public static ConfigEntry<int> tier3CostLunar; public static ConfigEntry<int> tierBossCostLunar; public static ConfigEntry<int> tierLunarCostLunar; public static ConfigEntry<int> tierEquipmentCostLunar; public static ConfigEntry<int> tierLunarEquipmentCostLunar; public static ConfigEntry<bool> disableTransferMoney; public static ConfigEntry<bool> nextLevelChestPriceScaling; public static ConfigEntry<int> configNumber; public static BaseUnityPlugin ShareSuite; public static BaseUnityPlugin EphemeralCoins; public static Dictionary<PickupTier, TierUnitConfig> tierConfigs = new Dictionary<PickupTier, TierUnitConfig>(); private static readonly int CurrentVersionNumber = 2; public static void InitConfig(ConfigFile config) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Expected O, but got Unknown //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Expected O, but got Unknown //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Expected O, but got Unknown //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Expected O, but got Unknown //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Expected O, but got Unknown //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Expected O, but got Unknown //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Expected O, but got Unknown //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Expected O, but got Unknown //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Expected O, but got Unknown //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Expected O, but got Unknown //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Expected O, but got Unknown //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Expected O, but got Unknown //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Expected O, but got Unknown //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Expected O, but got Unknown //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Expected O, but got Unknown //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Expected O, but got Unknown //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Expected O, but got Unknown //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Expected O, but got Unknown //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Expected O, but got Unknown //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Expected O, but got Unknown //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Expected O, but got Unknown //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Expected O, but got Unknown //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_0683: Expected O, but got Unknown //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Expected O, but got Unknown //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Expected O, but got Unknown //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Expected O, but got Unknown //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Expected O, but got Unknown //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_074b: Expected O, but got Unknown //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Expected O, but got Unknown //IL_078d: Unknown result type (might be due to invalid IL or missing references) //IL_0797: Expected O, but got Unknown //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07bd: Expected O, but got Unknown //IL_07d9: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Expected O, but got Unknown chestCostType = config.Bind<int>("0. Config", "chestCostType", 0, new ConfigDescription("Set the chests cost type to either gold (0) or lunar coins (1).", (AcceptableValueBase)null, Array.Empty<object>())); BroadcastShopSettings = config.Bind<bool>("0. Config", "BroadcastShopSettings", true, new ConfigDescription("Lets everyone know how many things they can purchase on bazaar entry.", (AcceptableValueBase)null, Array.Empty<object>())); lunarCoinWorth = config.Bind<int>("0. Config", "lunarCoinWorth", 50, new ConfigDescription("Conversion rate for Lunar Coins to Money. Conversion rate automatically scales with difficulty, meaning if you set this at the base price of a medium chest (50), you will always get enough money to buy a tier 2 item. (Reference: Small chest = 25, Medium Chest = 50, Legendary Chest = 400)\nIf you change the item tier prices, you might have to adjust this value.", (AcceptableValueBase)null, Array.Empty<object>())); maxLunarExchanges = config.Bind<int>("0. Config", "maxLunarExchanges", 3, new ConfigDescription("Sets how many Lunar Coin exchanges for money are allowed per player. A value of 0 will never allow an exchange. A value of -1 allows infinite exchanges.", (AcceptableValueBase)null, Array.Empty<object>())); if (maxLunarExchanges.Value == -1) { infiniteLunarExchanges = true; } chestAmount = config.Bind<int>("0. Config", "chestAmount", 6, new ConfigDescription("Adjust the amount of chests spawned. Minimum amount is 1, maximum amount is 6", (AcceptableValueBase)null, Array.Empty<object>())); AddItemsDirectlyToInventory = config.Bind<bool>("0. Config", "AddItemsDirectlyToInventory", false, new ConfigDescription("Adds bought items directly to your inventory instead of dropping them on the floor. This works just like ShareSuiteItemSharingEnabled when using ShareSuite, but is a seperate option for when not using ShareSuite.", (AcceptableValueBase)null, Array.Empty<object>())); tier1Cost = config.Bind<float>("1. TierCost", "tier1ChestCostMulti", 1f, new ConfigDescription("Set the base cost multiplier for tier 1 items (white). This scales automatically with difficulty and player amount.\nA value of 1 means that these items will cost as much as a small chest in the prior stage (the one you opened the shop portal in) \n(Default value: 1)", (AcceptableValueBase)null, Array.Empty<object>())); tier2Cost = config.Bind<float>("1. TierCost", "tier2ChestCostMulti", 2f, new ConfigDescription("Set the base cost multiplier for tier 2 items (green). This scales automatically with difficulty and player amount.\nA value of 2 means that these items will cost as much as a medium chest in the prior stage (the one you opened the shop portal in) \n(Default value: 2)", (AcceptableValueBase)null, Array.Empty<object>())); tier3Cost = config.Bind<float>("1. TierCost", "tier3ChestCostMulti", 16f, new ConfigDescription("Set the base cost multiplier for tier 3 items (red). This scales automatically with difficulty and player amount.\nA value of 16 means that these items will cost as much as a legendary chest in the prior stage (the one you opened the shop portal in) \n(Default value: 16)", (AcceptableValueBase)null, Array.Empty<object>())); tierBossCost = config.Bind<float>("1. TierCost", "tierBossCostMulti", 24f, new ConfigDescription("Set the base cost multiplier for boss tier items (yellow). This scales automatically with difficulty and player amount. (Default value: 24, untested)", (AcceptableValueBase)null, Array.Empty<object>())); tierLunarCost = config.Bind<float>("1. TierCost", "tierLunarCostMulti", 16f, new ConfigDescription("Set the base cost multiplier for lunar tier items (blue). This scales automatically with difficulty and player amount. (Default value: 16, untested)", (AcceptableValueBase)null, Array.Empty<object>())); tierEquipmentCost = config.Bind<float>("1. TierCost", "tierEquipmentCostMulti", 8f, new ConfigDescription("Set the base cost multiplier for equipment tier items (orange). This scales automatically with difficulty and player amount. (Default value: 8, untested)", (AcceptableValueBase)null, Array.Empty<object>())); tierLunarEquipmentCost = config.Bind<float>("1. TierCost", "tierLunarEquipmentCostMulti", 16f, new ConfigDescription("Set the base cost multiplier for lunar equipment tier items (blue). This scales automatically with difficulty and player amount. (Default value: 16, untested)", (AcceptableValueBase)null, Array.Empty<object>())); tier1Rarity = config.Bind<float>("2. TierRarity", "tier1Rarity", 0.55f, new ConfigDescription("Set the rarity of items/equipment for each tier. Higher value compared to the other tiers means that tier is more likely to appear (weighted random).\nDoes not need to add up to 1. Values are relative.\nSet a tier rarity to 0 if you don't want any items of that tier to appear.\n(Default values: 0.55, 0.3, 0.15, 0, 0, 0, 0)\n", (AcceptableValueBase)null, Array.Empty<object>())); tier2Rarity = config.Bind<float>("2. TierRarity", "tier2Rarity", 0.3f, new ConfigDescription("", (AcceptableValueBase)null, Array.Empty<object>())); tier3Rarity = config.Bind<float>("2. TierRarity", "tier3Rarity", 0.15f, new ConfigDescription("", (AcceptableValueBase)null, Array.Empty<object>())); tierBossRarity = config.Bind<float>("2. TierRarity", "tierBossRarity", 0f, new ConfigDescription("", (AcceptableValueBase)null, Array.Empty<object>())); tierLunarRarity = config.Bind<float>("2. TierRarity", "tierLunarRarity", 0f, new ConfigDescription("", (AcceptableValueBase)null, Array.Empty<object>())); tierEquipmentRarity = config.Bind<float>("2. TierRarity", "tierEquipmentRarity", 0f, new ConfigDescription("", (AcceptableValueBase)null, Array.Empty<object>())); tierLunarEquipmentRarity = config.Bind<float>("2. TierRarity", "tierLunarEquipmentRarity", 0f, new ConfigDescription("", (AcceptableValueBase)null, Array.Empty<object>())); maxChestPurchasesTier1 = config.Bind<int>("3. ChestPurchaseLimits", "maxChestPurchasesTier1", 3, new ConfigDescription("How often you can buy an item before a chest of this tier runs out/becomes unavailable.\nSet -1 for infinite purchases.\n\nTier 1", (AcceptableValueBase)null, Array.Empty<object>())); maxChestPurchasesTier2 = config.Bind<int>("3. ChestPurchaseLimits", "maxChestPurchasesTier2", 2, new ConfigDescription("Tier 2", (AcceptableValueBase)null, Array.Empty<object>())); maxChestPurchasesTier3 = config.Bind<int>("3. ChestPurchaseLimits", "maxChestPurchasesTier3", 1, new ConfigDescription("Tier 3", (AcceptableValueBase)null, Array.Empty<object>())); maxChestPurchasesTierBoss = config.Bind<int>("3. ChestPurchaseLimits", "maxChestPurchasesTierBoss", 1, new ConfigDescription("Tier Boss", (AcceptableValueBase)null, Array.Empty<object>())); maxChestPurchasesTierLunar = config.Bind<int>("3. ChestPurchaseLimits", "maxChestPurchasesTierLunar", 1, new ConfigDescription("Tier Lunar", (AcceptableValueBase)null, Array.Empty<object>())); maxChestPurchasesTierEquipment = config.Bind<int>("3. ChestPurchaseLimits", "maxChestPurchasesTierEquipment", 1, new ConfigDescription("Tier Equipment", (AcceptableValueBase)null, Array.Empty<object>())); maxChestPurchasesTierLunarEquipment = config.Bind<int>("3. ChestPurchaseLimits", "maxChestPurchasesTierLunarEquipment", 1, new ConfigDescription("Tier Lunar Equipment", (AcceptableValueBase)null, Array.Empty<object>())); maxPlayerPurchases = config.Bind<int>("4. PlayerPurchaseLimits", "maxPlayerPurchases", 3, new ConfigDescription("This sets how many total purchases a player is allowed to make per bazaar visit. Set this to -1 for unlimited.", (AcceptableValueBase)null, Array.Empty<object>())); maxPlayerPurchasesTier1 = config.Bind<int>("4. PlayerPurchaseLimits", "maxPlayerPurchasesTier1", -1, new ConfigDescription("This sets how many tier 1 (white) items a player can buy in total, per bazaar visit. Set this to -1 for unlimited.", (AcceptableValueBase)null, Array.Empty<object>())); maxPlayerPurchasesTier2 = config.Bind<int>("4. PlayerPurchaseLimits", "maxPlayerPurchasesTier2", -1, new ConfigDescription("This sets how many tier 2 (green) items a player can buy in total, per bazaar visit. Set this to -1 for unlimited.", (AcceptableValueBase)null, Array.Empty<object>())); maxPlayerPurchasesTier3 = config.Bind<int>("4. PlayerPurchaseLimits", "maxPlayerPurchasesTier3", -1, new ConfigDescription("This sets how many tier 3 (red) items a player can buy in total, per bazaar visit. Set this to -1 for unlimited.", (AcceptableValueBase)null, Array.Empty<object>())); maxPlayerPurchasesTierBoss = config.Bind<int>("4. PlayerPurchaseLimits", "maxPlayerPurchasesTierBoss", -1, new ConfigDescription("This sets how many boss tier (yellow) items a player can buy in total, per bazaar visit. Set this to -1 for unlimited.", (AcceptableValueBase)null, Array.Empty<object>())); maxPlayerPurchasesTierLunar = config.Bind<int>("4. PlayerPurchaseLimits", "maxPlayerPurchasesTierLunar", -1, new ConfigDescription("This sets how many lunar tier (blue) items a player can buy in total, per bazaar visit. Set this to -1 for unlimited.", (AcceptableValueBase)null, Array.Empty<object>())); maxPlayerPurchasesTierEquipment = config.Bind<int>("4. PlayerPurchaseLimits", "maxPlayerPurchasesTierEquipment", -1, new ConfigDescription("This sets how many equipment (orange) items a player can buy in total, per bazaar visit. Set this to -1 for unlimited.", (AcceptableValueBase)null, Array.Empty<object>())); maxPlayerPurchasesTierLunarEquipment = config.Bind<int>("4. PlayerPurchaseLimits", "maxPlayerPurchasesTierLunarEquipment", -1, new ConfigDescription("This sets how many lunar equipment (blue) items a player can buy in total, per bazaar visit. Set this to -1 for unlimited.", (AcceptableValueBase)null, Array.Empty<object>())); tier1CostLunar = config.Bind<int>("5. LunarModePricing", "tier1ChestCostLunar", 1, new ConfigDescription("Sets how many lunar coins a tier 1 (white) item costs", (AcceptableValueBase)null, Array.Empty<object>())); tier2CostLunar = config.Bind<int>("5. LunarModePricing", "tier2ChestCostLunar", 2, new ConfigDescription("Sets how many lunar coins a tier 2 (green) item costs", (AcceptableValueBase)null, Array.Empty<object>())); tier3CostLunar = config.Bind<int>("5. LunarModePricing", "tier3ChestCostLunar", 3, new ConfigDescription("Sets how many lunar coins a tier 3 (red) item costs", (AcceptableValueBase)null, Array.Empty<object>())); tierBossCostLunar = config.Bind<int>("5. LunarModePricing", "tierBossCostLunar", 5, new ConfigDescription("Sets how many lunar coins a boss (yellow) item costs", (AcceptableValueBase)null, Array.Empty<object>())); tierLunarCostLunar = config.Bind<int>("5. LunarModePricing", "tierLunarCostLunar", 3, new ConfigDescription("Sets how many lunar coins a lunar (blue) item costs", (AcceptableValueBase)null, Array.Empty<object>())); tierEquipmentCostLunar = config.Bind<int>("5. LunarModePricing", "tierEquipmentCostLunar", 3, new ConfigDescription("Sets how many lunar coins equipment (orange) costs", (AcceptableValueBase)null, Array.Empty<object>())); tierLunarEquipmentCostLunar = config.Bind<int>("5. LunarModePricing", "tierLunarEquipmentCostLunar", 3, new ConfigDescription("Sets how many lunar coins lunar equipment (blue) costs", (AcceptableValueBase)null, Array.Empty<object>())); ShareSuiteItemSharingEnabled = config.Bind<bool>("6. ShareSuite", "ShareSuiteItemSharingEnabled", true, new ConfigDescription("This option is only relevant if you are using ShareSuite, otherwise ignore. \nSetting this to false, will disable item sharing for Bigger Bazaar items and put items directly into the buyers inventory. Set to true if you want the item to drop on the floor and use ShareSuite's item sharing rules.", (AcceptableValueBase)null, Array.Empty<object>())); ShareSuiteTotalPurchaseSharing = config.Bind<bool>("6. ShareSuite", "ShareSuiteTotalPurchaseSharing", true, new ConfigDescription("This option is only relevant if you are using ShareSuite, otherwise ignore. \nSets the total amount of available purchases (maxPlayerPurchases in this config) to count for the whole party, rather than individual players.\nThis makes sense if you're sharing money and items.", (AcceptableValueBase)null, Array.Empty<object>())); isShareSuiteLoaded = IsShareSuiteLoaded(); sacrificeArtifactAllowChests = config.Bind<bool>("7. Sacrifice Artifact", "sacrificeArtifactAllowChests", true, new ConfigDescription("Prevents the Sacrifice Artifact from removing the chests in the bazaar.", (AcceptableValueBase)null, Array.Empty<object>())); modifyOriginalBazaar = config.Bind<bool>("8. Original Bazaar Modifications", "modifyOriginalBazaar", false, new ConfigDescription("If enabled, you can change the lunar cost of seer stations and lunar pods.", (AcceptableValueBase)null, Array.Empty<object>())); seerLunarCost = config.Bind<int>("8. Original Bazaar Modifications", "seerLunarCost", 3, new ConfigDescription("Set the lunar cost for seer stations.", (AcceptableValueBase)null, Array.Empty<object>())); lunarBudLunarCost = config.Bind<int>("8. Original Bazaar Modifications", "lunarBudLunarCost", 2, new ConfigDescription("Set the lunar cost for lunar buds.", (AcceptableValueBase)null, Array.Empty<object>())); disableTransferMoney = config.Bind<bool>("9. Other", "disableTransferMoney", false, new ConfigDescription("If set to true, no money will be transfered to the bazaar.", (AcceptableValueBase)null, Array.Empty<object>())); nextLevelChestPriceScaling = config.Bind<bool>("9. Other", "nextLevelChestPriceScaling", false, new ConfigDescription("If set to true, chest prices will be calculated based on how much things cost in the next stage, rather than the previous.", (AcceptableValueBase)null, Array.Empty<object>())); configNumber = config.Bind<int>("z_config version", "config version", 0, new ConfigDescription("No need to touch this", (AcceptableValueBase)null, Array.Empty<object>())); CreateTierConfigs(); if (configNumber.Value == 1) { UpdateTierCostToMulti(config); } if (configNumber.Value < CurrentVersionNumber) { DeleteOldEntries(config); } } private static void UpdateTierCostToMulti(ConfigFile config) { Dictionary<ConfigDefinition, string> obj = (Dictionary<ConfigDefinition, string>)typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(config); new List<KeyValuePair<ConfigDefinition, string>>(); foreach (KeyValuePair<ConfigDefinition, string> item in obj) { if (item.Key.Section == "1. TierCost") { switch (item.Key.Key) { case "tier1ChestCost": tier1Cost.Value = int.Parse(item.Value) / 25; break; case "tier2ChestCost": tier2Cost.Value = int.Parse(item.Value) / 25; break; case "tier3ChestCost": tier3Cost.Value = int.Parse(item.Value) / 25; break; case "tierBossCost": tierBossCost.Value = int.Parse(item.Value) / 25; break; case "tierLunarCost": tierLunarCost.Value = int.Parse(item.Value) / 25; break; case "tierEquipmentCost": tierEquipmentCost.Value = int.Parse(item.Value) / 25; break; case "tierLunarEquipmentCost": tierLunarEquipmentCost.Value = int.Parse(item.Value) / 25; break; } config.Save(); } } } private static void DeleteOldEntries(ConfigFile config) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(config); List<KeyValuePair<ConfigDefinition, string>> list = new List<KeyValuePair<ConfigDefinition, string>>(); foreach (KeyValuePair<ConfigDefinition, string> item in dictionary) { if (item.Key.Section == "Config" || item.Key.Section == "PlayerPurchaseLimits") { list.Add(item); } } dictionary.Clear(); foreach (KeyValuePair<ConfigDefinition, string> item2 in list) { dictionary.Add(new ConfigDefinition("z_backup_config (delete if you dont need it)", item2.Key.Key), item2.Value); } configNumber.Value = CurrentVersionNumber; config.Save(); } internal static bool isShareSuiteActive() { if (isShareSuiteLoaded) { return ShareSuite.GetFieldValue<ConfigEntry<bool>>("ModIsEnabled").Value; } return false; } private static bool IsShareSuiteLoaded() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { if (assemblies[i].FullName.StartsWith("ShareSuite")) { return true; } } return false; } internal static void SetShareSuiteReference(BaseUnityPlugin ShareSuiteInstance) { ShareSuite = ShareSuiteInstance; IsShareSuiteMoneySharing(); } internal static void SetEphemeralCoinsReference(BaseUnityPlugin EphemeralCoinsInstance) { EphemeralCoins = EphemeralCoinsInstance; } public static bool IsShareSuiteMoneySharing() { bool result = false; if ((Object)(object)ShareSuite != (Object)null) { if (!isShareSuiteActive()) { return false; } if (PlayerCharacterMasterController.instances.Count == 1 && !ShareSuite.GetFieldValue<ConfigEntry<bool>>("OverrideMultiplayerCheck").Value) { return false; } result = ShareSuite.GetFieldValue<ConfigEntry<bool>>("MoneyIsShared").Value; } return result; } public static bool isShareSuiteEquipmentSharing() { bool result = false; if ((Object)(object)ShareSuite != (Object)null) { if (!isShareSuiteActive()) { return false; } result = ShareSuite.GetFieldValue<ConfigEntry<bool>>("EquipmentShared").Value; } return result; } private static void CreateTierConfigs() { TierUnitConfig tierUnitConfig = default(TierUnitConfig); tierUnitConfig.cost = tier1Cost.Value; tierUnitConfig.costLunar = tier1CostLunar.Value; tierUnitConfig.rarity = tier1Rarity.Value; tierUnitConfig.maxChestPurchases = maxChestPurchasesTier1.Value; TierUnitConfig value = tierUnitConfig; tierConfigs.Add(PickupTier.Tier1, value); tierUnitConfig = default(TierUnitConfig); tierUnitConfig.cost = tier2Cost.Value; tierUnitConfig.costLunar = tier2CostLunar.Value; tierUnitConfig.rarity = tier2Rarity.Value; tierUnitConfig.maxChestPurchases = maxChestPurchasesTier2.Value; TierUnitConfig value2 = tierUnitConfig; tierConfigs.Add(PickupTier.Tier2, value2); tierUnitConfig = default(TierUnitConfig); tierUnitConfig.cost = tier3Cost.Value; tierUnitConfig.costLunar = tier3CostLunar.Value; tierUnitConfig.rarity = tier3Rarity.Value; tierUnitConfig.maxChestPurchases = maxChestPurchasesTier3.Value; TierUnitConfig value3 = tierUnitConfig; tierConfigs.Add(PickupTier.Tier3, value3); tierUnitConfig = default(TierUnitConfig); tierUnitConfig.cost = tierBossCost.Value; tierUnitConfig.costLunar = tierBossCostLunar.Value; tierUnitConfig.rarity = tierBossRarity.Value; tierUnitConfig.maxChestPurchases = maxChestPurchasesTierBoss.Value; TierUnitConfig value4 = tierUnitConfig; tierConfigs.Add(PickupTier.Boss, value4); tierUnitConfig = default(TierUnitConfig); tierUnitConfig.cost = tierLunarCost.Value; tierUnitConfig.costLunar = tierLunarCostLunar.Value; tierUnitConfig.rarity = tierLunarRarity.Value; tierUnitConfig.maxChestPurchases = maxChestPurchasesTierLunar.Value; TierUnitConfig value5 = tierUnitConfig; tierConfigs.Add(PickupTier.Lunar, value5); tierUnitConfig = default(TierUnitConfig); tierUnitConfig.cost = tierEquipmentCost.Value; tierUnitConfig.costLunar = tierEquipmentCostLunar.Value; tierUnitConfig.rarity = tierEquipmentRarity.Value; tierUnitConfig.maxChestPurchases = maxChestPurchasesTierEquipment.Value; TierUnitConfig value6 = tierUnitConfig; tierConfigs.Add(PickupTier.Equipment, value6); tierUnitConfig = default(TierUnitConfig); tierUnitConfig.cost = tierLunarEquipmentCost.Value; tierUnitConfig.costLunar = tierLunarEquipmentCostLunar.Value; tierUnitConfig.rarity = tierLunarEquipmentRarity.Value; tierUnitConfig.maxChestPurchases = maxChestPurchasesTierLunarEquipment.Value; TierUnitConfig value7 = tierUnitConfig; tierConfigs.Add(PickupTier.LunarEquipment, value7); } public static TierUnitConfig GetTierUnitConfig(PickupTier pickupTier) { return tierConfigs[pickupTier]; } } public enum PickupTier { Tier1, Tier2, Tier3, Lunar, Boss, Equipment, LunarEquipment, None } public static class Reflection { private delegate T GetDelegate<out T>(object instance); private delegate void SetDelegate<in T>(object instance, T value); private delegate void SetDelegateRef<TInstance, in TValue>(ref TInstance instance, TValue value) where TInstance : struct; private delegate T GetDelegateRef<TInstance, out T>(ref TInstance instance) where TInstance : struct; private const BindingFlags AllFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly ConcurrentDictionary<(Type T, string name), FieldInfo> FieldCache = new ConcurrentDictionary<(Type, string), FieldInfo>(); private static readonly ConcurrentDictionary<FieldInfo, Delegate> FieldGetDelegateCache = new ConcurrentDictionary<FieldInfo, Delegate>(); private static readonly ConcurrentDictionary<FieldInfo, Delegate> FieldSetDelegateCache = new ConcurrentDictionary<FieldInfo, Delegate>(); private static readonly ConcurrentDictionary<(Type T, string name), PropertyInfo> PropertyCache = new ConcurrentDictionary<(Type, string), PropertyInfo>(); private static readonly ConcurrentDictionary<PropertyInfo, Delegate> PropertyGetDelegateCache = new ConcurrentDictionary<PropertyInfo, Delegate>(); private static readonly ConcurrentDictionary<PropertyInfo, Delegate> PropertySetDelegateCache = new ConcurrentDictionary<PropertyInfo, Delegate>(); private static readonly ConcurrentDictionary<(Type T, string name), MethodInfo> MethodCache = new ConcurrentDictionary<(Type, string), MethodInfo>(); private static readonly ConcurrentDictionary<(Type T, string name, Type[] argumentTypes), MethodInfo> OverloadedMethodCache = new ConcurrentDictionary<(Type, string, Type[]), MethodInfo>(); private static readonly ConcurrentDictionary<MethodInfo, FastReflectionDelegate> DelegateCache = new ConcurrentDictionary<MethodInfo, FastReflectionDelegate>(); private static readonly ConcurrentDictionary<(Type T, Type[] argumentTypes), ConstructorInfo> ConstructorCache = new ConcurrentDictionary<(Type, Type[]), ConstructorInfo>(); private static readonly ConcurrentDictionary<(Type T, string name), Type> NestedTypeCache = new ConcurrentDictionary<(Type, string), Type>(); private static TValue GetOrAddOnNull<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, TKey key, Func<TKey, TValue> factory) { if (dict.TryGetValue(key, out var value) && value != null) { return value; } return dict[key] = factory(key); } public static FieldInfo GetFieldCached<T>(string name) { return typeof(T).GetFieldCached(name); } public static FieldInfo GetFieldCached(this Type T, string name) { return FieldCache.GetOrAddOnNull((T, name), ((Type T, string name) x) => x.T.GetFieldFull(x.name) ?? throw new Exception("Could not find FieldInfo on " + T.FullName + " with the name " + name)); } public static TReturn GetFieldValue<TReturn>(this object instance, string fieldName) { return instance.GetType().GetFieldCached(fieldName).GetFieldGetDelegate<TReturn>()(instance); } public static TReturn GetFieldValue<TReturn>(this Type staticType, string fieldName) { return staticType.GetFieldCached(fieldName).GetFieldGetDelegate<TReturn>()(null); } public static void SetFieldValue<TValue>(this object instance, string fieldName, TValue value) { instance.GetType().GetFieldCached(fieldName).GetFieldSetDelegate<TValue>()(instance, value); } public static void SetFieldValue<TValue>(this Type staticType, string fieldName, TValue value) { staticType.GetFieldCached(fieldName).GetFieldSetDelegate<TValue>()(null, value); } public static void SetStructFieldValue<TInstance, TValue>(this ref TInstance instance, string fieldName, TValue value) where TInstance : struct { typeof(TInstance).GetFieldCached(fieldName).GetFieldSetDelegateRef<TInstance, TValue>()(ref instance, value); } private static FieldInfo GetFieldFull(this Type T, string name) { while (T != null) { FieldInfo field = T.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return field; } T = T.BaseType; } return null; } private static T GetMemberFull<T>(this Type type, string name) where T : MemberInfo { while (type != null) { MemberInfo[] member = type.GetMember(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (member != null) { return (T)member.First(); } type = type.BaseType; } return null; } private static GetDelegate<TReturn> GetFieldGetDelegate<TReturn>(this FieldInfo field) { return Extensions.CastDelegate<GetDelegate<TReturn>>(FieldGetDelegateCache.GetOrAdd(field, (FieldInfo x) => x.CreateGetDelegate<TReturn>())); } private static SetDelegate<TValue> GetFieldSetDelegate<TValue>(this FieldInfo field) { return Extensions.CastDelegate<SetDelegate<TValue>>(FieldSetDelegateCache.GetOrAdd(field, (FieldInfo x) => x.CreateSetDelegate<TValue>())); } private static SetDelegateRef<TInstance, TValue> GetFieldSetDelegateRef<TInstance, TValue>(this FieldInfo field) where TInstance : struct { return Extensions.CastDelegate<SetDelegateRef<TInstance, TValue>>(FieldSetDelegateCache.GetOrAdd(field, (FieldInfo x) => x.CreateSetDelegateRef<TInstance, TValue>())); } public static PropertyInfo GetPropertyCached<T>(string name) { return typeof(T).GetPropertyCached(name); } public static PropertyInfo GetPropertyCached(this Type T, string name) { return PropertyCache.GetOrAddOnNull((T, name), ((Type T, string name) x) => x.T.GetProperty(x.name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); } public static TReturn GetPropertyValue<TReturn>(this object instance, string propName) { return instance.GetType().GetPropertyCached(propName).GetPropertyGetDelegate<TReturn>()(instance); } public static TReturn GetPropertyValue<TReturn>(this Type staticType, string propName) { return staticType.GetPropertyCached(propName).GetPropertyGetDelegate<TReturn>()(null); } public static void SetPropertyValue<TValue>(this object instance, string propName, TValue value) { PropertyInfo propertyCached = instance.GetType().GetPropertyCached(propName); if ((object)propertyCached != null) { propertyCached.GetPropertySetDelegate<TValue>()(instance, value); } } public static void SetPropertyValue<TValue>(this Type staticType, string propName, TValue value) { PropertyInfo propertyCached = staticType.GetPropertyCached(propName); if ((object)propertyCached != null) { propertyCached.GetPropertySetDelegate<TValue>()(null, value); } } public static void SetStructPropertyValue<TInstance, TValue>(this ref TInstance instance, string propName, TValue value) where TInstance : struct { typeof(TInstance).GetPropertyCached(propName).GetPropertySetDelegateRef<TInstance, TValue>()(ref instance, value); } public static TValue GetStructPropertyValue<TInstance, TValue>(this ref TInstance instance, string propName) where TInstance : struct { return typeof(TInstance).GetPropertyCached(propName).GetPropertyGetDelegateRef<TInstance, TValue>()(ref instance); } private static GetDelegate<TReturn> GetPropertyGetDelegate<TReturn>(this PropertyInfo property) { return Extensions.CastDelegate<GetDelegate<TReturn>>(PropertyGetDelegateCache.GetOrAdd(property, (PropertyInfo prop) => prop.CreateGetDelegate<TReturn>())); } private static GetDelegateRef<TInstance, TReturn> GetPropertyGetDelegateRef<TInstance, TReturn>(this PropertyInfo property) where TInstance : struct { return Extensions.CastDelegate<GetDelegateRef<TInstance, TReturn>>(PropertyGetDelegateCache.GetOrAdd(property, (PropertyInfo prop) => prop.CreateGetDelegate<TInstance, TReturn>())); } private static SetDelegate<TValue> GetPropertySetDelegate<TValue>(this PropertyInfo property) { return Extensions.CastDelegate<SetDelegate<TValue>>(PropertySetDelegateCache.GetOrAdd(property, (PropertyInfo prop) => prop.CreateSetDelegate<TValue>())); } private static SetDelegateRef<TInstance, TValue> GetPropertySetDelegateRef<TInstance, TValue>(this PropertyInfo property) where TInstance : struct { return Extensions.CastDelegate<SetDelegateRef<TInstance, TValue>>(PropertySetDelegateCache.GetOrAdd(property, (PropertyInfo prop) => prop.CreateSetDelegateRef<TInstance, TValue>())); } public static MethodInfo GetMethodCached<T>(string name) { return typeof(T).GetMethodCached(name); } public static MethodInfo GetMethodCached(this Type T, string name) { return MethodCache.GetOrAddOnNull((T, name), ((Type T, string name) x) => x.T.GetMethod(x.name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new Exception("Could not find MethodInfo on " + T.FullName + " with the name " + name)); } public static MethodInfo GetMethodWithConstructedGenericParameter(this Type T, string name, Type genericTypeDefinition) { return T.GetMethods().First(delegate(MethodInfo method) { if (method.Name != name) { return false; } Type parameterType = method.GetParameters().First().ParameterType; if (!parameterType.IsConstructedGenericType) { return false; } Type type = parameterType.GetGenericArguments().First(); return parameterType == genericTypeDefinition.MakeGenericType(type); }); } public static MethodInfo GetMethodCached<T>(string name, Type[] argumentTypes) { return typeof(T).GetMethodCached(name, argumentTypes); } public static MethodInfo GetMethodCached(this Type T, string name, Type[] argumentTypes) { return OverloadedMethodCache.GetOrAddOnNull((T, name, argumentTypes), ((Type T, string name, Type[] argumentTypes) x) => x.T.GetMethod(x.name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, x.argumentTypes, null) ?? throw new Exception("Could not find MethodInfo on " + T.FullName + " with the name " + name + " and arguments: " + string.Join(",", argumentTypes.Select((Type a) => a.FullName)))); } public static TReturn InvokeMethod<TReturn>(this object instance, string methodName) { return instance.InvokeMethod<TReturn>(methodName, null); } public static TReturn InvokeMethod<TReturn>(this Type staticType, string methodName) { return staticType.InvokeMethod<TReturn>(methodName, null); } public static void InvokeMethod(this object instance, string methodName) { instance.InvokeMethod<object>(methodName); } public static void InvokeMethod(this Type staticType, string methodName) { staticType.InvokeMethod<object>(methodName); } public static TReturn InvokeMethod<TReturn>(this object instance, string methodName, params object[] methodParams) { return (TReturn)(((methodParams == null) ? instance.GetType().GetMethodCached(methodName) : instance.GetType().GetMethodCached(methodName, methodParams.Select((object x) => x.GetType()).ToArray())) ?? throw new Exception($"Could not find method on type {instance.GetType()} with the name of {methodName} with the arguments specified.")).GetMethodDelegateCached().Invoke(instance, methodParams); } public static TReturn InvokeMethod<TReturn>(this Type staticType, string methodName, params object[] methodParams) { return (TReturn)(((methodParams == null) ? staticType.GetMethodCached(methodName) : staticType.GetMethodCached(methodName, methodParams.Select((object x) => x.GetType()).ToArray())) ?? throw new Exception($"Could not find method on type {staticType} with the name of {methodName} with the arguments specified.")).GetMethodDelegateCached().Invoke((object)null, methodParams); } public static void InvokeMethod(this object instance, string methodName, params object[] methodParams) { instance.InvokeMethod<object>(methodName, methodParams); } public static void InvokeMethod(this Type staticType, string methodName, params object[] methodParams) { staticType.InvokeMethod<object>(methodName, methodParams); } private static FastReflectionDelegate GetMethodDelegateCached(this MethodInfo methodInfo) { return DelegateCache.GetOrAdd(methodInfo, (Func<MethodInfo, FastReflectionDelegate>)((MethodInfo method) => method.GenerateCallDelegate())); } public static ConstructorInfo GetConstructorCached<T>(Type[] argumentTypes) { return typeof(T).GetConstructorCached(argumentTypes); } public static ConstructorInfo GetConstructorCached(this Type T, Type[] argumentTypes) { return ConstructorCache.GetOrAddOnNull((T, argumentTypes), ((Type T, Type[] argumentTypes) x) => x.T.GetConstructor(x.argumentTypes) ?? throw new Exception("Could not find ConstructorInfo on " + T.FullName + " with the arguments " + string.Join(",", argumentTypes.Select((Type a) => a.FullName)))); } public static Type GetNestedType<T>(string name) { return typeof(T).GetNestedTypeCached(name); } public static Type GetNestedTypeCached<T>(string name) { return typeof(T).GetNestedTypeCached(name); } public static Type GetNestedTypeCached(this Type T, string name) { return NestedTypeCache.GetOrAddOnNull((T, name), ((Type T, string name) x) => x.T.GetNestedType(x.name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new Exception("Could not find nested Type on " + T.FullName + " with the name " + name)); } public static object Instantiate(this Type type) { return Activator.CreateInstance(type, nonPublic: true); } public static object Instantiate(this Type type, params object[] constructorArguments) { return type.GetConstructorCached(constructorArguments.Select((object x) => x.GetType()).ToArray()).Invoke(constructorArguments); } public static object InstantiateGeneric<TClass>(this Type typeArgument) { return typeof(TClass).MakeGenericType(typeArgument).Instantiate(); } public static object InstantiateGeneric<TClass>(this Type[] typeArgument) { return typeof(TClass).MakeGenericType(typeArgument).Instantiate(); } public static IList InstantiateList(this Type type) { return (IList)typeof(List<>).MakeGenericType(type).Instantiate(); } private static GetDelegate<TReturn> CreateGetDelegate<TReturn>(this FieldInfo field) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) if (field == null) { throw new ArgumentException("Field cannot be null.", "field"); } if (!typeof(TReturn).IsAssignableFrom(field.FieldType)) { throw new Exception($"Field type {field.FieldType} does not match the requested type {typeof(TReturn)}."); } DynamicMethodDefinition val = new DynamicMethodDefinition($"{field} Getter", typeof(TReturn), new Type[1] { typeof(object) }); try { ILProcessor iLProcessor = val.GetILProcessor(); if (!field.IsStatic) { iLProcessor.Emit(OpCodes.Ldarg_0); if (field.DeclaringType.GetTypeInfo().IsValueType) { Extensions.Emit(iLProcessor, OpCodes.Unbox_Any, field.DeclaringType); } } Extensions.Emit(iLProcessor, (!field.IsStatic) ? OpCodes.Ldfld : OpCodes.Ldsfld, field); iLProcessor.Emit(OpCodes.Ret); return (GetDelegate<TReturn>)val.Generate().CreateDelegate(typeof(GetDelegate<TReturn>)); } finally { ((IDisposable)val)?.Dispose(); } } private static SetDelegate<TValue> CreateSetDelegate<TValue>(this FieldInfo field) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (field == null) { throw new ArgumentException("Field cannot be null.", "field"); } if (!field.FieldType.IsAssignableFrom(typeof(TValue))) { throw new Exception($"Value type type {typeof(TValue)} does not match the requested type {field.FieldType}."); } DynamicMethodDefinition val = new DynamicMethodDefinition($"{field} Setter", typeof(void), new Type[2] { typeof(object), typeof(TValue) }); try { ILProcessor iLProcessor = val.GetILProcessor(); if (!field.IsStatic) { iLProcessor.Emit(OpCodes.Ldarg_0); } iLProcessor.Emit(OpCodes.Ldarg_1); Extensions.Emit(iLProcessor, (!field.IsStatic) ? OpCodes.Stfld : OpCodes.Stsfld, field); iLProcessor.Emit(OpCodes.Ret); return (SetDelegate<TValue>)val.Generate().CreateDelegate(typeof(SetDelegate<TValue>)); } finally { ((IDisposable)val)?.Dispose(); } } private static SetDelegateRef<TInstance, TValue> CreateSetDelegateRef<TInstance, TValue>(this FieldInfo field) where TInstance : struct { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (field == null) { throw new ArgumentException("Field cannot be null.", "field"); } if (field.FieldType != typeof(TValue)) { throw new Exception($"Value type type {typeof(TValue)} does not match the requested type {field.FieldType}."); } DynamicMethodDefinition val = new DynamicMethodDefinition($"{field} SetterByRef", typeof(void), new Type[2] { typeof(TInstance).MakeByRefType(), typeof(TValue) }); try { ILProcessor iLProcessor = val.GetILProcessor(); if (!field.IsStatic) { iLProcessor.Emit(OpCodes.Ldarg_0); } iLProcessor.Emit(OpCodes.Ldarg_1); Extensions.Emit(iLProcessor, (!field.IsStatic) ? OpCodes.Stfld : OpCodes.Stsfld, field); iLProcessor.Emit(OpCodes.Ret); return (SetDelegateRef<TInstance, TValue>)val.Generate().CreateDelegate(typeof(SetDelegateRef<TInstance, TValue>)); } finally { ((IDisposable)val)?.Dispose(); } } private static GetDelegate<TReturn> CreateGetDelegate<TReturn>(this PropertyInfo property) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (property == null) { throw new ArgumentException("Property cannot be null.", "property"); } if (!typeof(TReturn).IsAssignableFrom(property.PropertyType)) { throw new Exception($"Field type {property.PropertyType} does not match the requested type {typeof(TReturn)}."); } DynamicMethodDefinition val = new DynamicMethodDefinition($"{property} Getter", typeof(TReturn), new Type[1] { typeof(object) }); try { ILProcessor iLProcessor = val.GetILProcessor(); MethodInfo getMethod = property.GetGetMethod(nonPublic: true); if (!getMethod.IsStatic) { iLProcessor.Emit(OpCodes.Ldarg_0); } Extensions.Emit(iLProcessor, OpCodes.Call, (MethodBase)getMethod); iLProcessor.Emit(OpCodes.Ret); return (GetDelegate<TReturn>)val.Generate().CreateDelegate(typeof(GetDelegate<TReturn>)); } finally { ((IDisposable)val)?.Dispose(); } } private static GetDelegateRef<TInstance, TReturn> CreateGetDelegate<TInstance, TReturn>(this PropertyInfo property) where TInstance : struct { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (property == null) { throw new ArgumentException("Property cannot be null.", "property"); } if (!typeof(TReturn).IsAssignableFrom(property.PropertyType)) { throw new Exception($"Field type {property.PropertyType} does not match the requested type {typeof(TReturn)}."); } DynamicMethodDefinition val = new DynamicMethodDefinition($"{property} Getter", typeof(TReturn), new Type[1] { typeof(TInstance).MakeByRefType() }); try { ILProcessor iLProcessor = val.GetILProcessor(); MethodInfo getMethod = property.GetGetMethod(nonPublic: true); if (!getMethod.IsStatic) { iLProcessor.Emit(OpCodes.Ldarg_0); } Extensions.Emit(iLProcessor, OpCodes.Call, (MethodBase)getMethod); iLProcessor.Emit(OpCodes.Ret); return (GetDelegateRef<TInstance, TReturn>)val.Generate().CreateDelegate(typeof(GetDelegateRef<TInstance, TReturn>)); } finally { ((IDisposable)val)?.Dispose(); } } private static SetDelegate<TValue> CreateSetDelegate<TValue>(this PropertyInfo property) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00ae: Unknown result type (might