IEnumerator WaitForStart(MultiShopController multiShop)
        {
            yield return(null);

            foreach (var item in (GameObject[])getTerminalGameObjects.GetValue(multiShop))
            {
                var purchaseInteraction = item.GetComponent <PurchaseInteraction>();
                var shopTerminal        = item.GetComponent <ShopTerminalBehavior>();

                shopTerminal.SetPickupIndex(new PickupIndex((ItemIndex)itemIndexes[0]), hidden[0]);

                hidden.RemoveAt(0);
                itemIndexes.RemoveAt(0);

                purchaseInteraction.Networkcost = cost;
                purchaseInteraction.SetAvailable(available);
            }

            multiShop.SetFieldValue("cost", cost);
        }
Beispiel #2
0
        public static void CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self, ItemTierShopConfig itemTierConfig)
        {
            // Boss Items and Equipment can not be part of multi shops by default, so needs a special case
            List <PickupIndex> otherItemsList = new List <PickupIndex>();

            if (itemTierConfig.itemTier == ItemTier.Boss)
            {
                var itemIndexList = R2API.ItemDropAPI.GetDefaultDropList(ItemTier.Boss);
                foreach (var itemIndex in itemIndexList)
                {
                    otherItemsList.Add(new PickupIndex(itemIndex));
                }
            }
            else if (itemTierConfig.itemTier == ItemTier.NoTier && itemTierConfig.isEquipment)
            {
                var itemIndexList = R2API.ItemDropAPI.GetDefaultEquipmentDropList();
                foreach (var itemIndex in itemIndexList)
                {
                    otherItemsList.Add(new PickupIndex(itemIndex));
                }
            }
            if (otherItemsList.Count > 0)
            {
                self.SetFieldValue("terminalGameObjects", new GameObject[self.terminalPositions.Length]);
                for (int i = 0; i < self.terminalPositions.Length; i++)
                {
                    PickupIndex      newPickupIndex = PickupIndex.none;
                    Xoroshiro128Plus treasureRng    = Run.instance.treasureRng;
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(otherItemsList);
                    bool       newHidden  = Run.instance.treasureRng.nextNormalizedFloat < 0.2f;
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(self.terminalPrefab, self.terminalPositions[i].position, self.terminalPositions[i].rotation);
                    self.GetFieldValue <GameObject[]>("terminalGameObjects")[i] = gameObject;
                    gameObject.GetComponent <ShopTerminalBehavior>().SetPickupIndex(newPickupIndex, newHidden);
                    NetworkServer.Spawn(gameObject);
                }
                return;
            }

            orig(self);
        }