Exemplo n.º 1
0
 public void OnInteractionBegin(Interactor activator)
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.BarrelInteraction::OnInteractionBegin(RoR2.Interactor)' called on client");
         return;
     }
     if (!this.opened)
     {
         this.Networkopened = true;
         EntityStateMachine component = base.GetComponent <EntityStateMachine>();
         if (component)
         {
             component.SetNextState(new Opening());
         }
         CharacterBody component2 = activator.GetComponent <CharacterBody>();
         if (component2)
         {
             TeamIndex objectTeam = TeamComponent.GetObjectTeam(component2.gameObject);
             TeamManager.instance.GiveTeamMoney(objectTeam, (uint)this.goldReward);
         }
         this.CoinDrop();
         ExperienceManager.instance.AwardExperience(base.transform.position, activator.GetComponent <CharacterBody>(), (ulong)this.expReward);
     }
 }
Exemplo n.º 2
0
        // Token: 0x0600138C RID: 5004 RVA: 0x0005F66C File Offset: 0x0005D86C
        public bool CanBeAffordedByInteractor(Interactor activator)
        {
            switch (this.costType)
            {
            case CostType.None:
                return(true);

            case CostType.Money:
            {
                CharacterBody component = activator.GetComponent <CharacterBody>();
                if (component)
                {
                    CharacterMaster master = component.master;
                    if (master)
                    {
                        return((ulong)master.money >= (ulong)((long)this.cost));
                    }
                }
                return(false);
            }

            case CostType.PercentHealth:
            {
                HealthComponent component2 = activator.GetComponent <HealthComponent>();
                return(component2 && component2.health / component2.fullHealth * 100f >= (float)this.cost);
            }

            case CostType.Lunar:
            {
                NetworkUser networkUser = Util.LookUpBodyNetworkUser(activator.gameObject);
                return(networkUser && (ulong)networkUser.lunarCoins >= (ulong)((long)this.cost));
            }

            case CostType.WhiteItem:
            case CostType.GreenItem:
            case CostType.RedItem:
            {
                ItemTier      itemTier   = PurchaseInteraction.CostTypeToItemTier(this.costType);
                CharacterBody component3 = activator.gameObject.GetComponent <CharacterBody>();
                if (component3)
                {
                    Inventory inventory = component3.inventory;
                    if (inventory)
                    {
                        return(inventory.HasAtLeastXTotalItemsOfTier(itemTier, this.cost));
                    }
                }
                return(false);
            }

            default:
                return(false);
            }
        }
Exemplo n.º 3
0
 void AttemptInteraction(On.RoR2.Interactor.orig_AttemptInteraction orig, RoR2.Interactor interactor, GameObject gameObject)
 {
     if (Data.modEnabled && interactor.GetComponent <NetworkBehaviour>().hasAuthority)
     {
         if (Data.mode == DataShop.mode)
         {
             latestInteractionName = gameObject.name;
             DataShop.purchaseCost = 0;
             DataShop.purchaseTier = -1;
             if (gameObject.name.ToLower().Contains("duplicator"))
             {
                 Util.LogComponentsOfObject(gameObject);
             }
             if (gameObject.name == "Scrapper(Clone)")
             {
                 DataShop.purchaseCost = gameObject.GetComponent <ScrapperController>().maxItemsToScrapAtATime;
             }
             else
             {
                 RoR2.PurchaseInteraction purchaseInteraction = purchaseInteraction = gameObject.GetComponent <RoR2.PurchaseInteraction>();
                 if (purchaseInteraction != null)
                 {
                     if (DataShop.costTypeTier.ContainsKey(purchaseInteraction.costType))
                     {
                         DataShop.purchaseTier = DataShop.costTypeTier[purchaseInteraction.costType];
                         DataShop.purchaseCost = purchaseInteraction.cost;
                     }
                 }
             }
         }
     }
     orig(interactor, gameObject);
 }
        // Token: 0x06001546 RID: 5446 RVA: 0x0005A9D0 File Offset: 0x00058BD0
        public Interactability GetInteractability(Interactor activator)
        {
            CharacterBody component = activator.GetComponent <CharacterBody>();

            if (!this.passengerBodyObject)
            {
                Interactability?interactability = this.enterVehicleAllowedCheck.Evaluate(component);
                if (interactability == null)
                {
                    return(Interactability.Available);
                }
                return(interactability.GetValueOrDefault());
            }
            else if (this.passengerBodyObject == activator.gameObject && this.passengerAssignmentTime.timeSince >= this.passengerAssignmentCooldown)
            {
                Interactability?interactability = this.exitVehicleAllowedCheck.Evaluate(component);
                if (interactability == null)
                {
                    return(Interactability.Available);
                }
                return(interactability.GetValueOrDefault());
            }
            else
            {
                if (component && component.currentVehicle && component.currentVehicle != this)
                {
                    return(Interactability.ConditionsNotMet);
                }
                return(Interactability.Disabled);
            }
        }
