private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig,
                                           PurchaseInteraction self, Interactor activator)
        {
            if (!self.CanBeAffordedByInteractor(activator))
            {
                return;
            }

            #region Sharedmoney

            if (ShareSuite.MoneyIsShared.Value)
            {
                switch (self.costType)
                {
                case CostTypeIndex.Money:
                {
                    // Remove money from shared money pool
                    orig(self, activator);
                    SharedMoneyValue -= self.cost;
                    return;
                }

                case CostTypeIndex.PercentHealth:
                {
                    // Share the damage taken from a sacrifice
                    // as it generates shared money
                    orig(self, activator);
                    var teamMaxHealth = 0;
                    foreach (var playerCharacterMasterController in PlayerCharacterMasterController.instances)
                    {
                        var charMaxHealth = playerCharacterMasterController.master.GetBody().maxHealth;
                        if (charMaxHealth > teamMaxHealth)
                        {
                            teamMaxHealth = (int)charMaxHealth;
                        }
                    }

                    var purchaseInteraction = self.GetComponent <PurchaseInteraction>();
                    var shrineBloodBehavior = self.GetComponent <ShrineBloodBehavior>();
                    var amount = (uint)(teamMaxHealth * purchaseInteraction.cost / 100.0 *
                                        shrineBloodBehavior.goldToPaidHpRatio);

                    if (ShareSuite.MoneyScalarEnabled.Value)
                    {
                        amount *= (uint)ShareSuite.MoneyScalar.Value;
                    }

                    SharedMoneyValue += (int)amount;
                    return;
                }
                }
            }

            orig(self, activator);

            #endregion
        }
예제 #2
0
 private void OutsideInteractableLocker_LockPurchasable(On.RoR2.OutsideInteractableLocker.orig_LockPurchasable orig, OutsideInteractableLocker self, PurchaseInteraction purchaseInteraction)
 {
     if (purchaseInteraction.GetComponent <MoneyPickupMarker>())
     {
         return;
     }
     orig(self, purchaseInteraction);
 }
예제 #3
0
 private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
 {
     orig(self, activator);
     if (self && self.CanBeAffordedByInteractor(activator) && !self.GetComponent <RecombobulatorFlag>())
     {
         self.gameObject.AddComponent <RecombobulatorFlag>();
     }
 }
 private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
 {
     orig(self, activator);
     if (self.displayNameToken.ToLower() == "shrine_boss_name")
     {
         var bossBehavior = self.GetComponent <ShrineBossBehavior>();
         bossBehavior.maxPurchaseCount = maxpurchase.Value;
         bossBehavior.refreshTimer     = delaytime.Value;
     }
 }
예제 #5
0
        private void MultiplyChestCost(On.RoR2.PurchaseInteraction.orig_Awake orig, PurchaseInteraction self)
        {
            var chest = self.GetComponent <ChestBehavior>();

            if (chest && chest.tier3Chance == 1f)
            {
                var ResultAmt = (int)Mathf.Ceil(self.cost * CostMultiplier.Value);
                self.cost        = ResultAmt;
                self.Networkcost = ResultAmt;
            }
            orig(self);
        }
예제 #6
0
        private void RaiseChestPrices(On.RoR2.PurchaseInteraction.orig_Awake orig, PurchaseInteraction self)
        {
            orig(self);
            var chest = self.GetComponent <ChestBehavior>();

            if (ShouldIgnoreChestBehaviour(chest))
            {
                return;
            }

            self.cost = (int)Mathf.Ceil(self.cost * config.chestPriceCoefficient.Value);
        }
        private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
        {
            orig(self, activator);

            var shopTerminal = self.GetComponent <ShopTerminalBehavior>();
            var user         = UsersHelper.GetUser(activator);

            if (shopTerminal && user && CheckIfCostTypeIsItem(self.costType))
            {
                if (!watchedPrintedItems.ContainsKey(user.id))
                {
                    watchedPrintedItems[user.id] = new PrintedItems();
                }
                watchedPrintedItems[user.id].AddPrintedItem(shopTerminal.itemTier);
            }
        }
