//////////////// public override void PostDrawInInventory(SpriteBatch sb, Vector2 pos, Rectangle _1, Color drawColor, Color _2, Vector2 _3, float scale) { if (this.StoredItemStackSize == 0) { return; } float timeLeftPercent; if (!this.ComputeTimeLeftPercent(out timeLeftPercent)) { return; } Texture2D tupperTex = ModContent.GetTexture(this.Texture); if (timeLeftPercent == 0) { StarvationItem.DrawSpoilageInventory(sb, tupperTex, pos, drawColor, scale); } else { TupperwareItem.DrawContainerItemInventory(sb, this.StoredItemType, pos, scale); StarvationItem.DrawFreshnessGaugeInventory(sb, tupperTex, pos, timeLeftPercent, scale); } TupperwareItem.DrawItemStackInventory(sb, pos, this.StoredItemStackSize, scale); }
//// internal bool StoreItem(Item item) { if (this.StoredItemStackSize > 0 && this.StoredItemType != item.type) { Main.NewText("Tupperware cannot hold this type of item.", Color.Red); return(false); } int maxElapsedSeconds; if (this.StoredItemStackSize == 0) { if (!TupperwareItem.PredictMaxElapsedTicksOfItem(item, out maxElapsedSeconds)) { Main.NewText("Could not predict max elapsed time of item.", Color.Red); return(false); } } else { if (!this.ComputeMaxElapsedTicks(out maxElapsedSeconds)) { Main.NewText("Could not predict max elapsed time of own item.", Color.Red); return(false); } } var myitem = item.GetGlobalItem <StarvationItem>(); float itemTimeLeftPercent; if (!myitem.ComputeTimeLeftPercent(item, out itemTimeLeftPercent)) { Main.NewText("Could not compute time left of item.", Color.Red); return(false); } float timeLeftPercent = this.ComputeAveragedTimeLeftByPercent(itemTimeLeftPercent); this.SetTimeLeftByPercent(maxElapsedSeconds, timeLeftPercent); this.StoredItemType = item.type; this.StoredItemStackSize++; this.GetCachedModItem(); // Resets the timestamp return(true); }