Exemplo n.º 5
0
        public void GrantUnlock(Interactor interactor)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.BlueprintTerminal::GrantUnlock(RoR2.Interactor)' called on client");
                return;
            }
            this.SetHasBeenPurchased(true);
            string unlockableName = this.unlockableOptions[this.unlockableChoice].unlockableName;

            EffectManager.SpawnEffect(this.unlockEffect, new EffectData
            {
                origin = base.transform.position
            }, true);
            if (Run.instance)
            {
                Util.PlaySound(this.unlockSoundString, interactor.gameObject);
                CharacterBody component = interactor.GetComponent <CharacterBody>();
                Run.instance.GrantUnlockToSinglePlayer(unlockableName, component);
                string        pickupToken   = "???";
                UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(unlockableName);
                if (unlockableDef != null)
                {
                    pickupToken = unlockableDef.nameToken;
                }
                Chat.SendBroadcastChat(new Chat.PlayerPickupChatMessage
                {
                    subjectAsCharacterBody = component,
                    baseToken      = "PLAYER_PICKUP",
                    pickupToken    = pickupToken,
                    pickupColor    = ColorCatalog.GetColor(ColorCatalog.ColorIndex.Unlockable),
                    pickupQuantity = 1U
                });
            }
        }
Exemplo n.º 6
0
        public void AddShrineStack(Interactor interactor)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ShrineBossBehavior::AddShrineStack(RoR2.Interactor)' called on client");
                return;
            }
            this.waitingForRefresh = true;
            if (TeleporterInteraction.instance)
            {
                TeleporterInteraction.instance.AddShrineStack();
            }
            CharacterBody component = interactor.GetComponent <CharacterBody>();

            Chat.SendBroadcastChat(new Chat.SubjectFormatChatMessage
            {
                subjectAsCharacterBody = component,
                baseToken = "SHRINE_BOSS_USE_MESSAGE"
            });
            EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
            {
                origin   = base.transform.position,
                rotation = Quaternion.identity,
                scale    = 1f,
                color    = new Color(0.7372549f, 0.90588236f, 0.94509804f)
            }, true);
            this.purchaseCount++;
            this.refreshTimer = 2f;
            if (this.purchaseCount >= this.maxPurchaseCount)
            {
                this.symbolTransform.gameObject.SetActive(false);
            }
        }
Exemplo n.º 7
0
        public void OpenSummon(Interactor activator)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.SummonMasterBehavior::OpenSummon(RoR2.Interactor)' called on client");
                return;
            }
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.masterPrefab, base.transform.position, base.transform.rotation);

            NetworkServer.Spawn(gameObject);
            CharacterMaster component = gameObject.GetComponent <CharacterMaster>();

            component.SpawnBody(component.bodyPrefab, base.transform.position + Vector3.up * 0.8f, base.transform.rotation);
            AIOwnership component2 = gameObject.GetComponent <AIOwnership>();

            if (component2)
            {
                CharacterBody component3 = activator.GetComponent <CharacterBody>();
                if (component3)
                {
                    CharacterMaster master = component3.master;
                    if (master)
                    {
                        component2.ownerMaster = master;
                    }
                }
            }
            BaseAI component4 = gameObject.GetComponent <BaseAI>();

            if (component4)
            {
                component4.leader.gameObject = activator.gameObject;
            }
            UnityEngine.Object.Destroy(base.gameObject);
        }