예제 #8
0
        private void UpdateShrineDisplay(ShrineHealingBehavior self)
        {
            PurchaseInteraction pi = self.GetFieldValue <PurchaseInteraction>("purchaseInteraction");

            if (clientCost == BALANCED_MODE)
            {
                pi.costType = CostTypeIndex.None;
                pi.cost     = BALANCED_MODE;
                pi.GetComponent <HologramProjector>().displayDistance   = 0f;
                self.GetComponent <HologramProjector>().displayDistance = 0f;
            }
            else
            {
                pi.costType = CostTypeIndex.Money;
                pi.cost     = clientCost;
            }
        }
예제 #9
0
        private string AddPickupNameToDisplay(On.RoR2.PurchaseInteraction.orig_GetDisplayName orig, PurchaseInteraction self)
        {
            var displayName = orig(self);

            var chest = self.GetComponent <ChestBehavior>();

            if (ShouldIgnoreChestBehaviour(chest))
            {
                return(displayName);
            }

            if (NetworkChestSync.instance.TryGetPickup(chest.netId, out PickupDef pickup))
            {
                return($"{displayName} ({GetStylizedPickupName(pickup)})");
            }

            Debug.LogWarning("Failed to get pickup for chest " + chest.netId);
            return(displayName);
        }
        public void SetUnlockedItemNotification(RoR2.UI.PingIndicator pingIndicator)
        {
            GenericPickupController pickupController = pingIndicator.pingTarget.GetComponent <GenericPickupController>();

            if (pickupController && _config.ShowItemNotification.Value)
            {
                BuildNotification(pickupController.pickupIndex, pingIndicator);
            }

            PurchaseInteraction purchaseInteraction = pingIndicator.pingTarget.GetComponent <PurchaseInteraction>();

            if (purchaseInteraction && _config.ShowItemNotification.Value)
            {
                ShopTerminalBehavior shopTerminalBehavior = purchaseInteraction.GetComponent <ShopTerminalBehavior>();
                if (shopTerminalBehavior && !shopTerminalBehavior.pickupIndexIsHidden)
                {
                    BuildNotification(shopTerminalBehavior.CurrentPickupIndex(), pingIndicator);
                }
            }
        }
예제 #11
0
 private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
 {
     if (SceneInfo.instance.countsAsStage)
     {
         if (!self.CanBeAffordedByInteractor(activator))
         {
             return;
         }
         MultiShopController usedShop = GetMultiShopController(self);
         if (usedShop != null)
         {
             self.GetComponent <ShopTerminalBehavior>().DropPickup();
             CharacterBody characterBody = activator.GetComponent <CharacterBody>();
             characterBody.master.GiveMoney((uint)-usedShop.Networkcost);
             gameMode.UpdateTerminals(usedShop);
             return;
         }
     }
     orig(self, activator);
 }
예제 #12
0
        private void LowerCosts(On.RoR2.PurchaseInteraction.orig_Awake orig, PurchaseInteraction self)
        {
            var chest          = self.GetComponent <ChestBehavior>();
            int InventoryCount = Util.GetItemCountForTeam(TeamIndex.Player, catalogIndex, false, true);

            if (chest)
            {
                if (InventoryCount > 0)
                {
                    //var ResultMultUnclamp = 1 - CostReductionAmount + CostReductionAmountStack * (InventoryCount - 1);
                    //var ResultMult = Mathf.Max(ResultMultUnclamp, 0);
                    //credit to harb+bord listam
                    var ResultMult = (CostReductionAmount + (1 - CostReductionAmount) * (1 - (CostReductionAmountLimit / Mathf.Pow(InventoryCount + CostReductionAmountLimit, CostReductionAmountPerStack))));
                    var ResultAmt  = (int)Mathf.Ceil(self.cost * ResultMult);
                    //Chat.AddMessage("Cost of chest reduced from" + self.cost + " to " + ResultAmt + " with multiplier "+ResultMult);
                    self.cost        = ResultAmt;
                    self.Networkcost = ResultAmt;
                }
            }
            orig(self);
        }
예제 #13
0
        private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
        {
            if (!self.CanBeAffordedByInteractor(activator))
            {
                return;
            }

            var characterBody = activator.GetComponent <CharacterBody>();
            var inventory     = characterBody.inventory;



            #region Cauldronfix

            // If this is not a multi-player server or the fix is disabled, do the normal drop action
            if (!GeneralHooks.IsMultiplayer() || !ShareSuite.PrinterCauldronFixEnabled.Value)
            {
                orig(self, activator);
                return;
            }

            var shop = self.GetComponent <ShopTerminalBehavior>();

            // If the cost type is an item, give the user the item directly and send the pickup message
            if (self.costType == CostTypeIndex.WhiteItem ||
                self.costType == CostTypeIndex.GreenItem ||
                self.costType == CostTypeIndex.RedItem ||
                self.costType == CostTypeIndex.BossItem ||
                self.costType == CostTypeIndex.LunarItemOrEquipment)
            {
                var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex;
                inventory.GiveItem(item);
                SendPickupMessage(inventory.GetComponent <CharacterMaster>(), shop.CurrentPickupIndex());
            }

            #endregion Cauldronfix

            orig(self, activator);
        }
