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) { } }
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); }
public void UpdateTerminals(RoR2.MultiShopController self) { MultiShop.RepopulateTerminals(self, MultiShop.RetrieveItemTierConfig(ModConfig.tierWeights, self.itemTier)); }
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)); } }