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); //} } }
public virtual void CopyAllowancesFrom(CompRestrictedStorage other) { this.allowAll = other.allowAll; this.allowNone = other.allowNone; this.allowHumans = other.allowHumans; this.allowColonists = other.allowColonists; this.allowPrisoners = other.allowPrisoners; this.allowGuests = other.allowGuests; this.allowAnimals = other.allowAnimals; this.allowGrazers = other.allowGrazers; this.allowNonGrazers = other.allowNonGrazers; this.allowMeatEaters = other.allowMeatEaters; this.allowNonMeatEaters = other.allowNonMeatEaters; allowedIfInAreas = null; if (other.allowedIfInAreas != null) { allowedIfInAreas = new List <Area>(other.allowedIfInAreas); } allowedIfNotInAreas = null; if (other.allowedIfNotInAreas != null) { allowedIfNotInAreas = new List <Area>(other.allowedIfNotInAreas); } allowedPawns = null; if (other.allowedPawns != null) { allowedPawns = new List <Pawn>(allowedPawns); } disallowedPawns = null; if (other.disallowedPawns != null) { disallowedPawns = new List <Pawn>(disallowedPawns); } }
// Much useful from RimWorld.AreaAlowedGUI public Dialog_SpecifyPawns(CompRestrictedStorage comp) { this.crs = comp; this.doCloseX = true; this.doCloseButton = true; this.closeOnClickedOutside = true; this.forcePause = true; this.resizeable = true; this.optionalTitle = "Access Control for Pawns"; }
// Much useful from RimWorld.AreaAlowedGUI public Dialog_SpecifyAreas(Map map, CompRestrictedStorage comp) { this.map = map; this.crs = comp; this.doCloseX = true; this.doCloseButton = true; this.closeOnClickedOutside = true; this.forcePause = true; this.resizeable = true; this.optionalTitle = "Specify Access Control by Area";//TODO: translate entire thing... }
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(); } } }