예제 #14
0
            // Token: 0x0600261B RID: 9755 RVA: 0x000B0334 File Offset: 0x000AE534
            private void OnItemSpentOnPurchase(PurchaseInteraction purchaseInteraction, Interactor interactor)
            {
                CharacterBody currentBody = this.serverAchievementTracker.networkUser.GetCurrentBody();

                if (currentBody && currentBody.GetComponent <Interactor>() == interactor && purchaseInteraction.gameObject.name.Contains("Duplicator"))
                {
                    ShopTerminalBehavior component = purchaseInteraction.GetComponent <ShopTerminalBehavior>();
                    if (component)
                    {
                        ItemIndex itemIndex = component.CurrentPickupIndex().itemIndex;
                        if (this.trackingItemIndex != itemIndex)
                        {
                            this.trackingItemIndex = itemIndex;
                            this.progress          = 0;
                        }
                        this.progress++;
                        if (this.progress >= 7)
                        {
                            base.Grant();
                        }
                    }
                }
            }
예제 #15
0
        public void Awake()
        {
            InitConfig();

            //On.RoR2.PurchaseInteraction.OnTeleporterBeginCharging += PurchaseInteraction_OnTeleporterBeginCharging;

            On.RoR2.OutsideInteractableLocker.LockPurchasable += OutsideInteractableLocker_LockPurchasable;

            On.RoR2.SceneDirector.PlaceTeleporter += (orig, self) =>
                                                     //On.RoR2.SceneDirector.PopulateScene += (orig, self) =>
            {
                orig(self);
                if (!RoR2Application.isInSinglePlayer)
                {
                    SpawnShrineOfDio(self);
                }
            };

            On.RoR2.ShrineHealingBehavior.FixedUpdate += (orig, self) =>
            {
                orig(self);
                if (!NetworkServer.active)
                {
                    if (clientCost == UNINITIALIZED)
                    {
                        int piCost = self.GetFieldValue <PurchaseInteraction>("purchaseInteraction").cost;
                        if (piCost != clientCost)
                        {
                            clientCost = piCost;
                            if (clientCost == BALANCED_MODE)
                            {
                                isBalancedMode = true;
                            }
                            else
                            {
                                isBalancedMode = false;
                            }
                            Type[] arr = ((IEnumerable <System.Type>) typeof(ChestRevealer).Assembly.GetTypes()).Where <System.Type>((Func <System.Type, bool>)(t => typeof(IInteractable).IsAssignableFrom(t))).ToArray <System.Type>();
                            for (int i = 0; i < arr.Length; i++)
                            {
                                foreach (UnityEngine.MonoBehaviour instances in InstanceTracker.FindInstancesEnumerable(arr[i]))
                                {
                                    if (((IInteractable)instances).ShouldShowOnScanner())
                                    {
                                        string item = ((IInteractable)instances).ToString().ToLower();
                                        if (item.Contains("shrinehealing"))
                                        {
                                            UpdateShrineDisplay(instances.GetComponentInParent <ShrineHealingBehavior>());
                                        }
                                    }
                                    ;
                                }
                            }
                        }
                    }
                }
            };

            On.RoR2.Stage.Start += (orig, self) =>
            {
                orig(self);
                if (!RoR2Application.isInSinglePlayer && NetworkServer.active)
                {
                    isDead.Clear();
                }
            };

            On.RoR2.ShrineHealingBehavior.Awake += (orig, self) =>
            {
                orig(self);
                if (!RoR2Application.isInSinglePlayer)
                {
                    PurchaseInteraction pi = self.GetFieldValue <PurchaseInteraction>("purchaseInteraction");
                    pi.contextToken                = "Offer to the Shrine of Dio";
                    pi.displayNameToken            = "Shrine of Dio";
                    self.costMultiplierPerPurchase = 1f;


                    if (NetworkServer.active)
                    {
                        isBalancedMode = UseBalancedMode.Value;
                        if (UseBalancedMode.Value)
                        {
                            pi.costType = CostTypeIndex.None;
                            pi.cost     = BALANCED_MODE;
                            pi.GetComponent <HologramProjector>().displayDistance   = 0f;
                            self.GetComponent <HologramProjector>().displayDistance = 0f;
                        }
                        else
                        {
                            pi.costType = CostTypeIndex.Money;
                            pi.cost     = ResurrectionCost.Value;
                        }
                    }
                    else
                    {
                        clientCost = UNINITIALIZED;
                    }
                }
            };

            On.RoR2.ShrineHealingBehavior.AddShrineStack += (orig, self, interactor) =>
            {
                if (!RoR2Application.isInSinglePlayer)
                {
                    if (NetworkServer.active)
                    {
                        PlayerCharacterMasterController deadCharacter = GetRandomDeadCharacter();
                        isDead.Remove(deadCharacter.networkUser);

                        GameObject prefab = BodyCatalog.GetBodyPrefab(deadCharacter.networkUser.NetworkbodyIndexPreference);
                        if (prefab != null)
                        {
                            deadCharacter.master.bodyPrefab = prefab;
                        }
                        deadCharacter.master.Respawn(deadCharacter.master.GetFieldValue <Vector3>("deathFootPosition"), deadCharacter.master.transform.rotation, true);

                        string resurrectionMessage = $"<color=#beeca1>{interactor.GetComponent<CharacterBody>().GetUserName()}</color> resurrected <color=#beeca1>{deadCharacter.networkUser.userName}</color>";
                        Chat.SendBroadcastChat(new Chat.SimpleChatMessage
                        {
                            baseToken = resurrectionMessage
                        });

                        GameObject spawnEffect = Resources.Load <GameObject>("Prefabs/Effects/HippoRezEffect");
                        EffectManager.SpawnEffect(spawnEffect, new EffectData
                        {
                            origin   = deadCharacter.master.GetBody().footPosition,
                            rotation = deadCharacter.master.gameObject.transform.rotation
                        }, true);
                        self.SetFieldValue("waitingForRefresh", true);
                        self.SetFieldValue("refreshTimer", 2f);
                        EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData()
                        {
                            origin   = self.transform.position,
                            rotation = Quaternion.identity,
                            scale    = 1f,
                            color    = (Color32)Color.green
                        }, true);
                        // dio
                        CharacterBody cb = interactor.GetComponent <CharacterBody>();
                        if (UseBalancedMode.Value)
                        {
                            PurchaseInteraction pi = self.GetComponent <PurchaseInteraction>();
                            PurchaseInteraction.CreateItemTakenOrb(cb.corePosition, pi.gameObject, ItemIndex.ExtraLife);
                            cb.inventory.RemoveItem(ItemIndex.ExtraLife, 1);
                            cb.inventory.GiveItem(ItemIndex.ExtraLifeConsumed, 1);
                        }
                    }
                }
                else
                {
                    orig(self, interactor);
                }
            };

            On.RoR2.CharacterMaster.OnBodyDeath += (orig, self, masterbody) =>
            {
                orig(self, masterbody);
                if (!RoR2Application.isInSinglePlayer)
                {
                    if (NetworkServer.active)
                    {
                        if (masterbody.isPlayerControlled)
                        {
                            PlayerCharacterMasterController player = self.GetComponent <PlayerCharacterMasterController>();
                            if (!isDead.Contains(player.networkUser))
                            {
                                isDead.Add(player.networkUser);
                            }
                        }
                    }
                }
            };

            On.RoR2.PurchaseInteraction.CanBeAffordedByInteractor += (orig, self, interactor) =>
            {
                if (!RoR2Application.isInSinglePlayer)
                {
                    if (self.displayNameToken.Contains("Shrine of Dio") || self.displayNameToken.Contains("SHRINE_HEALING"))
                    {
                        if (isBalancedMode)
                        {
                            if (interactor.GetComponent <CharacterBody>().inventory.GetItemCount(ItemIndex.ExtraLife) > 0)
                            {
                                if (IsAnyoneDead())
                                {
                                    return(true);
                                }
                            }
                            return(false);
                        }
                        else
                        {
                            if (IsAnyoneDead())
                            {
                                return(orig(self, interactor));
                            }
                            return(false);
                        }
                    }
                    return(orig(self, interactor));
                }
                return(orig(self, interactor));
            };
        }
