private static bool Prefix(Thing __instance) { if (Find.CameraDriver.CurrentZoom != CameraZoomRange.Closest) { return(true); // maybe someone changes this? Who knows. } if (!(__instance is Building_Storage DSU)) { return(true); } var cds = DSU.GetComp <CompDeepStorage>(); if (cds == null) { return(true); } switch (cds.cdsProps.overlayType) { case GuiOverlayType.Normal: return(true); case GuiOverlayType.None: return(false); } List <Thing> things; string s; switch (cds.cdsProps.overlayType) { case GuiOverlayType.CountOfAllStacks: { // maybe Armor Racks, Clothing Racks, def Weapon Lockers etc... things = new List <Thing>(); foreach (var c in DSU.AllSlotCellsList()) { things.AddRange(__instance.Map.thingGrid.ThingsListAtFast(c).FindAll(t => t.def.EverStorable(false))); } switch (things.Count) { case 0 when cds.cdsProps.showContents: return(false); // If it's empty, player will see! case 0: s = "LWM_DS_Empty".Translate(); break; case 1: s = 1.ToStringCached(); // Why not s="1";? You never know, someone may be playing in... break; default: { if (AllSameType(things)) { s = "x" + things.Count.ToStringCached(); } else { s = "[ " + things.Count.ToStringCached() + " ]"; } break; } } GenMapUI.DrawThingLabel(GenMapUI.LabelDrawPosFor(__instance, 0f), s, GenMapUI.DefaultThingLabelColor); return(false); } case GuiOverlayType.CountOfStacksPerCell: { // maybe Armor Racks, Clothing Racks? foreach (var c in DSU.AllSlotCellsList()) { things = __instance.Map.thingGrid.ThingsListAtFast(c).FindAll(t => t.def.EverStorable(false)); switch (things.Count) { case 0 when cds.cdsProps.showContents: continue; // if it's empty, player will see! case 0: s = "LWM_DS_Empty".Translate(); break; case 1: s = 1.ToStringCached(); // ..a language that doesn't use arabic numerals? break; default: { if (AllSameType(things)) { s = "x" + things.Count.ToStringCached(); } else { s = "[ " + things.Count.ToStringCached() + " ]"; } break; } } var l2 = GenMapUI.LabelDrawPosFor(c); // l2.x+=cds.x; // l2.y+=cds.y; l2.y += 10f; GenMapUI.DrawThingLabel(l2, s, GenMapUI.DefaultThingLabelColor); } return(false); } case GuiOverlayType.SumOfAllItems: { // probably food baskets, skips, etc... things = new List <Thing>(); foreach (var c in DSU.slotGroup.CellsList) { things.AddRange(__instance.Map.thingGrid.ThingsListAtFast(c) .FindAll(t => t.def.EverStorable(false))); } if (things.Count == 0) { if (cds.cdsProps.showContents) { return(false); // if it's empty, player will see } s = "LWM_DS_Empty".Translate(); } else { var count = things[0].stackCount; var allTheSame = true; for (var i = 1; i < things.Count; i++) { if (things[i].def != things[0].def) { allTheSame = false; } count += things[i].stackCount; } if (allTheSame) { s = count.ToStringCached(); } else { s = "[ " + count.ToStringCached() + " ]"; } } GenMapUI.DrawThingLabel(GenMapUI.LabelDrawPosFor(__instance, 0f), s, GenMapUI.DefaultThingLabelColor); return(false); } case GuiOverlayType.SumOfItemsPerCell: { // Big Shelves var anyItems = false; var itemsWithStackSizeOne = false; foreach (var c in DSU.AllSlotCellsList()) { things = __instance.Map.thingGrid.ThingsListAtFast(c).FindAll(t => t.def.EverStorable(false)); if (things.Count > 0) { anyItems = true; var count = 0; foreach (var t in things) { if (itemsWithStackSizeOne || t.def.stackLimit == 1) { itemsWithStackSizeOne = true; if (things.Count == 1) { s = 1.ToStringCached(); // ..a language that doesn't use arabic numerals? } else if (AllSameType(things)) { s = "x" + things.Count.ToStringCached(); } else { s = "[ " + things.Count.ToStringCached() + " ]"; } var l = GenMapUI.LabelDrawPosFor(c); l.y += 10f; GenMapUI.DrawThingLabel(l, s, GenMapUI.DefaultThingLabelColor); goto WhyDoesCSharpNotHaveBreakTwo; } else { count += t.stackCount; } } if (AllSameType(things)) { s = count.ToStringCached(); } else { s = "[ " + count.ToStringCached() + " ]"; } var l2 = GenMapUI.LabelDrawPosFor(c); l2.y += 10f; GenMapUI.DrawThingLabel(l2, s, GenMapUI.DefaultThingLabelColor); } // if count > 0 WhyDoesCSharpNotHaveBreakTwo :; } // foreach cell if (anyItems || cds.cdsProps.showContents) { return(false); } // there are no items, but no way to see that. s = "LWM_DS_Empty".Translate(); GenMapUI.DrawThingLabel(GenMapUI.LabelDrawPosFor(__instance, 0f), s, GenMapUI.DefaultThingLabelColor); return(false); } default: Log.Warning("LWM DeepStorage: could not find GuiOverlayType of " + cds.cdsProps.overlayType); return(true); } }