Exemplo n.º 8
0
        public void AddShrineStack(Interactor activator)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ShrineChanceBehavior::AddShrineStack(RoR2.Interactor)' called on client");
                return;
            }
            PickupIndex none   = PickupIndex.none;
            PickupIndex value  = this.rng.NextElementUniform <PickupIndex>(Run.instance.availableTier1DropList);
            PickupIndex value2 = this.rng.NextElementUniform <PickupIndex>(Run.instance.availableTier2DropList);
            PickupIndex value3 = this.rng.NextElementUniform <PickupIndex>(Run.instance.availableTier3DropList);
            PickupIndex value4 = this.rng.NextElementUniform <PickupIndex>(Run.instance.availableEquipmentDropList);
            WeightedSelection <PickupIndex> weightedSelection = new WeightedSelection <PickupIndex>(8);

            weightedSelection.AddChoice(none, this.failureWeight);
            weightedSelection.AddChoice(value, this.tier1Weight);
            weightedSelection.AddChoice(value2, this.tier2Weight);
            weightedSelection.AddChoice(value3, this.tier3Weight);
            weightedSelection.AddChoice(value4, this.equipmentWeight);
            PickupIndex pickupIndex = weightedSelection.Evaluate(this.rng.nextNormalizedFloat);
            bool        flag        = pickupIndex == PickupIndex.none;
            string      baseToken;

            if (flag)
            {
                baseToken = "SHRINE_CHANCE_FAIL_MESSAGE";
            }
            else
            {
                baseToken = "SHRINE_CHANCE_SUCCESS_MESSAGE";
                this.successfulPurchaseCount++;
                PickupDropletController.CreatePickupDroplet(pickupIndex, this.dropletOrigin.position, this.dropletOrigin.forward * 20f);
            }
            Chat.SendBroadcastChat(new Chat.SubjectFormatChatMessage
            {
                subjectAsCharacterBody = activator.GetComponent <CharacterBody>(),
                baseToken = baseToken
            });
            Action <bool, Interactor> action = ShrineChanceBehavior.onShrineChancePurchaseGlobal;

            if (action != null)
            {
                action(flag, activator);
            }
            this.waitingForRefresh = true;
            this.refreshTimer      = 2f;
            EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
            {
                origin   = base.transform.position,
                rotation = Quaternion.identity,
                scale    = 1f,
                color    = this.shrineColor
            }, true);
            if (this.successfulPurchaseCount >= this.maxPurchaseCount)
            {
                this.symbolTransform.gameObject.SetActive(false);
            }
        }