예제 #16
0
        public void Awake()
        {
            UseLongDescription = Config.Wrap("InfoOnPing", "UseLongDescription", "Whether to show the long description in chat when a pickup is pinged.", false);

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            On.RoR2.UI.PingIndicator.RebuildPing += (orig, self) =>
            {
                orig(self);
                try
                {
                    if (self.GetFieldValue <RoR2.UI.PingIndicator.PingType>("pingType") == RoR2.UI.PingIndicator.PingType.Interactable) // If object is an interactable
                    {
                        GameObject              target = self.pingTarget;
                        BarrelInteraction       BI     = target.GetComponent <BarrelInteraction>();       // Barrel Interactable info
                        PurchaseInteraction     PI     = target.GetComponent <PurchaseInteraction>();     // Purchase Interactable info
                        GenericPickupController GPC    = target.GetComponent <GenericPickupController>(); // Generic item pickup

                        if (BI)
                        {
                            Chat.AddMessage(ExtPingMessages.BarrelMessage(BI));        // Send chat message with name and rewards (gold, exp). Also shows exp needed for next level.
                            Chat.AddMessage(ExtPingMessages.ExpMessage());
                        }
                        else if (PI && PI.costType != CostTypeIndex.None)                                                       // If object is purchasable and has a valid cost type
                        {
                            if (PI.GetComponent <ShopTerminalBehavior>())                                                       // If object is a shop terminal, don't use normal purchasable behavior.
                            {
                                Chat.AddMessage(ExtPingMessages.ShopTerminalMessage(PI.GetComponent <ShopTerminalBehavior>())); // Send chat message with shown pickup name, cost and description
                            }
                            else
                            {
                                Chat.AddMessage(ExtPingMessages.PurchasableMessage(PI));   // Send chat message with name and price info (ex: Chest: $22, Shrine of Blood: 50% HP, etc).
                            }
                        }
                        else if (GPC) // If object is a pickup
                        {
                            PickupIndex pickupIdx = GPC.pickupIndex;
                            if (pickupIdx.itemIndex != ItemIndex.None)
                            {
                                Chat.AddMessage(ExtPingMessages.ItemMessage(pickupIdx));        // Send chat message with item name and description.
                            }
                            else if (pickupIdx.equipmentIndex != EquipmentIndex.None)
                            {
                                Chat.AddMessage(ExtPingMessages.EquipmentMessage(pickupIdx));   // Send chat message with equipment name and description.
                            }
                        }
                    }
                    else if (self.GetFieldValue <RoR2.UI.PingIndicator.PingType>("pingType") == RoR2.UI.PingIndicator.PingType.Enemy) // If object is an enemy/character
                    {
                        GameObject    target = self.pingTarget;
                        CharacterBody CB     = target.GetComponent <CharacterBody>();

                        if (CB)
                        {
                            Chat.AddMessage(ExtPingMessages.CharacterHeaderMessage(CB));
                            Chat.AddMessage(ExtPingMessages.CharacterHealthStatsMessage(CB));
                            Chat.AddMessage(ExtPingMessages.CharacterDamageStatsMessage(CB));
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
            };
        }
예제 #17
0
        private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig,
                                           PurchaseInteraction self, Interactor activator)
        {
            if (!self.CanBeAffordedByInteractor(activator))
            {
                return;
            }

            if (!GeneralHooks.IsMultiplayer())
            {
                orig(self, activator);
                return;
            }

            var shop = self.GetComponent <ShopTerminalBehavior>();

            #region Cauldronfix

            if (ShareSuite.PrinterCauldronFixEnabled.Value)
            {
                var characterBody = activator.GetComponent <CharacterBody>();
                var inventory     = characterBody.inventory;

                if (self.costType == CostTypeIndex.WhiteItem ||
                    self.costType == CostTypeIndex.GreenItem ||
                    self.costType == CostTypeIndex.RedItem ||
                    self.costType == CostTypeIndex.BossItem ||
                    self.costType == CostTypeIndex.LunarItemOrEquipment)
                {
                    var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex;
                    inventory.GiveItem(item);
                    ChatHandler.SendRichCauldronMessage(inventory.GetComponent <CharacterMaster>(),
                                                        shop.CurrentPickupIndex());
                    orig(self, activator);
                    return;
                }
            }

            #endregion Cauldronfix

            #region EquipDronefix

            if (ShareSuite.EquipmentShared.Value)
            {
                var rng       = self.GetComponent <Xoroshiro128Plus>();
                var itemIndex = ItemIndex.None;

                var costTypeDef = CostTypeCatalog.GetCostTypeDef(self.costType);
                if (shop)
                {
                    itemIndex = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex;
                }

                var payCostResults = costTypeDef.PayCost(self.cost,
                                                         activator, self.gameObject, rng, itemIndex);

                foreach (var equipmentIndex in payCostResults.equipmentTaken)
                {
                    //TODO fix equipment drones here
                }
            }
            #endregion EquipDronefix

            orig(self, activator);
        }
예제 #18
0
        private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig,
                                           PurchaseInteraction self, Interactor activator)
        {
            if (!self.CanBeAffordedByInteractor(activator))
            {
                return;
            }

            if (!GeneralHooks.IsMultiplayer())
            {
                orig(self, activator);
                return;
            }

            if (self.costType == CostTypeIndex.None)
            {
                orig(self, activator);
                return;
            }

            var shop = self.GetComponent <ShopTerminalBehavior>();

            #region Cauldronfix

            if (printerCosts.Contains(self.costType))
            {
                if (ShareSuite.PrinterCauldronFixEnabled.Value)
                {
                    var characterBody = activator.GetComponent <CharacterBody>();
                    var inventory     = characterBody.inventory;


                    var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex())?.itemIndex;

                    if (item == null)
                    {
                        RoR2.Console.print("ShareSuite: PickupCatalog is null.");
                    }
                    else
                    {
                        inventory.GiveItem(item.Value);
                    }

                    orig(self, activator);
                    ChatHandler.SendRichCauldronMessage(inventory.GetComponent <CharacterMaster>(),
                                                        shop.CurrentPickupIndex());
                    return;
                }
            }

            #endregion Cauldronfix

            #region EquipDronefix

            if (ShareSuite.EquipmentShared.Value)
            {
                if (self.costType == CostTypeIndex.Equipment)
                {
                    var rng       = self.GetComponent <Xoroshiro128Plus>();
                    var itemIndex = ItemIndex.None;

                    var costTypeDef = CostTypeCatalog.GetCostTypeDef(self.costType);
                    if (shop)
                    {
                        itemIndex = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex;
                    }

                    var payCostResults = costTypeDef.PayCost(self.cost,
                                                             activator, self.gameObject, rng, itemIndex);

                    if (payCostResults.equipmentTaken.Count >= 1)
                    {
                        orig(self, activator);
                        EquipmentSharingHooks.RemoveAllUnBlacklistedEquipment();
                        return;
                    }
                }
            }

            #endregion

            orig(self, activator);
        }
