/// <summary>Starts the behaviour, interactions can happen now</summary> public new void Start() { int index = 0; int num = 0; PlayerState.GameMode gm = SceneContext.Instance.GameModel.currGameMode; foreach (PlortEntry plort in plorts) { if (plort.id == Identifiable.Id.SABER_PLORT && gm == PlayerState.GameMode.TIME_LIMIT_V2) { continue; } if (!IsPlortShown(plort, PlortsCollected(plort.id))) { continue; } GameObject obj = Instantiate(priceEntryPrefab, pricesPanels[index].panel.transform, false); ModdedPriceEntry entry = obj.GetComponent <ModdedPriceEntry>(); entry.itemIcon.sprite = lookupDir.GetIcon(plort.id); displayMap.Add(plort, entry); if (num++ < pricesPanels[index].entryCount) { continue; } index++; num = 0; //? This prevents it from exceeding the capacity and makes the market always work even when there are //? more plorts than spaces on it. if (index == pricesPanels.Length) { break; } } while (index < pricesPanels.Length) { Instantiate(priceEntryEmptyPrefab, pricesPanels[index].panel.transform, false); if (num++ < pricesPanels[index].entryCount) { continue; } index++; num = 0; } EconUpdate(); econDir.didUpdateDelegate += EconUpdate; econDir.onRegisterSold += PlortCountUpdate; progressDir.onProgressChanged += EconUpdate; }
//+ MARKET UPDATE private void EconUpdate() { foreach (KeyValuePair <PlortEntry, ModdedPriceEntry> display in displayMap) { ModdedPriceEntry entry = display.Value; entry.UpdateValue(display.Key); entry.UpdateEntry(display.Key); } }
//+ FIXES private void FixEntryPrefab() { PriceEntry old = priceEntryPrefab.GetComponent <PriceEntry>(); ModdedPriceEntry entry = priceEntryPrefab.AddComponent <ModdedPriceEntry>(); entry.amountText = old.amountText; entry.changeAmountText = old.changeAmountText; entry.changeIcon = old.changeIcon; entry.coinIcon = old.coinIcon; entry.itemIcon = old.itemIcon; entry.bonusFill = old.bonusFill; entry.market = this; entry.dir = econDir; Destroy(old); }