Exemplo n.º 9
0
        // Token: 0x0600172D RID: 5933 RVA: 0x0006E1DC File Offset: 0x0006C3DC
        public void GrantUnlockable(Interactor interactor)
        {
            CharacterBody component = interactor.GetComponent <CharacterBody>();

            if (component)
            {
                Run.instance.GrantUnlockToSinglePlayer(this.unlockableString, component);
            }
        }
        // Token: 0x06001358 RID: 4952 RVA: 0x00052DE4 File Offset: 0x00050FE4
        public Interactability GetInteractability(Interactor activator)
        {
            CharacterBody component = activator.GetComponent <CharacterBody>();

            if (component)
            {
                Inventory inventory = component.inventory;
                if (inventory && ShrineCleanseBehavior.InventoryIsCleansable(inventory))
                {
                    return(Interactability.Available);
                }
            }
            return(Interactability.ConditionsNotMet);
        }
        // Token: 0x06001359 RID: 4953 RVA: 0x00052E1C File Offset: 0x0005101C
        public void OnInteractionBegin(Interactor activator)
        {
            CharacterBody component = activator.GetComponent <CharacterBody>();

            if (component)
            {
                Inventory inventory = component.inventory;
                if (inventory)
                {
                    ShrineCleanseBehavior.CleanseInventoryServer(inventory);
                    EffectManager.SimpleEffect(this.activationEffectPrefab, base.transform.position, base.transform.rotation, true);
                }
            }
        }
        public void AddShrineStack(Interactor interactor)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ShrineCombatBehavior::AddShrineStack(RoR2.Interactor)' called on client");
                return;
            }
            new List <CharacterBody>();
            this.waitingForRefresh = true;
            if (this.combatDirector)
            {
                this.combatDirector.enabled        = true;
                this.combatDirector.monsterCredit += this.monsterCredit;
                this.combatDirector.OverrideCurrentMonsterCard(this.chosenDirectorCard);
                this.combatDirector.monsterSpawnTimer = 0f;
            }
            CharacterMaster component = this.chosenDirectorCard.spawnCard.prefab.GetComponent <CharacterMaster>();

            if (component)
            {
                CharacterBody component2 = component.bodyPrefab.GetComponent <CharacterBody>();
                if (component2)
                {
                    Chat.SendBroadcastChat(new Chat.SubjectFormatChatMessage
                    {
                        subjectAsCharacterBody = interactor.GetComponent <CharacterBody>(),
                        baseToken   = "SHRINE_COMBAT_USE_MESSAGE",
                        paramTokens = new string[]
                        {
                            component2.baseNameToken
                        }
                    });
                }
            }
            EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
            {
                origin   = base.transform.position,
                rotation = Quaternion.identity,
                scale    = 1f,
                color    = this.shrineEffectColor
            }, true);
            this.purchaseCount++;
            this.refreshTimer = 2f;
            if (this.purchaseCount >= this.maxPurchaseCount)
            {
                this.symbolTransform.gameObject.SetActive(false);
            }
        }
        // Token: 0x060004AC RID: 1196 RVA: 0x00012C34 File Offset: 0x00010E34
        public CostTypeDef.PayCostResults PayCost(int cost, Interactor activator, GameObject purchasedObject, Xoroshiro128Plus rng, ItemIndex avoidedItemIndex)
        {
            CostTypeDef.PayCostResults payCostResults = new CostTypeDef.PayCostResults();
            CharacterBody component = activator.GetComponent <CharacterBody>();

            this.payCost(this, new CostTypeDef.PayCostContext
            {
                cost             = cost,
                activator        = activator,
                activatorBody    = component,
                activatorMaster  = (component ? component.master : null),
                purchasedObject  = purchasedObject,
                results          = payCostResults,
                rng              = rng,
                avoidedItemIndex = avoidedItemIndex
            });
            return(payCostResults);
        }
        // Token: 0x060010B3 RID: 4275 RVA: 0x00049330 File Offset: 0x00047530
        public void OnInteractionBegin(Interactor activator)
        {
            if (!this.CanBeAffordedByInteractor(activator))
            {
                return;
            }
            CharacterBody        component   = activator.GetComponent <CharacterBody>();
            CostTypeDef          costTypeDef = CostTypeCatalog.GetCostTypeDef(this.costType);
            ItemIndex            itemIndex   = ItemIndex.None;
            ShopTerminalBehavior component2  = base.GetComponent <ShopTerminalBehavior>();

            if (component2)
            {
                itemIndex = component2.CurrentPickupIndex().itemIndex;
            }
            CostTypeDef.PayCostResults payCostResults = costTypeDef.PayCost(this.cost, activator, base.gameObject, this.rng, itemIndex);
            foreach (ItemIndex itemIndex2 in payCostResults.itemsTaken)
            {
                PurchaseInteraction.CreateItemTakenOrb(component.corePosition, base.gameObject, itemIndex2);
                if (itemIndex2 != itemIndex)
                {
                    Action <PurchaseInteraction, Interactor> action = PurchaseInteraction.onItemSpentOnPurchase;
                    if (action != null)
                    {
                        action(this, activator);
                    }
                }
            }
            foreach (EquipmentIndex arg in payCostResults.equipmentTaken)
            {
                Action <PurchaseInteraction, Interactor, EquipmentIndex> action2 = PurchaseInteraction.onEquipmentSpentOnPurchase;
                if (action2 != null)
                {
                    action2(this, activator, arg);
                }
            }
            IEnumerable <StatDef> statDefsToIncrement = this.purchaseStatNames.Select(new Func <string, StatDef>(StatDef.Find));

            StatManager.OnPurchase <IEnumerable <StatDef> >(component, this.costType, statDefsToIncrement);
            this.onPurchase.Invoke(activator);
            this.lastActivator = activator;
        }
