static void Postfix(StorageSettings s) { Building_Storage building; if ((building = (s.owner as Building_Storage)) != null) { var oldcrs = building.GetComp <CompRestrictedStorage>(); if (oldcrs != null) { building.AllComps.Remove(oldcrs); } // would like to not bother with comp if is defaults, but... //if (Patch_StorageSettingsClipboard_Copy.crs!=null) { CompRestrictedStorage newcrs = new CompRestrictedStorage(); newcrs.parent = building; newcrs.Initialize(null); building.AllComps.Add(newcrs); if (Patch_StorageSettingsClipboard_Copy.crs != null) { newcrs.CopyAllowancesFrom(Patch_StorageSettingsClipboard_Copy.crs); } //Log.Message("Copying restictions to "+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(); } } }