From 8f768f9f2d9ad51df5f36ec8eface05ae82cea33 Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Tue, 13 Oct 2020 21:05:09 +0200 Subject: [PATCH 1/3] Added uptate on load to the Designator default label - This fixes the zone display issue --- .../Drones/Building_DroneStation.cs | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Source/ProjectRimFactory/Drones/Building_DroneStation.cs b/Source/ProjectRimFactory/Drones/Building_DroneStation.cs index a2100b43..92403e4c 100644 --- a/Source/ProjectRimFactory/Drones/Building_DroneStation.cs +++ b/Source/ProjectRimFactory/Drones/Building_DroneStation.cs @@ -83,7 +83,9 @@ public class DroneAreaSelector : Designator public static Area SelectedArea => selectedArea; - + + + public override AcceptanceReport CanDesignateCell(IntVec3 loc) { return loc.InBounds(base.Map) && Designator_AreaAllowed.SelectedArea != null && !Designator_AreaAllowed.SelectedArea[loc]; @@ -328,11 +330,22 @@ public override void SpawnSetup(Map map, bool respawningAfterLoad) GenSpawn.Spawn(drone, Position, Map); drone.Destroy(); } + //Init the Designator default Label + update_droneAreaSelectorLable(droneAllowedArea); + } - - - + private void update_droneAreaSelectorLable(Area a) + { + if (a == null) + { + droneAreaSelectorLable = "Unrestricted\nSelect Area"; + } + else + { + droneAreaSelectorLable = a.Label + "\nSelect Area"; + } } + public override void Draw() { base.Draw(); @@ -533,14 +546,7 @@ Holds example of how i want this Gizmo Implemented selectAction = (a) => { Update_droneAllowedArea_forDrones(a); - if (a == null) - { - droneAreaSelectorLable = "Unrestricted\nSelect Area"; - } - else - { - droneAreaSelectorLable = a.Label + "\nSelect Area"; - } + update_droneAreaSelectorLable(a); } }; From bc79b990914212401b0804138576316632247034 Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Tue, 13 Oct 2020 21:26:34 +0200 Subject: [PATCH 2/3] Added Langurage File entry for the area Selection --- Languages/English/Keyed/AllKeyed_Other.xml | 1 + Source/ProjectRimFactory/Drones/Building_DroneStation.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Languages/English/Keyed/AllKeyed_Other.xml b/Languages/English/Keyed/AllKeyed_Other.xml index be9ac022..cdfcea50 100644 --- a/Languages/English/Keyed/AllKeyed_Other.xml +++ b/Languages/English/Keyed/AllKeyed_Other.xml @@ -70,6 +70,7 @@ Activate the Lockdown for all drone stations on the map. Reactivate all Lift the Lockdown for all drone stations on the map. + {0}\nSelect Area Settings Toggle Jobs for this Drone Station diff --git a/Source/ProjectRimFactory/Drones/Building_DroneStation.cs b/Source/ProjectRimFactory/Drones/Building_DroneStation.cs index 92403e4c..755028cd 100644 --- a/Source/ProjectRimFactory/Drones/Building_DroneStation.cs +++ b/Source/ProjectRimFactory/Drones/Building_DroneStation.cs @@ -338,11 +338,11 @@ private void update_droneAreaSelectorLable(Area a) { if (a == null) { - droneAreaSelectorLable = "Unrestricted\nSelect Area"; + droneAreaSelectorLable = "PRFDroneStationSelectArea".Translate("Unrestricted".Translate()); } else { - droneAreaSelectorLable = a.Label + "\nSelect Area"; + droneAreaSelectorLable = "PRFDroneStationSelectArea".Translate(a.Label); } } From cd62f52c873338ad43c2bc4a4d239b256ace2394 Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Tue, 13 Oct 2020 21:38:29 +0200 Subject: [PATCH 3/3] switchd from a foreach to a for loop to avoid a timing related error (changing allowed area during drone spawn) --- Source/ProjectRimFactory/Drones/Building_DroneStation.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ProjectRimFactory/Drones/Building_DroneStation.cs b/Source/ProjectRimFactory/Drones/Building_DroneStation.cs index 755028cd..c23df72f 100644 --- a/Source/ProjectRimFactory/Drones/Building_DroneStation.cs +++ b/Source/ProjectRimFactory/Drones/Building_DroneStation.cs @@ -226,9 +226,9 @@ public void Update_droneAllowedArea_forDrones(Area dr = null) { //Refresh the area droneAllowedArea = dr ?? (Area)GetDroneAllowedArea; - foreach (Pawn_Drone sdrone in spawnedDrones) + for (int i = 0; i < spawnedDrones.Count; i++) { - sdrone.playerSettings.AreaRestriction = droneAllowedArea; + spawnedDrones[i].playerSettings.AreaRestriction = droneAllowedArea; } }