public override void OnEnableFsm(PlayMakerFSM fsm) { if (fsm.FsmName == fsmName && fsm.gameObject.name == objectName) { ShopMenuStock shop = fsm.gameObject.GetComponent <ShopMenuStock>(); GameObject itemPrefab = UnityEngine.Object.Instantiate(shop.stock[0]); itemPrefab.SetActive(false); shop.stock = GetNewStock(shop.stock, itemPrefab); if (shop.stockAlt != null) { shop.stockAlt = GetNewAltStock(shop.stock, shop.stockAlt, itemPrefab); } } }
public override void Process(string scene, Object changeObj) { if (scene != SceneName) { return; } // Find the shop and save an item for use later GameObject shopObj = GameObject.Find(ObjectName); ShopMenuStock shop = shopObj.GetComponent <ShopMenuStock>(); GameObject itemPrefab = Object.Instantiate(shop.stock[0]); itemPrefab.SetActive(false); // Remove all charm type items from the store List <GameObject> newStock = new List <GameObject>(); foreach (ShopItemDef itemDef in _items) { // Create a new shop item for this item def GameObject newItemObj = Object.Instantiate(itemPrefab); newItemObj.SetActive(false); // Apply all the stored values ShopItemStats stats = newItemObj.GetComponent <ShopItemStats>(); stats.playerDataBoolName = itemDef.PlayerDataBoolName; stats.nameConvo = itemDef.NameConvo; stats.descConvo = itemDef.DescConvo; stats.requiredPlayerDataBool = itemDef.RequiredPlayerDataBool; stats.removalPlayerDataBool = itemDef.RemovalPlayerDataBool; stats.dungDiscount = itemDef.DungDiscount; stats.notchCostBool = itemDef.NotchCostBool; stats.cost = itemDef.Cost; // Need to set all these to make sure the item doesn't break in one of various ways stats.priceConvo = string.Empty; stats.specialType = 2; stats.charmsRequired = 0; stats.relic = false; stats.relicNumber = 0; stats.relicPDInt = string.Empty; // Apply the sprite for the UI stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite = RandomizerMod.GetSprite(itemDef.SpriteName); newStock.Add(newItemObj); } foreach (GameObject item in shop.stock) {// Update normal stock (specialType: 0 = lantern, elegant key, quill; 1 = mask, 2 = charm, 3 = vessel, 4-7 = relics, 8 = notch, 9 = map, 10 = simple key, 11 = egg, 12-14 = repair fragile, 15 = salubra blessing, 16 = map pin, 17 = map marker) if (RandomizerMod.Instance.Settings.RandomizeMaps) { if (item.GetComponent <ShopItemStats>().specialType == 9 || item.GetComponent <ShopItemStats>().playerDataBoolName == "hasQuill") { continue; } } string shopBool = item.GetComponent <ShopItemStats>().playerDataBoolName; if (!LogicManager.HasItemWithShopBool(shopBool)) { // LogicManager doesn't know about this shop item, which means it's never potentially randomized. Put it back! if (!(shopBool.StartsWith("salubraNotch") && RandomizerMod.Instance.Settings.CharmNotch)) { // If Salubra QOL is off, we need to add these notches back into her shop. newStock.Add(item); } } } shop.stock = newStock.ToArray(); // Update alt stock; Sly only if (shop.stockAlt != null) { // Save unchanged list for potential alt stock List <GameObject> altStock = new List <GameObject>(); altStock.AddRange(newStock); foreach (GameObject item in shop.stockAlt) { string shopBool = item.GetComponent <ShopItemStats>().playerDataBoolName; if (!LogicManager.HasItemWithShopBool(shopBool) && !newStock.Contains(item)) { altStock.Add(item); } } shop.stockAlt = altStock.ToArray(); } }
public override void Process(string scene, Object changeObj) { if (scene != SceneName) { return; } // Find the shop and save an item for use later GameObject shopObj = GameObject.Find(ObjectName); ShopMenuStock shop = shopObj.GetComponent <ShopMenuStock>(); GameObject itemPrefab = Object.Instantiate(shop.stock[0]); itemPrefab.SetActive(false); // Remove all charm type items from the store List <GameObject> newStock = new List <GameObject>(); foreach (ShopItemDef itemDef in _items) { // Create a new shop item for this item def GameObject newItemObj = Object.Instantiate(itemPrefab); newItemObj.SetActive(false); // Apply all the stored values ShopItemStats stats = newItemObj.GetComponent <ShopItemStats>(); stats.playerDataBoolName = itemDef.PlayerDataBoolName; stats.nameConvo = itemDef.NameConvo; stats.descConvo = itemDef.DescConvo; stats.requiredPlayerDataBool = itemDef.RequiredPlayerDataBool; stats.removalPlayerDataBool = itemDef.RemovalPlayerDataBool; stats.dungDiscount = itemDef.DungDiscount; stats.notchCostBool = itemDef.NotchCostBool; stats.cost = itemDef.Cost; // Need to set all these to make sure the item doesn't break in one of various ways stats.priceConvo = string.Empty; stats.specialType = 2; stats.charmsRequired = 0; stats.relic = false; stats.relicNumber = 0; stats.relicPDInt = string.Empty; // Apply the sprite for the UI stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite = RandomizerMod.GetSprite(itemDef.SpriteName); newStock.Add(newItemObj); } // Save unchanged list for potential alt stock List <GameObject> altStock = new List <GameObject>(); altStock.AddRange(newStock); // Update normal stock foreach (GameObject item in shop.stock) { // It would be cleaner to destroy the unused objects, but that breaks the shop on subsequent loads // TC must be reusing the shop items rather than destroying them on load if (item.GetComponent <ShopItemStats>().specialType != 2) { newStock.Add(item); } } shop.stock = newStock.ToArray(); // Update alt stock if (shop.stockAlt != null) { foreach (GameObject item in shop.stockAlt) { if (item.GetComponent <ShopItemStats>().specialType != 2) { altStock.Add(item); } } shop.stockAlt = altStock.ToArray(); } }
public static void SetShopItems(GameObject shopObj, string[] items) { ShopMenuStock shop = shopObj.GetComponent <ShopMenuStock>(); GameObject itemPrefab = UObject.Instantiate(shop.stock[0]); itemPrefab.transform.SetPosition2D(-1000, -1000); // Remove all charm type items from the store List <GameObject> newStock = new List <GameObject>(); foreach (string itemId in items) { Item item = RandoResources.Items.First(i => i.Id == itemId.Substring(0, itemId.IndexOf('.'))); if (!item.TryGetNextStage(out ItemStage stage)) { continue; } // Create a new shop item for this item def GameObject newItemObj = UObject.Instantiate(itemPrefab); // Apply all the stored values ShopItemStats stats = newItemObj.GetComponent <ShopItemStats>(); stats.playerDataBoolName = RandomizerMod.Instance.ItemPlacements[itemId] + "." + itemId; stats.nameConvo = stage.Shop.Name; stats.descConvo = stage.Shop.Description; stats.requiredPlayerDataBool = "CheckHasRequired." + RandomizerMod.Instance.ItemPlacements[itemId]; stats.notchCostBool = string.Empty; stats.cost = RandomizerMod.Instance.ItemCosts[itemId]; // Need to set all these to make sure the item doesn't break in one of various ways stats.priceConvo = ""; stats.specialType = 2; stats.charmsRequired = 0; stats.relicNumber = 0; // Apply the sprite for the UI stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite = Sprites.Get(stage.Shop.Sprite); UObject.Destroy(stats.transform.Find("Item Sprite").gameObject.LocateMyFSM("get_charm_sprite")); newStock.Add(newItemObj); } UObject.Destroy(itemPrefab); foreach (GameObject item in shop.stock) { // Update normal stock (specialType: 0 = lantern, elegant key, quill; 1 = mask, 2 = charm, 3 = vessel, 4-7 = relics, 8 = notch, 9 = map, 10 = simple key, 11 = egg, 12-14 = repair fragile, 15 = salubra blessing, 16 = map pin, 17 = map marker) if (item.GetComponent <ShopItemStats>().specialType == 9 || item.GetComponent <ShopItemStats>().playerDataBoolName == "hasQuill") { continue; } string shopBool = item.GetComponent <ShopItemStats>().playerDataBoolName; if (!RandoResources.Items.Any(i => i.Stages.Any(s => s.BoolActions.Any(b => b.FieldName == shopBool))) && !shopBool.StartsWith("salubraNotch")) { // LogicManager doesn't know about this shop item, which means it's never potentially randomized. Put it back! newStock.Add(item); } } shop.stock = newStock.ToArray(); // Update alt stock; Sly only if (shop.stockAlt != null) { // Save unchanged list for potential alt stock List <GameObject> altStock = new List <GameObject>(); altStock.AddRange(newStock); foreach (GameObject item in shop.stockAlt) { string shopBool = item.GetComponent <ShopItemStats>().playerDataBoolName; if (!RandoResources.Items.Any(i => i.Stages.Any(s => s.BoolActions.Any(b => b.FieldName == shopBool))) && !newStock.Contains(item)) { altStock.Add(item); } } shop.stockAlt = altStock.ToArray(); } FSMUtility.SendEventToGameObject(GameObject.Find("Item List"), "RESET"); }
public override void Process(string scene, Object changeObj) { if (scene != SceneName) { return; } // Find the shop and save an item for use later GameObject shopObj = GameObject.Find(ObjectName); ShopMenuStock shop = shopObj.GetComponent <ShopMenuStock>(); GameObject itemPrefab = Object.Instantiate(shop.stock[0]); itemPrefab.SetActive(false); // Remove all charm type items from the store List <GameObject> newStock = new List <GameObject>(); foreach (ShopItemDef itemDef in _items) { // Create a new shop item for this item def GameObject newItemObj = Object.Instantiate(itemPrefab); newItemObj.SetActive(false); // Apply all the stored values ShopItemStats stats = newItemObj.GetComponent <ShopItemStats>(); stats.playerDataBoolName = itemDef.PlayerDataBoolName; stats.nameConvo = itemDef.NameConvo; stats.descConvo = itemDef.DescConvo; stats.requiredPlayerDataBool = itemDef.RequiredPlayerDataBool; stats.removalPlayerDataBool = itemDef.RemovalPlayerDataBool; stats.dungDiscount = itemDef.DungDiscount; stats.notchCostBool = itemDef.NotchCostBool; stats.cost = itemDef.Cost; // Need to set all these to make sure the item doesn't break in one of various ways stats.priceConvo = string.Empty; stats.specialType = 2; stats.charmsRequired = 0; stats.relic = false; stats.relicNumber = 0; stats.relicPDInt = string.Empty; // Apply the sprite for the UI stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite = AreaRando.GetSprite(itemDef.SpriteName); newStock.Add(newItemObj); } // Save unchanged list for potential alt stock List <GameObject> altStock = new List <GameObject>(); altStock.AddRange(newStock); // Update normal stock //specialType: 0 = lantern, elegant key, quill; 1 = mask, 2 = charm, 3 = vessel, 4-7 = relics, 8 = notch, 9 = map, 10 = simple key, 11 = egg, 12-14 = repair fragile, 15 = salubra blessing, 16 = map pin, 17 = map marker foreach (GameObject item in shop.stock) { // It would be cleaner to destroy the unused objects, but that breaks the shop on subsequent loads // TC must be reusing the shop items rather than destroying them on load List <int> randomizedTypes = new List <int>() { 0, 1, 2, 3, 8, 10, 11 }; if (!randomizedTypes.Contains(item.GetComponent <ShopItemStats>().specialType)) { newStock.Add(item); } else if (item.GetComponent <ShopItemStats>().nameConvo == "INV_NAME_LANTERN" && !AreaRando.Instance.Settings.RandomizeKeys && !AreaRando.Instance.Settings.MiscSkips) { // Easiest way to handle lantern on easy mode. Lantern is given automatically on new game load } else if (item.GetComponent <ShopItemStats>().specialType == 2 && !AreaRando.Instance.Settings.RandomizeCharms) { newStock.Add(item); } else if ((item.GetComponent <ShopItemStats>().specialType == 0 || item.GetComponent <ShopItemStats>().specialType == 10) && !AreaRando.Instance.Settings.RandomizeKeys) { newStock.Add(item); } else if (item.GetComponent <ShopItemStats>().nameConvo == "INV_NAME_QUILL" && AreaRando.Instance.Settings.RandomizeKeys) { newStock.Add(item); //Special case: only nonrandomized item of special type 0 } else if (item.GetComponent <ShopItemStats>().specialType == 1 && !AreaRando.Instance.Settings.RandomizeMaskShards) { newStock.Add(item); } else if (item.GetComponent <ShopItemStats>().specialType == 3 && !AreaRando.Instance.Settings.RandomizeVesselFragments) { newStock.Add(item); } else if (item.GetComponent <ShopItemStats>().specialType == 8 && !AreaRando.Instance.Settings.RandomizeCharmNotches) { newStock.Add(item); } else if (item.GetComponent <ShopItemStats>().specialType == 11 && !AreaRando.Instance.Settings.RandomizeRancidEggs) { newStock.Add(item); } } shop.stock = newStock.ToArray(); // Update alt stock if (shop.stockAlt != null) { foreach (GameObject item in shop.stockAlt) { // note we just have to handle the vanilla item types sly sells here List <int> randomizedTypes = new List <int>() { 0, 1, 2, 3, 8, 10, 11 }; if (!randomizedTypes.Contains(item.GetComponent <ShopItemStats>().specialType)) { altStock.Add(item); } else if (item.GetComponent <ShopItemStats>().nameConvo == "INV_NAME_LANTERN" && !AreaRando.Instance.Settings.RandomizeKeys && !AreaRando.Instance.Settings.MiscSkips) { // Easiest way to handle lantern on easy mode. Lantern is given automatically on new game load } else if (item.GetComponent <ShopItemStats>().specialType == 2 && !AreaRando.Instance.Settings.RandomizeCharms) { altStock.Add(item); } else if ((item.GetComponent <ShopItemStats>().specialType == 0 || item.GetComponent <ShopItemStats>().specialType == 10) && !AreaRando.Instance.Settings.RandomizeKeys) { altStock.Add(item); } else if (item.GetComponent <ShopItemStats>().specialType == 1 && !AreaRando.Instance.Settings.RandomizeMaskShards) { altStock.Add(item); } else if (item.GetComponent <ShopItemStats>().specialType == 3 && !AreaRando.Instance.Settings.RandomizeVesselFragments) { altStock.Add(item); } else if (item.GetComponent <ShopItemStats>().specialType == 11 && !AreaRando.Instance.Settings.RandomizeRancidEggs) { altStock.Add(item); } } shop.stockAlt = altStock.ToArray(); } }
public override void Process(string scene, Object changeObj) { if (scene != SceneName) { return; } foreach (GameObject shopObj in Object.FindObjectsOfType <GameObject>()) { if (shopObj.name != ObjectName) { continue; } ShopMenuStock shop = shopObj.GetComponent <ShopMenuStock>(); GameObject itemPrefab = Object.Instantiate(shop.stock[0]); itemPrefab.SetActive(false); // Remove all charm type items from the store List <GameObject> newStock = new List <GameObject>(); foreach (ShopItemDef itemDef in _items) { // Create a new shop item for this item def GameObject newItemObj = Object.Instantiate(itemPrefab); newItemObj.SetActive(false); // Apply all the stored values ShopItemStats stats = newItemObj.GetComponent <ShopItemStats>(); stats.playerDataBoolName = itemDef.PlayerDataBoolName; stats.nameConvo = itemDef.NameConvo; stats.descConvo = itemDef.DescConvo; stats.requiredPlayerDataBool = itemDef.RequiredPlayerDataBool; stats.removalPlayerDataBool = itemDef.RemovalPlayerDataBool; stats.dungDiscount = itemDef.DungDiscount; stats.notchCostBool = itemDef.NotchCostBool; stats.cost = itemDef.Cost; // Need to set all these to make sure the item doesn't break in one of various ways stats.priceConvo = string.Empty; stats.specialType = 0; stats.charmsRequired = 0; stats.relic = false; stats.relicNumber = 0; stats.relicPDInt = string.Empty; // Apply the sprite for the UI stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite = itemDef.Sprite; newStock.Add(newItemObj); } foreach (GameObject g in shop.stock) { ShopItemStats stats = g.GetComponent <ShopItemStats>(); switch (SceneName) { case SceneNames.Room_mapper: switch (stats.specialType) { // Map marker case 17 when(_defaultShopItems & DefaultShopItems.IseldaMapMarkers) == DefaultShopItems.IseldaMapMarkers: // Map pin case 16 when(_defaultShopItems & DefaultShopItems.IseldaMapPins) == DefaultShopItems.IseldaMapPins: // Quill case 0 when stats.playerDataBoolName == nameof(PlayerData.hasQuill) && ((_defaultShopItems & DefaultShopItems.IseldaQuill) == DefaultShopItems.IseldaQuill): // Map case 9 when(_defaultShopItems & DefaultShopItems.IseldaMaps) == DefaultShopItems.IseldaMaps: newStock.Add(g); continue; default: continue; } case SceneNames.Room_shop: switch (stats.specialType) { // sly mask shards case 1 when(_defaultShopItems & DefaultShopItems.SlyMaskShards) == DefaultShopItems.SlyMaskShards: // sly charms case 2 when(_defaultShopItems & DefaultShopItems.SlyCharms) == DefaultShopItems.SlyCharms: // sly vessel fragments case 3 when(_defaultShopItems & DefaultShopItems.SlyVesselFragments) == DefaultShopItems.SlyVesselFragments: // sly simple key case 10 when(_defaultShopItems & DefaultShopItems.SlySimpleKey) == DefaultShopItems.SlySimpleKey: // sly rancid egg case 11 when(_defaultShopItems & DefaultShopItems.SlyRancidEgg) == DefaultShopItems.SlyRancidEgg: // sly lantern case 0 when stats.playerDataBoolName == nameof(PlayerData.hasLantern) && (_defaultShopItems & DefaultShopItems.SlyLantern) == DefaultShopItems.SlyLantern: newStock.Add(g); continue; default: continue; } case SceneNames.Room_Charm_Shop: switch (stats.specialType) { case 2 when(_defaultShopItems & DefaultShopItems.SalubraCharms) == DefaultShopItems.SalubraCharms: case 8 when(_defaultShopItems & DefaultShopItems.SalubraNotches) == DefaultShopItems.SalubraNotches: newStock.Add(g); continue; default: continue; } case SceneNames.Fungus2_26: switch (stats.specialType) { // fragile charms case 2 when(_defaultShopItems & DefaultShopItems.LegEaterCharms) == DefaultShopItems.LegEaterCharms: // fragile repair case 12 when(_defaultShopItems & DefaultShopItems.LegEaterRepair) == DefaultShopItems.LegEaterRepair: case 13 when(_defaultShopItems & DefaultShopItems.LegEaterRepair) == DefaultShopItems.LegEaterRepair: case 14 when(_defaultShopItems & DefaultShopItems.LegEaterRepair) == DefaultShopItems.LegEaterRepair: newStock.Add(g); continue; default: continue; } default: continue; } } shop.stock = newStock.ToArray(); // Update alt stock; Sly only if (shop.stockAlt != null) { // Save unchanged list for potential alt stock List <GameObject> altStock = new List <GameObject>(); altStock.AddRange(newStock); foreach (GameObject g in shop.stockAlt) { ShopItemStats stats = g.GetComponent <ShopItemStats>(); switch (stats.specialType) { // sly mask shards case 1 when(_defaultShopItems & DefaultShopItems.SlyMaskShards) == DefaultShopItems.SlyMaskShards: // sly charms case 2 when stats.requiredPlayerDataBool != nameof(PlayerData.gaveSlykey) && (_defaultShopItems & DefaultShopItems.SlyCharms) == DefaultShopItems.SlyCharms: // sly key charms case 2 when stats.requiredPlayerDataBool == nameof(PlayerData.gaveSlykey) && (_defaultShopItems & DefaultShopItems.SlyKeyCharms) == DefaultShopItems.SlyKeyCharms: // sly vessel fragments case 3 when(_defaultShopItems & DefaultShopItems.SlyVesselFragments) == DefaultShopItems.SlyVesselFragments: // sly simple key case 10 when(_defaultShopItems & DefaultShopItems.SlySimpleKey) == DefaultShopItems.SlySimpleKey: // sly rancid egg case 11 when(_defaultShopItems & DefaultShopItems.SlyRancidEgg) == DefaultShopItems.SlyRancidEgg: // sly lantern case 0 when stats.playerDataBoolName == nameof(PlayerData.hasLantern) && (_defaultShopItems & DefaultShopItems.SlyLantern) == DefaultShopItems.SlyLantern: // sly key elegant key case 0 when stats.playerDataBoolName == nameof(PlayerData.hasWhiteKey) && (_defaultShopItems & DefaultShopItems.SlyKeyElegantKey) == DefaultShopItems.SlyKeyElegantKey: newStock.Add(g); continue; default: continue; } } shop.stockAlt = altStock.ToArray(); } } }