static void Postfix(StorageSettings s) { crs = null; // clear old one Building_Storage building; if ((building = (s.owner as Building_Storage)) != null) { CompRestrictedStorage origComp = building.GetComp <CompRestrictedStorage>(); if (origComp == null || origComp.IsDefault()) { return; } crs = new CompRestrictedStorage(); crs.CopyAllowancesFrom(origComp); //Log.Warning("Copying restrictions from "+building); } }
// NOTE: This is actually protected, but the krefs.RimWorld package makes all things public for us public override void FillTab() { Text.Font = GameFont.Medium; CompRestrictedStorage crs = (this.SelThing as ThingWithComps).GetComp <CompRestrictedStorage>(); Rect mainOptionRect = new Rect(10f, 10f, size.x - 50f, 54f); // -10f for border, -30f for X to close the ITab if (crs != null) { crs.DisplayMainOption(mainOptionRect); } else { defaultCRS.parent = (this.SelThing as ThingWithComps); defaultCRS.DisplayMainOption(mainOptionRect); } Text.Font = GameFont.Small; Widgets.DrawLineHorizontal(10f, 65f, size.y - 20f); Rect fineOptionsRect = new Rect(20f, 68f, this.size.x - 35, this.size.y - 70); if (crs != null) { crs.DisplayFineOptions(fineOptionsRect); } else { defaultCRS.DisplayFineOptions(fineOptionsRect); if (!defaultCRS.IsDefault()) { defaultCRS.Initialize(null); (this.SelThing as ThingWithComps).AllComps.Add(defaultCRS); defaultCRS = new CompRestrictedStorage(); } } }