Exemplo n.º 15
0
            void InteractionResult(On.RoR2.Interactor.orig_RpcInteractionResult orig, RoR2.Interactor interactor, bool boolean)
            {
                if (Data.modEnabled)
                {
                    if (Data.mode == DataShop.mode)
                    {
                        if (interactor.GetComponent <NetworkBehaviour>().hasAuthority)
                        {
                            if (boolean)
                            {
                                if (DataShop.purchaseTier != -1 && DataShop.purchaseCost > 0)
                                {
                                    DataShop.RemoveScrap(DataShop.purchaseTier, DataShop.purchaseCost);
                                }

                                Dictionary <string, string> specialCases = new Dictionary <string, string>()
                                {
                                    { "BrokenDroneMissile", "BrokenMissileDrone" },
                                };
                                string prefix       = "Broken";
                                string suffix       = "Master(Clone)";
                                string adjustedName = latestInteractionName;
                                if (adjustedName.Length > suffix.Length)
                                {
                                    adjustedName = adjustedName.Substring(0, adjustedName.Length - suffix.Length);
                                }
                                adjustedName = prefix + adjustedName;
                                if (specialCases.ContainsKey(adjustedName))
                                {
                                    adjustedName = specialCases[adjustedName];
                                }
                                if (Data.allDroneNames.ContainsKey(adjustedName))
                                {
                                    DataShop.AddScrap(characterBody, 6);
                                }
                            }
                        }
                    }
                }
                orig(interactor, boolean);
            }
Exemplo n.º 16
0
        public void AddShrineStack(Interactor interactor)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ShrineBloodBehavior::AddShrineStack(RoR2.Interactor)' called on client");
                return;
            }
            this.waitingForRefresh = true;
            CharacterBody component = interactor.GetComponent <CharacterBody>();

            if (component)
            {
                uint amount = (uint)(component.healthComponent.fullHealth * (float)this.purchaseInteraction.cost / 100f * this.goldToPaidHpRatio);
                if (component.master)
                {
                    component.master.GiveMoney(amount);
                    Chat.SendBroadcastChat(new Chat.SubjectFormatChatMessage
                    {
                        subjectCharacterBodyGameObject = interactor.gameObject,
                        baseToken   = "SHRINE_BLOOD_USE_MESSAGE",
                        paramTokens = new string[]
                        {
                            amount.ToString()
                        }
                    });
                }
            }
            EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
            {
                origin   = base.transform.position,
                rotation = Quaternion.identity,
                scale    = 1f,
                color    = Color.red
            }, true);
            this.purchaseCount++;
            this.refreshTimer = 2f;
            if (this.purchaseCount >= this.maxPurchaseCount)
            {
                this.symbolTransform.gameObject.SetActive(false);
            }
        }
Exemplo n.º 17
0
        // Token: 0x06000B57 RID: 2903 RVA: 0x000320E0 File Offset: 0x000302E0
        public Interactability GetInteractability(Interactor activator)
        {
            if (!base.enabled)
            {
                return(Interactability.Disabled);
            }
            if (this.waitStartTime.timeSince < this.waitDuration || this.consumed)
            {
                return(Interactability.Disabled);
            }
            CharacterBody component = activator.GetComponent <CharacterBody>();

            if (!component)
            {
                return(Interactability.Disabled);
            }
            if (!GenericPickupController.BodyHasPickupPermission(component))
            {
                return(Interactability.Disabled);
            }
            return(Interactability.Available);
        }
        public void AddShrineStack(Interactor interactor)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ShrineRestackBehavior::AddShrineStack(RoR2.Interactor)' called on client");
                return;
            }
            this.waitingForRefresh = true;
            CharacterBody component = interactor.GetComponent <CharacterBody>();

            if (component && component.master)
            {
                Inventory inventory = component.master.inventory;
                if (inventory)
                {
                    inventory.ShrineRestackInventory(this.rng);
                    Chat.SendBroadcastChat(new Chat.SubjectFormatChatMessage
                    {
                        subjectCharacterBodyGameObject = interactor.gameObject,
                        baseToken = "SHRINE_RESTACK_USE_MESSAGE"
                    });
                }
            }
            EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
            {
                origin   = base.transform.position,
                rotation = Quaternion.identity,
                scale    = 1f,
                color    = new Color(1f, 0.23f, 0.6337214f)
            }, true);
            this.purchaseCount++;
            this.refreshTimer = 2f;
            if (this.purchaseCount >= this.maxPurchaseCount)
            {
                this.symbolTransform.gameObject.SetActive(false);
            }
        }
Exemplo n.º 19
0
 // Token: 0x06000B58 RID: 2904 RVA: 0x00032130 File Offset: 0x00030330
 public void OnInteractionBegin(Interactor activator)
 {
     this.AttemptGrant(activator.GetComponent <CharacterBody>());
 }
