/// <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; }
/// <summary>Adjusts the UI rendering to account for value of <see cref="Configuration.maxItemSlots"/>.</summary> /// <param name="this">The instance of SiloSlotUI this method is hooking.</param> public static void Update(SiloSlotUI @this) { //set lookupDir only once (only if it's null) lookupDir = lookupDir ?? SRSingleton <GameContext> .Instance.LookupDirector; //this has to be done here, because we don't have access to the private field //We can't just save it, because there will be many SiloSlotUIs, and they don't all share the same SiloStorage SiloStorage storage = @this.GetComponentInParent <SiloStorage>(); //Get the slot ID for the Silo slot this screen is on Identifiable.Id slotIdentifiable = storage.GetSlotIdentifiable(@this.slotIdx); //check if there is any item in this slot if (slotIdentifiable != Identifiable.Id.NONE) { //do render stuff @this.slotIcon.sprite = lookupDir.GetIcon(slotIdentifiable); @this.slotIcon.enabled = true; //rather than scaling our current item count, we just change the max slots @this.bar.maxValue = BiggerSilo.Config.maxItemSlots; @this.bar.currValue = storage.GetSlotCount(@this.slotIdx); @this.bar.barColor = lookupDir.GetColor(slotIdentifiable); @this.frontFrameIcon.sprite = @this.frontFilled; @this.backFrameIcon.sprite = @this.backFilled; } else { //do more render stuff @this.slotIcon.enabled = false; @this.bar.currValue = 0f; @this.bar.barColor = Color.black; @this.frontFrameIcon.sprite = @this.frontEmpty; @this.backFrameIcon.sprite = @this.backEmpty; } }