Esempio n. 1
0
        public void UpdateTerminals(MultiShopController self)
        {
            // choose random item tier
            ItemTierShopConfig itemTierConfig = PickRandomItemTier();

            MultiShop.RepopulateTerminals(self, itemTierConfig);
        }
Esempio n. 2
0
        public static void RepopulateTerminals(MultiShopController multiShopController, ItemTierShopConfig itemTierConfig)
        {
            GameObject[] terminalGameObjects = multiShopController.GetFieldValue <GameObject[]>("terminalGameObjects");
            for (int i = 0; i < multiShopController.terminalPositions.Length; i++)
            {
                List <PickupIndex> otherItemsList = new List <PickupIndex>();
                PickupIndex        newPickupIndex = PickupIndex.none;
                Xoroshiro128Plus   treasureRng    = Run.instance.treasureRng;
                switch (itemTierConfig.itemTier)
                {
                case ItemTier.Tier1:
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier1DropList);
                    break;

                case ItemTier.Tier2:
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier2DropList);
                    break;

                case ItemTier.Tier3:
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier3DropList);
                    break;

                case ItemTier.Lunar:
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableLunarDropList);
                    break;

                case ItemTier.Boss:
                    otherItemsList = new List <PickupIndex>();
                    var bossItemIndexList = R2API.ItemDropAPI.GetDefaultDropList(ItemTier.Boss);
                    foreach (var itemIndex in bossItemIndexList)
                    {
                        otherItemsList.Add(new PickupIndex(itemIndex));
                    }
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(otherItemsList);
                    break;

                case ItemTier.NoTier:
                    if (itemTierConfig.isEquipment)
                    {
                        otherItemsList = new List <PickupIndex>();
                        var equipmentIndexList = R2API.ItemDropAPI.GetDefaultEquipmentDropList();
                        foreach (var itemIndex in equipmentIndexList)
                        {
                            otherItemsList.Add(new PickupIndex(itemIndex));
                        }
                        newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(otherItemsList);
                        //self.itemTier = ItemTier.Tier1;
                    }
                    break;
                }
                bool newHidden = Run.instance.treasureRng.nextNormalizedFloat < 0.2f;
                terminalGameObjects[i].GetComponent <ShopTerminalBehavior>().SetPickupIndex(newPickupIndex, newHidden);
            }
        }
Esempio n. 3
0
        public static MultiShop GetMultiShopFromController(MultiShopController multiShopController)
        {
            foreach (MultiShop multiShop in instances)
            {
                if (multiShop.multiShopController == multiShopController)
                {
                    return(multiShop);
                }
            }

            return(null);
        }
 private void On_MultiShopController_DisableAllTerminals(
     On.RoR2.MultiShopController.orig_DisableAllTerminals orig,
     MultiShopController self, Interactor interactor)
 {
     orig(self, interactor);
     if (ShouldApplyToMultishops.Value)
     {
         DynData <MultiShopController> controllerData = new DynData <MultiShopController>(self);
         GameObject[] terminalGameObjects             = controllerData.Get <GameObject[]>("terminalGameObjects");
         foreach (GameObject terminalObject in terminalGameObjects)
         {
             terminalObject.AddComponent <FadeObject>();
         }
     }
 }
        public MultiShopData(MultiShopController multiShop)
        {
            transform = new SerializableTransform(multiShop.transform);
            name      = multiShop.name.Replace("(Clone)", "");

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

                itemIndexes.Add((int)shopTerminal.GetFieldValue <PickupIndex>("pickupIndex").itemIndex);
                hidden.Add((bool)shopTerminal.pickupIndexIsHidden);
            }

            cost      = multiShop.GetFieldValue <int>("cost");
            available = multiShop.GetFieldValue <bool>("available");
        }
Esempio n. 6
0
        public void SpawnShop(Xoroshiro128Plus xoroshiro128Plus)
        {
            SpawnCard  card = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscTripleShop");
            GameObject multiShopGameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(card, new DirectorPlacementRule
            {
                maxDistance   = 30f,
                minDistance   = 10f,
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                position      = TeleporterInteraction.instance.transform.position
            }, xoroshiro128Plus));

            float   startPosOffsetY = 0; // -7.2f;
            Vector3 endPosition     = multiShopGameObject.transform.position;

            multiShopGameObject.transform.position = new Vector3(multiShopGameObject.transform.position.x, multiShopGameObject.transform.position.y + startPosOffsetY, multiShopGameObject.transform.position.z);

            MultiShopController        multiShopController     = multiShopGameObject.GetComponent <MultiShopController>();
            List <PurchaseInteraction> purchaseInteractionList = new List <PurchaseInteraction>();

            GameObject[] terminalGameObjects = multiShopController.GetFieldValue <GameObject[]>("terminalGameObjects");
            for (int k = 0; k < terminalGameObjects.Length; k++)
            {
                purchaseInteractionList.Add(terminalGameObjects[k].GetComponent <PurchaseInteraction>());
                terminalGameObjects[k].gameObject.transform.position = new Vector3(terminalGameObjects[k].gameObject.transform.position.x, terminalGameObjects[k].gameObject.transform.position.y + startPosOffsetY, terminalGameObjects[k].gameObject.transform.position.z);
            }

            //EffectManager.instance.SpawnEffect(Resources.Load<GameObject>("Prefabs/Effects/BeetleQueenBurrow"), new EffectData()
            EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/TeleportOutBoom"), new EffectData()
            {
                origin   = endPosition,
                rotation = Quaternion.identity
            }, true);

            MultiShop.terminalOffset = Math.Abs(terminalGameObjects[0].gameObject.transform.position.y - multiShopGameObject.transform.position.y);

            MultiShop multiShop = new MultiShop
            {
                multiShopController          = multiShopController,
                terminalPurchaseInteractions = purchaseInteractionList,
                endPosition = endPosition
            };

            MultiShop.instances.Add(multiShop);
        }
        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);
        }
