private void PreventTerminalsIfNoItems(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self) { if (!self.doEquipmentInstead && ItemTierAvailable(self.itemTier)) { orig(self); } }
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); }
public void CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, RoR2.MultiShopController self) { int index = MultiShop.instances.Count; // I don't super like this ItemTierShopConfig itemTierConfig = ModConfig.tierWeights[index]; self.itemTier = itemTierConfig.itemTier; self.Networkcost = itemTierConfig.price; MultiShop.CreateTerminals(orig, self, itemTierConfig); }
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); }
private void MultiShopController_on_CreateTerminals1(On.RoR2.MultiShopController.orig_CreateTerminals orig, RoR2.MultiShopController self) { orig(self); int count = 0; bool allSame = true; GameObject[] terminals = self.GetFieldValue <GameObject[]>("terminalGameObjects"); ShopTerminalBehavior lastSTB = null; foreach (GameObject terminal in terminals) { var stb = terminal.GetComponent <ShopTerminalBehavior>(); if (stb) { if (stb.pickupIndexIsHidden) { count++; } if (allSame && lastSTB && lastSTB.CurrentPickupIndex() != stb.CurrentPickupIndex()) { allSame = false; } lastSTB = stb; } else { count = -1; allSame = false; base.Logger.LogError("Something was wrong with a terminal, aborting."); break; } } if (count == terminals.Length && lastSTB) { var pre = lastSTB.CurrentPickupIndex(); var pre2 = lastSTB.pickupIndexIsHidden; lastSTB.SetPickupIndex(lastSTB.CurrentPickupIndex(), false); Logger.LogMessage(string.Format("All question marks. Unhiding the last terminal. ({0},{1} -> {2},{3})", pre, pre2, lastSTB.CurrentPickupIndex(), lastSTB.pickupIndexIsHidden)); } if (allSame && lastSTB) { var pre = lastSTB.CurrentPickupIndex(); var pre2 = lastSTB.pickupIndexIsHidden; lastSTB.selfGeneratePickup = true; lastSTB.Start(); Logger.LogMessage(string.Format("All same. Making the last terminal reroll itself. ({0},{1} -> {2},{3})", pre, pre2, lastSTB.CurrentPickupIndex(), lastSTB.pickupIndexIsHidden)); } }
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; } } } }
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); }
private void MultiShopController_on_CreateTerminals1(On.RoR2.MultiShopController.orig_CreateTerminals orig, RoR2.MultiShopController self) { orig(self); int questionCount = 0; int sameCount = 0; List <PickupIndex> pickups = new List <PickupIndex>(); Xoroshiro128Plus rng = self.GetFieldValue <Xoroshiro128Plus>("rng"); GameObject[] terminals = self.GetFieldValue <GameObject[]>("terminalGameObjects"); ShopTerminalBehavior[] behaviors = new ShopTerminalBehavior[3]; for (int i = 0; i < 3; i++) { GameObject terminal = terminals[i]; ShopTerminalBehavior stb = terminal.GetComponent <ShopTerminalBehavior>(); behaviors[i] = stb; if (stb) { bool shopDirty = false; bool hidden = stb.pickupIndexIsHidden; if (hidden) { questionCount++; if (questionCount > maxQuestions.Value) { hidden = false; shopDirty |= true; } } PickupIndex pickupIndex = stb.CurrentPickupIndex(); if (pickups.Contains(pickupIndex)) { sameCount++; if (sameCount > maxSame.Value) { shopDirty |= true; switch (self.itemTier) { case ItemTier.Tier1: pickupIndex = rng.NextElementUniform(Run.instance.availableTier1DropList); break; case ItemTier.Tier2: pickupIndex = rng.NextElementUniform(Run.instance.availableTier2DropList); break; case ItemTier.Tier3: pickupIndex = rng.NextElementUniform(Run.instance.availableTier3DropList); break; case ItemTier.Lunar: pickupIndex = rng.NextElementUniform(Run.instance.availableLunarDropList); break; } } } pickups.Add(pickupIndex); if (shopDirty) { stb.SetPickupIndex(pickupIndex, hidden); } } else { TweakLogger.LogWarning("MultiShopImprovements", "Something was wrong with a terminal, aborting."); return; } } while (questionCount > maxQuestions.Value) { questionCount--; behaviors[questionCount].SetPickupIndex(pickups[questionCount], false); } if (sameCount > maxSame.Value) { } }
private void MultiShopController_CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self) { gameMode.CreateTerminals(orig, self); }