예제 #19
0
        private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
        {
            if (isCurrentStageBazaar())
            {
                NetworkUser  networkUser  = Util.LookUpBodyNetworkUser(activator.gameObject);
                BazaarPlayer bazaarPlayer = bazaar.GetBazaarPlayer(networkUser);
                if (!self.CanBeAffordedByInteractor(activator))
                {
                    return;
                }

                if (bazaar.IsMoneyLunarPodAvailable())
                {
                    if (bazaar.IsMoneyLunarPod(self.gameObject))
                    {
                        if (bazaarPlayer.lunarExchanges < ModConfig.maxLunarExchanges.Value || ModConfig.infiniteLunarExchanges)
                        {
                            bazaarPlayer.lunarExchanges++;
                            int money = bazaar.GetLunarCoinExchangeMoney();
                            if (!ModConfig.IsShareSuiteMoneySharing())
                            {
                                activator.GetComponent <CharacterBody>().master.money += ((uint)money);
                            }
                            else
                            {
                                //ShareSuite.MoneySharingHooks.AddMoneyExternal(money);
                                bazaar.ShareSuiteMoneyFix(activator, money);
                            }
                            //activator.GetComponent<CharacterBody>().master.money += ((uint)money);
                            //activator.GetComponent<CharacterBody>().master.GiveMoney((uint)money);
                            networkUser.DeductLunarCoins((uint)self.cost);
                            var        goldReward          = (int)((double)ModConfig.lunarCoinWorth.Value * (double)bazaar.CurrentDifficultyCoefficient);
                            GameObject coinEmitterResource = Resources.Load <GameObject>("Prefabs/Effects/CoinEmitter");
                            EffectManager.SpawnEffect(coinEmitterResource, new EffectData()
                            {
                                origin       = self.transform.position,
                                genericFloat = (float)goldReward
                            }, true);
                            EffectManager.SpawnEffect(coinEmitterResource, new EffectData()
                            {
                                origin       = self.transform.position,
                                genericFloat = (float)goldReward
                            }, true);
                            Util.PlaySound("Play_UI_coin", self.gameObject);
                        }

                        return;
                    }
                }
                // New addition that made everything less nice. Added to check if player still has purchases left
                int bazaarChestIndex            = -1;
                List <BazaarItem>   bazaarItems = bazaar.GetBazaarItems();
                PurchaseInteraction bazaarPI;
                for (int i = 0; i < bazaarItems.Count; i++)
                {
                    // Fix for SavedGames. SavedGames somehow breaks the BiggerBazaar chests and BiggerBazaar breaks everything else in return :)
                    if (bazaarItems[i].chestBehavior == null)
                    {
                        continue;
                    }
                    bazaarPI = bazaarItems[i].chestBehavior.GetComponent <PurchaseInteraction>();
                    if (bazaarPI.Equals(self))
                    {
                        if (!bazaar.PlayerHasPurchasesLeft(bazaarPlayer))
                        {
                            return;
                        }

                        //ItemTier tier = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(bazaarItems[i].pickupIndex).itemIndex).tier;
                        PickupTier pickupTier = PickupIndexToPickupTier(bazaarItems[i].pickupIndex);
                        if (!bazaar.PlayerHasTierPurchasesLeft(pickupTier, bazaarPlayer))
                        {
                            return;
                        }
                        if (ModConfig.ShareSuite != null && ModConfig.ShareSuiteTotalPurchaseSharing.Value)
                        {
                            bazaar.GetBazaarPlayers().ForEach(x => x.chestPurchases++);
                        }
                        else
                        {
                            bazaarPlayer.chestPurchases++;
                        }

                        bazaarPlayer.IncreaseTierPurchase(pickupTier);
                        bazaarChestIndex = i;
                        break;
                    }
                }
                // Special case for ShareSuite
                if (ModConfig.isShareSuiteActive() && !ModConfig.ShareSuiteItemSharingEnabled.Value)
                {
                    if (bazaarChestIndex != -1)
                    {
                        CharacterMaster master      = activator.GetComponent <CharacterBody>().master;
                        var             isEquipment = PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).equipmentIndex == EquipmentIndex.None ? false : true;
                        if (!isEquipment)
                        {
                            master.inventory.GiveItem(PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).itemIndex);
                        }
                        else
                        {
                            if (!ModConfig.isShareSuiteEquipmentSharing())
                            {
                                PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(master.inventory.GetEquipmentIndex()), master.GetBody().gameObject.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + self.transform.forward * 2f);
                            }
                            master.inventory.SetEquipmentIndex(PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).equipmentIndex);
                        }


                        if (ModConfig.chestCostType.Value == 1)
                        {
                            var netUser = Util.LookUpBodyNetworkUser(master.GetBody());
                            netUser.DeductLunarCoins((uint)self.cost);
                        }
                        else
                        {
                            if (!ModConfig.IsShareSuiteMoneySharing())
                            {
                                master.money -= (uint)self.cost;
                            }
                            else
                            {
                                //ShareSuite.MoneySharingHooks.AddMoneyExternal(-self.cost);
                                bazaar.ShareSuiteMoneyFix(activator, -self.cost);
                            }
                        }

                        bazaarItems[bazaarChestIndex].purchaseCount++;
                        if (!bazaar.IsChestStillAvailable(bazaarItems[bazaarChestIndex]))
                        {
                            self.GetComponent <PurchaseInteraction>().SetAvailable(false);
                        }

                        Vector3 effectPos = self.transform.position;
                        effectPos.y -= 1;
                        EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData()
                        {
                            origin   = effectPos,
                            rotation = Quaternion.identity,
                            scale    = 0.01f,
                            color    = (Color32)Color.yellow
                        }, true);
                        PurchaseInteraction.CreateItemTakenOrb(self.gameObject.transform.position, activator.GetComponent <CharacterBody>().gameObject, PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).itemIndex);

                        return;
                    }
                }
            }
            orig(self, activator);
        }