Esempio n. 8
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);
 }
Esempio n. 9
0
 private void PreventTerminalsIfNoItems(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self)
 {
     if (!self.doEquipmentInstead && ItemTierAvailable(self.itemTier))
     {
         orig(self);
     }
 }
Esempio n. 10
0
 public static void Track_MultiShopCrontroller_Add(On.RoR2.MultiShopController.orig_Awake orig, MultiShopController self)
 {
     orig(self);
     InstanceTracker.Add(self);
 }
Esempio n. 11
0
 public static void Track_MultiShopCrontroller_Remove(On.RoR2.MultiShopController.orig_OnDestroy orig, MultiShopController self)
 {
     orig(self);
     InstanceTracker.Remove(self);
 }
Esempio n. 12
0
        private void MultishopNoDuplicates(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self)
        {
            orig(self);


            List <ShopTerminalBehavior> terminalBehaviors = new List <ShopTerminalBehavior>();

            foreach (GameObject gameObject in self.GetFieldValue <GameObject[]>("terminalGameObjects"))
            {
                if (gameObject.GetComponent <ShopTerminalBehavior>())
                {
                    terminalBehaviors.Add(gameObject.GetComponent <ShopTerminalBehavior>());
                }
            }

            List <PickupIndex> pickups = new List <PickupIndex>();

            foreach (ShopTerminalBehavior shopTerminalBehavior in terminalBehaviors)
            {
                pickups.Add(shopTerminalBehavior.NetworkpickupIndex);
            }

            foreach (ShopTerminalBehavior shopTerminalBehavior in terminalBehaviors)
            {
                if (pickups.FindAll(x => x == shopTerminalBehavior.NetworkpickupIndex).Count > 1)
                {
                    switch (self.itemTier)
                    {
                    case ItemTier.Tier1:
                        shopTerminalBehavior.SetPickupIndex(Run.instance.treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier1DropList));
                        break;

                    case ItemTier.Tier2:
                        shopTerminalBehavior.SetPickupIndex(Run.instance.treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier2DropList));
                        break;

                    case ItemTier.Tier3:
                        shopTerminalBehavior.SetPickupIndex(Run.instance.treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier3DropList));
                        break;

                    case ItemTier.Lunar:
                        shopTerminalBehavior.SetPickupIndex(Run.instance.treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableLunarDropList));
                        break;
                    }
                }
            }
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
 private void RaiseMultishopPrices(On.RoR2.MultiShopController.orig_Start orig, MultiShopController self)
 {
     orig(self);
     self.Networkcost = (int)(self.Networkcost * config.multiShopPriceCoefficient.Value);
     if (self.GetFieldValue <GameObject[]>("terminalGameObjects") is GameObject[] terminalGameObjects)
     {
         GameObject[] array = terminalGameObjects;
         for (int i = 0; i < array.Length; i++)
         {
             PurchaseInteraction component = array[i].GetComponent <PurchaseInteraction>();
             component.Networkcost = self.Networkcost;
             component.costType    = self.costType;
         }
     }
 }
Esempio n. 15
0
 private void MultiShopController_DisableAllTerminals(On.RoR2.MultiShopController.orig_DisableAllTerminals orig, MultiShopController self, Interactor interactor)
 {
     orig(self, interactor);
     foreach (GameObject gameObject in self.terminalGameObjects)
     {
         RemoveIndicator(gameObject);
     }
 }
Esempio n. 16
0
        public void CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self)
        {
            // choose random item tier
            ItemTierShopConfig itemTierConfig = PickRandomItemTier();

            self.itemTier    = itemTierConfig.itemTier;
            self.Networkcost = 1;
            MultiShop.CreateTerminals(orig, self, itemTierConfig);
        }
Esempio n. 17
0
        private void MultiShopController_CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self)
        {
            if (!RunArtifactManager.instance.IsArtifactEnabled(_content.Artifact))
            {
                orig(self);
                return;
            }

            if (self.doEquipmentInstead)
            {
                orig(self);
                return;
            }

            var rng = (Xoroshiro128Plus)typeof(MultiShopController).GetField("rng", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(self);

            if (rng == null)
            {
                orig(self);
                return;
            }

            var val = rng.RangeFloat(0, 1);

            if (val > 0.975f)
            {
                self.itemTier = ItemTier.Tier3;
                self.baseCost = 400;
            }
            else if (val > 0.8f)
            {
                self.itemTier = ItemTier.Tier2;
                self.baseCost = 50;
            }
            else
            {
                self.itemTier = ItemTier.Tier1;
                self.baseCost = 25;
            }

            self.Networkcost = Run.instance.GetDifficultyScaledCost(self.baseCost);

            var terminalGameObjects = (GameObject[])typeof(MultiShopController).GetField("terminalGameObjects", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(self);

            if (terminalGameObjects != null)
            {
                foreach (var terminalGameObject in terminalGameObjects)
                {
                    var purchaseInteraction = terminalGameObject.GetComponent <PurchaseInteraction>();
                    purchaseInteraction.Networkcost = self.Networkcost;
                }
            }

            orig(self);
        }
Esempio n. 18
0
 private void MultiShopController_CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self)
 {
     gameMode.CreateTerminals(orig, self);
 }