internal static void SaveCurrentState(List <Pawn> pawns) { int currentMap = Find.CurrentMap.uniqueID; int activePolicyId = RestrictManager.GetActivePolicy().id; //Save current state foreach (Pawn p in pawns) { //find colonist in the current zone in the current map RestrictLink link = RestrictManager.links.Find( x => p.Equals(x.colonist) && x.zone == activePolicyId && x.mapId == currentMap); if (link != null) { //colonist found! save link.area = p.playerSettings.AreaRestriction; RestrictManager.CopySchedule(p.timetable.times, link.schedule); } else { //colonist not found. So add it to the RestrictLink list RestrictManager.links.Add( new RestrictLink( activePolicyId, p, p.playerSettings.AreaRestriction, p.timetable.times, currentMap)); } } }
private static void SaveCurrentState(List <Pawn> pawns) { int currentMap = Find.CurrentMap.uniqueID; //Save current state foreach (Pawn p in pawns) { //find colonist on the current zone in the current map RestrictLink link = RestrictManager.links.Find( x => x.colonist.Equals(p) && x.zone == RestrictManager.GetActivePolicy().id&& x.mapId == currentMap); if (link != null) { //colonist found! save link.area = p.playerSettings.AreaRestriction; } else { //colonist not found. So add it to the RestrictLink list RestrictManager.links.Add( new RestrictLink( RestrictManager.GetActivePolicy().id, p, p.playerSettings.AreaRestriction, currentMap)); } } }
public override void DoWindowContents(Rect fillRect) { if (RestrictManager.DirtyPolicy) { LoadState( RestrictManager.links, this.Pawns.ToList(), RestrictManager.GetActivePolicy()); RestrictManager.DirtyPolicy = false; } float offsetX = 200f; if (Widget_CSL.CLSAvailable) { offsetX = offsetX + 87f; } base.DoWindowContents(fillRect); Rect position = new Rect(0f, 0f, fillRect.width, 65f); GUI.BeginGroup(position); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.LowerCenter; Rect rect1 = new Rect(offsetX, -8f, 165f, Mathf.Round(position.height / 3f)); Widgets.Label(rect1, "BPC.CurrentRestrictPolicy".Translate()); GUI.EndGroup(); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Rect rect2 = new Rect( offsetX, Mathf.Round(position.height / 4f) - 4f, rect1.width, Mathf.Round(position.height / 4f) + 4f); if (Widgets.ButtonText( rect2, RestrictManager.GetActivePolicy().label, true, false, true)) { //CleanDeadColonists(this.pawns); SaveCurrentState(this.Pawns.ToList()); OpenRestrictPolicySelectMenu( RestrictManager.links, this.Pawns.ToList()); } offsetX += rect1.width; Rect rect3 = new Rect( offsetX, 0f, 20f, Mathf.Round(position.height / 2f)); if (Widgets.ButtonText(rect3, "", true, false, true)) { Find.WindowStack.Add( new Dialog_ManagePolicies(Find.CurrentMap)); } Rect rect4 = new Rect(offsetX + 3f, rect3.height / 4f, 14f, 14f); GUI.DrawTexture(rect4, Resources.Settings); TooltipHandler.TipRegion(rect4, "BPC.Settings".Translate()); }
public override void PreOpen() { base.PreOpen(); RestrictManager.CleanDeadMaps(); RestrictManager.UpdateState( RestrictManager.links, this.Pawns.ToList(), RestrictManager.GetActivePolicy()); RestrictManager.LoadState( RestrictManager.links, this.Pawns.ToList(), RestrictManager.GetActivePolicy()); RestrictManager.CleanDeadColonists(this.Pawns.ToList()); }
public override void PreOpen() { base.PreOpen(); //PrintAllAssignPolicies(); UpdateState( RestrictManager.links, this.Pawns.ToList(), RestrictManager.GetActivePolicy()); LoadState( RestrictManager.links, this.Pawns.ToList(), RestrictManager.GetActivePolicy()); CleanDeadMaps(); CleanDeadColonists(this.Pawns.ToList()); }
public override void DoWindowContents(Rect fillRect) { if (RestrictManager.DirtyPolicy) { RestrictManager.LoadState( RestrictManager.links, this.Pawns.ToList(), RestrictManager.GetActivePolicy()); RestrictManager.DirtyPolicy = false; } float offsetX = 200f; if (Widget_CSL.CLSAvailable) { offsetX = offsetX + 87f; } base.DoWindowContents(fillRect); Rect position = new Rect(0f, 0f, fillRect.width, 65f); GUI.BeginGroup(position); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.LowerCenter; Rect rect1 = new Rect(offsetX, -8f, 165f, Mathf.Round(position.height / 3f)); Widgets.Label(rect1, "BPC.CurrentRestrictPolicy".Translate()); GUI.EndGroup(); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Rect rect2 = new Rect( offsetX, Mathf.Round(position.height / 4f) - 4f, rect1.width, Mathf.Round(position.height / 4f) + 4f); if (Widgets.ButtonText( rect2, RestrictManager.GetActivePolicy().label, true, false, true)) { RestrictManager.SaveCurrentState(this.Pawns.ToList()); OpenRestrictPolicySelectMenu( RestrictManager.links, this.Pawns.ToList()); } offsetX += rect1.width; Rect rect3 = new Rect( offsetX, 0f, 20f, Mathf.Round(position.height / 2f)); if (Widgets.ButtonText(rect3, "", true, false, true)) { Find.WindowStack.Add( new Dialog_ManagePolicies(Find.CurrentMap)); } Rect rect4 = new Rect(offsetX + 3f, rect3.height / 4f, 14f, 14f); GUI.DrawTexture(rect4, Resources.Settings); TooltipHandler.TipRegion(rect4, "BPC.Settings".Translate()); offsetX += rect3.width; Rect rect5 = new Rect(offsetX + 3f, rect3.height / 4f - 6f, 21f, 28f); if (Widgets.ButtonImage(rect5, ContentFinder <Texture2D> .Get("UI/Buttons/Copy", true))) { RestrictManager.CopyToClipboard(); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); showPaste = true; } TooltipHandler.TipRegion(rect5, "BPC.CopySchedule".Translate()); if (showPaste) { offsetX += rect3.width; Rect rect6 = new Rect(offsetX + 3f, rect3.height / 4f - 6f, 21f, 28f); if (Widgets.ButtonImage(rect6, ContentFinder <Texture2D> .Get("UI/Buttons/Paste", true))) { RestrictManager.PasteToActivePolicy(); SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect6, "BPC.PasteSchedule".Translate()); } }