Exemplo n.º 20
0
        // Token: 0x0600138F RID: 5007 RVA: 0x0005F7EC File Offset: 0x0005D9EC
        public void OnInteractionBegin(Interactor activator)
        {
            if (!this.CanBeAffordedByInteractor(activator))
            {
                return;
            }
            CharacterBody component = activator.GetComponent <CharacterBody>();

            switch (this.costType)
            {
            case CostType.Money:
                if (component)
                {
                    CharacterMaster master = component.master;
                    if (master)
                    {
                        master.money -= (uint)this.cost;
                    }
                }
                break;

            case CostType.PercentHealth:
            {
                HealthComponent component2 = activator.GetComponent <HealthComponent>();
                if (component2)
                {
                    float health = component2.health;
                    float num    = component2.fullHealth * (float)this.cost / 100f;
                    if (health > num)
                    {
                        component2.TakeDamage(new DamageInfo
                            {
                                damage     = num,
                                attacker   = base.gameObject,
                                position   = base.transform.position,
                                damageType = DamageType.BypassArmor
                            });
                    }
                }
                break;
            }

            case CostType.Lunar:
            {
                NetworkUser networkUser = Util.LookUpBodyNetworkUser(activator.gameObject);
                if (networkUser)
                {
                    networkUser.DeductLunarCoins((uint)this.cost);
                }
                break;
            }

            case CostType.WhiteItem:
            case CostType.GreenItem:
            case CostType.RedItem:
            {
                ItemTier itemTier = PurchaseInteraction.CostTypeToItemTier(this.costType);
                if (component)
                {
                    Inventory inventory = component.inventory;
                    if (inventory)
                    {
                        ItemIndex            itemIndex  = ItemIndex.None;
                        ShopTerminalBehavior component3 = base.GetComponent <ShopTerminalBehavior>();
                        if (component3)
                        {
                            itemIndex = component3.CurrentPickupIndex().itemIndex;
                        }
                        WeightedSelection <ItemIndex> weightedSelection = new WeightedSelection <ItemIndex>(8);
                        foreach (ItemIndex itemIndex2 in ItemCatalog.allItems)
                        {
                            if (itemIndex2 != itemIndex)
                            {
                                int itemCount = inventory.GetItemCount(itemIndex2);
                                if (itemCount > 0 && ItemCatalog.GetItemDef(itemIndex2).tier == itemTier)
                                {
                                    weightedSelection.AddChoice(itemIndex2, (float)itemCount);
                                }
                            }
                        }
                        List <ItemIndex> list = new List <ItemIndex>();
                        int num2 = 0;
                        while (weightedSelection.Count > 0 && num2 < this.cost)
                        {
                            int num3 = weightedSelection.EvaluteToChoiceIndex(this.rng.nextNormalizedFloat);
                            WeightedSelection <ItemIndex> .ChoiceInfo choice = weightedSelection.GetChoice(num3);
                            ItemIndex value = choice.value;
                            int       num4  = (int)choice.weight;
                            num4--;
                            if (num4 <= 0)
                            {
                                weightedSelection.RemoveChoice(num3);
                            }
                            else
                            {
                                weightedSelection.ModifyChoiceWeight(num3, (float)num4);
                            }
                            list.Add(value);
                            num2++;
                        }
                        for (int i = num2; i < this.cost; i++)
                        {
                            list.Add(itemIndex);
                        }
                        for (int j = 0; j < list.Count; j++)
                        {
                            ItemIndex itemIndex3 = list[j];
                            PurchaseInteraction.CreateItemTakenOrb(component.corePosition, base.gameObject, itemIndex3);
                            inventory.RemoveItem(itemIndex3, 1);
                            if (itemIndex3 != itemIndex)
                            {
                                Action <PurchaseInteraction, Interactor> action = PurchaseInteraction.onItemSpentOnPurchase;
                                if (action != null)
                                {
                                    action(this, activator);
                                }
                            }
                        }
                    }
                }
                break;
            }
            }
            IEnumerable <StatDef> statDefsToIncrement = this.purchaseStatNames.Select(new Func <string, StatDef>(StatDef.Find));

            StatManager.OnPurchase <IEnumerable <StatDef> >(component, this.costType, statDefsToIncrement);
            this.onPurchase.Invoke(activator);
            this.lastActivator = activator;
        }