Пример #1
0
            // Token: 0x060004C9 RID: 1225 RVA: 0x000132B0 File Offset: 0x000114B0
            public static void PayCost(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context)
            {
                CostTypeCatalog.LunarItemOrEquipmentCostTypeHelper.< > c__DisplayClass3_0 CS$ < > 8__locals1;
                CS$ < > 8__locals1.context   = context;
                CS$ < > 8__locals1.inventory = CS$ < > 8__locals1.context.activator.GetComponent <CharacterBody>().inventory;
                int cost = CS$ < > 8__locals1.context.cost;

                CS$ < > 8__locals1.itemWeight      = 0;
                CS$ < > 8__locals1.equipmentWeight = 0;
                for (int i = 0; i < CostTypeCatalog.LunarItemOrEquipmentCostTypeHelper.lunarItemIndices.Length; i++)
                {
                    ItemIndex itemIndex = CostTypeCatalog.LunarItemOrEquipmentCostTypeHelper.lunarItemIndices[i];
                    int       itemCount = CS$ < > 8__locals1.inventory.GetItemCount(itemIndex);
                    CS$ < > 8__locals1.itemWeight += itemCount;
                }
                int j = 0;
                int equipmentSlotCount = CS$ < > 8__locals1.inventory.GetEquipmentSlotCount();

                while (j < equipmentSlotCount)
                {
                    EquipmentState equipment = CS$ < > 8__locals1.inventory.GetEquipment((uint)j);
                    if (Array.IndexOf <EquipmentIndex>(CostTypeCatalog.LunarItemOrEquipmentCostTypeHelper.lunarEquipmentIndices, equipment.equipmentIndex) != -1)
                    {
                        int equipmentWeight = CS$ < > 8__locals1.equipmentWeight + 1;
                        CS$ < > 8__locals1.equipmentWeight = equipmentWeight;
                    }
                    j++;
                }
                CS$ < > 8__locals1.totalWeight = CS$ < > 8__locals1.itemWeight + CS$ < > 8__locals1.equipmentWeight;
                for (int k = 0; k < cost; k++)
                {
                    CostTypeCatalog.LunarItemOrEquipmentCostTypeHelper.< PayCost > g__TakeOne | 3_0 (ref CS$ < > 8__locals1);
                }
            }
Пример #2
0
        private static bool FixLunarCostDef(ref CostTypeDef.PayCostContext context)
        {
            var inventory = context.activator.GetComponent <CharacterBody>().inventory;

            if (inventory.GetItemCount(LunarScrapDef) > 0)
            {
                inventory.RemoveItem(LunarScrapDef, 1);
                context.results.itemsTaken.Add(LunarScrapDef.itemIndex);
                return(false);
            }
            return(true);
        }
Пример #3
0
 private static void LunarItemOrEquipmentCostTypeHelper_PayCost(On.RoR2.CostTypeCatalog.LunarItemOrEquipmentCostTypeHelper.orig_PayCost orig, CostTypeDef costTypeDef, CostTypeDef.PayCostContext context)
 {
     ignoreFakes = true;
     orig(costTypeDef, context);
     ignoreFakes = false;
 }
        private void MultiShopCardUtils_OnPurchase(On.RoR2.Items.MultiShopCardUtils.orig_OnPurchase orig, CostTypeDef.PayCostContext context, int moneyCost)
        {
            orig(context, moneyCost);
            CharacterMaster activatorMaster = context.activatorMaster;

            if (activatorMaster && activatorMaster.hasBody && activatorMaster.inventory && activatorMaster.inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_KeepShopTerminalOpen) > 0 && context.purchasedObject)
            {
                ShopTerminalBehavior shopTerminalBehavior = context.purchasedObject.GetComponent <ShopTerminalBehavior>();
                if (shopTerminalBehavior && shopTerminalBehavior.serverMultiShopController)
                {
                    shopTerminalBehavior.serverMultiShopController.SetCloseOnTerminalPurchase(context.purchasedObject.GetComponent <PurchaseInteraction>(), false);
                    activatorMaster.inventory.RemoveItem(MysticsItemsContent.Items.MysticsItems_KeepShopTerminalOpen);
                    activatorMaster.inventory.GiveItem(MysticsItemsContent.Items.MysticsItems_KeepShopTerminalOpenConsumed);

                    RoR2.Audio.PointSoundManager.EmitSoundServer(KeepShopTerminalOpen.sfx.index, shopTerminalBehavior.transform.position);

                    shopTerminalBehavior.serverMultiShopController.Networkcost = (int)(shopTerminalBehavior.serverMultiShopController.Networkcost * (1f - discount / 100f));
                    foreach (var terminal in shopTerminalBehavior.serverMultiShopController.terminalGameObjects)
                    {
                        if (terminal)
                        {
                            var purchaseInteraction = terminal.GetComponent <PurchaseInteraction>();
                            if (purchaseInteraction)
                            {
                                purchaseInteraction.Networkcost = (int)(purchaseInteraction.Networkcost * (1f - discount / 100f));
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
 private static void TakeItemsFromWeightedSelection(WeightedSelection <ItemIndex> weightedSelection, ref CostTypeDef.PayCostContext context, ref List <ItemIndex> itemsToTake, int halfTotalItemCount)
 {
     while (weightedSelection.Count > 0 && itemsToTake.Count < halfTotalItemCount)
     {
         int choiceIndex = weightedSelection.EvaluateToChoiceIndex(context.rng.nextNormalizedFloat);
         WeightedSelection <ItemIndex> .ChoiceInfo choice = weightedSelection.GetChoice(choiceIndex);
         ItemIndex value = choice.value;
         int       num   = (int)choice.weight;
         num--;
         if (num <= 0)
         {
             weightedSelection.RemoveChoice(choiceIndex);
         }
         else
         {
             weightedSelection.ModifyChoiceWeight(choiceIndex, (float)num);
         }
         itemsToTake.Add(value);
     }
 }