@@ -16,7 +16,7 @@ namespace ProjectRimFactory.Drones
1616 public abstract class Building_DroneStation : Building , IPowerSupplyMachineHolder , IDroneSeetingsITab , IPRF_SettingsContentLink
1717 {
1818 //Sleep Time List (Loaded on Spawn)
19- public string [ ] CachedSleepTimeList ;
19+ protected int [ ] CachedSleepTimeList ;
2020
2121 protected CompRefuelable RefuelableComp ;
2222
@@ -37,6 +37,7 @@ private int DroneRange
3737 }
3838
3939 private CompPowerWorkSetting compPowerWorkSetting ;
40+ internal ModExtension_Skills ModExtensionDroneSkills ;
4041
4142 private IEnumerable < IntVec3 > StationRangeCells
4243 {
@@ -104,7 +105,7 @@ private void Update_droneAllowedArea_forDrones(Area dr)
104105
105106 private static readonly Texture2D Cancel = ContentFinder < Texture2D > . Get ( "UI/Designators/Cancel" ) ;
106107 private bool lockdown ;
107- private string droneAreaSelectorLable = "PRFDroneStationSelectArea" . Translate ( "PRFDroneStationUnrestricted" . Translate ( ) ) ;
108+ private string droneAreaSelectorLabel = "PRFDroneStationSelectArea" . Translate ( "PRFDroneStationUnrestricted" . Translate ( ) ) ;
108109 protected DefModExtension_DroneStation DefModExtensionDroneStation ;
109110 protected List < Pawn_Drone > SpawnedDrones = [ ] ;
110111
@@ -121,8 +122,7 @@ public Dictionary<WorkTypeDef, bool> GetWorkSettings
121122 }
122123
123124 public List < SkillRecord > DroneSettingsSkillDefs => GetDroneSkillsRecord ;
124-
125- public string [ ] GetSleepTimeList => CachedSleepTimeList ;
125+ public string [ ] GetSleepTimeList { get ; private set ; }
126126
127127 public CompRefuelable CompRefuelable => RefuelableComp ;
128128
@@ -151,6 +151,7 @@ public override void SpawnSetup(Map map, bool respawningAfterLoad)
151151 RefuelableComp = GetComp < CompRefuelable > ( ) ;
152152 compPowerTrader = GetComp < CompPowerTrader > ( ) ;
153153 DefModExtensionDroneStation = def . GetModExtension < DefModExtension_DroneStation > ( ) ;
154+ ModExtensionDroneSkills = def . GetModExtension < ModExtension_Skills > ( ) ;
154155 compPowerWorkSetting = GetComp < CompPowerWorkSetting > ( ) ;
155156 stationRangeCellsOld = StationRangeCells ;
156157 //Setup Allowed Area
@@ -161,7 +162,8 @@ public override void SpawnSetup(Map map, bool respawningAfterLoad)
161162 Update_droneAllowedArea_forDrones ( DroneAllowedArea ) ;
162163 }
163164 //Load the SleepTimes from XML
164- CachedSleepTimeList = DefModExtensionDroneStation . Sleeptimes . Split ( ',' ) ;
165+ CachedSleepTimeList = DefModExtensionDroneStation . GetSleepTimesInt ( ) ;
166+ GetSleepTimeList = DefModExtensionDroneStation . GetSleepTimesString ( ) ;
165167
166168 CashedGetCoverageCells = StationRangeCells . ToList ( ) ;
167169
@@ -200,11 +202,11 @@ private void update_droneAreaSelectorLabel(Area area)
200202 {
201203 if ( area is null )
202204 {
203- droneAreaSelectorLable = "PRFDroneStationSelectArea" . Translate ( "PRFDroneStationUnrestricted" . Translate ( ) ) ;
205+ droneAreaSelectorLabel = "PRFDroneStationSelectArea" . Translate ( "PRFDroneStationUnrestricted" . Translate ( ) ) ;
204206 return ;
205207 }
206208
207- droneAreaSelectorLable = "PRFDroneStationSelectArea" . Translate ( area . Label ) ;
209+ droneAreaSelectorLabel = "PRFDroneStationSelectArea" . Translate ( area . Label ) ;
208210 }
209211
210212 public override void DynamicDrawPhaseAt ( DrawPhase phase , Vector3 drawLoc , bool flip = false )
@@ -266,33 +268,29 @@ protected override void Tick()
266268 //Return if not Spawned
267269 if ( ! Spawned ) return ;
268270
269-
270- //Should not draw much performance...
271- //To enhance performance we could add "this.IsHashIntervalTick(60)"
271+
272272 if ( SpawnedDrones . Count > 0 && compPowerTrader ? . PowerOn == false )
273273 {
274274 for ( var i = SpawnedDrones . Count - 1 ; i >= 0 ; i -- )
275275 {
276276 SpawnedDrones [ i ] . jobs . StartJob ( new Job ( PRFDefOf . PRFDrone_ReturnToStation , this ) , JobCondition . InterruptForced ) ;
277277 }
278- //return as there is nothing to do if its off....
278+ //return as there is nothing to do if it's off....
279279 return ;
280280 }
281-
282-
283- //Update the Allowed Area Range on Power Change
281+
282+ //Update the Allowed Area
284283 if ( this . IsHashIntervalTick ( 60 ) )
285284 {
286285 //Update the Range
287286 Update_droneAllowedArea_forDrones ( DroneAllowedArea ) ;
288-
289- //TODO add cell calc
287+
290288 CashedGetCoverageCells = StationRangeCells . ToList ( ) ;
291289 }
292290
293- //Search for Job
291+ //Check if we should search for a Job
294292 if ( ! this . IsHashIntervalTick ( 60 + additionJobSearchTickDelay ) || DronesLeft <= 0 || lockdown || compPowerTrader ? . PowerOn == false ) return ;
295- //The issue appears to be 100% with TryGiveJob
293+
296294 var drone = MakeDrone ( ) ;
297295 GenSpawn . Spawn ( drone , Position , Map ) ;
298296
@@ -301,7 +299,7 @@ protected override void Tick()
301299 if ( job != null )
302300 {
303301 additionJobSearchTickDelay = 0 ; //Reset to 0 - found a job -> may find more
304- job . playerForced = true ; // Why is that here? (included since the very beginning)
302+ job . playerForced = true ; // Allow higher Danger for the Job
305303 //MakeDrone takes about 1ms
306304
307305 drone . jobs . StartJob ( job ) ;
@@ -310,15 +308,15 @@ protected override void Tick()
310308 {
311309 drone . Destroy ( ) ;
312310 Notify_DroneGained ( ) ;
313- //Experimental Delay
314- //Add delay (limit to 300) i am well aware that this can be higher that 300 with the current code
311+ //Add delay (limit to 300) effective limit is 510
315312 if ( additionJobSearchTickDelay < 300 )
316313 {
317314 //Exponential delay
318315 additionJobSearchTickDelay = ( additionJobSearchTickDelay + 1 ) * 2 ;
319316 }
320317 }
321318 }
319+
322320 public void Notify_DroneMayBeLost ( Pawn_Drone drone )
323321 {
324322 if ( ! SpawnedDrones . Contains ( drone ) ) return ;
@@ -460,7 +458,7 @@ public override IEnumerable<Gizmo> GetGizmos()
460458 yield return new DroneAreaSelector ( )
461459 {
462460 icon = ContentFinder < Texture2D > . Get ( "UI/Designators/AreaAllowedExpand" ) ,
463- defaultLabel = droneAreaSelectorLable ,
461+ defaultLabel = droneAreaSelectorLabel ,
464462 SelectAction = ( a ) =>
465463 {
466464 Update_droneAllowedArea_forDrones ( a ) ;
0 commit comments