public override bool Tick(Actor self) { if (this.IsCanceling) { return(true); } if (this.ChildActivity != null) { return(false); } if (this.tanker.Current < this.tanker.Maximum) { this.tanker.PreferedDrillrig ??= OilUtils.GetMostUnderutilizedDrillrig(self.Owner, self.CenterPosition); if (this.tanker.PreferedDrillrig != null) { this.QueueChild(new Docking(this.actor, this.tanker.PreferedDrillrig, this.tanker.PreferedDrillrig.TraitOrDefault <Dock>())); return(false); } } if (this.tanker.Current <= 0) { return(false); } if (this.tanker.PreferedPowerStation == null && this.tanker.PreferedDrillrig != null) { this.tanker.PreferedPowerStation = OilUtils.GetNearestPowerStation(self.Owner, this.tanker.PreferedDrillrig.CenterPosition); } var target = this.tanker.PreferedPowerStation ?? OilUtils.GetNearestPowerStation(self.Owner, self.CenterPosition); if (target == null) { return(false); } this.QueueChild(new Docking(this.actor, target, target.TraitOrDefault <Dock>())); return(false); }
void ITick.Tick(Actor self) { if (this.PreferedDrillrig != null && !OilUtils.IsUsable(this.PreferedDrillrig, this.PreferedDrillrig.TraitOrDefault <Drillrig>())) { // When releasing the drillrig, we should also release the powerstation as another one might be the better pick. this.PreferedDrillrig = null; this.PreferedPowerStation = null; } if (this.PreferedPowerStation != null && this.PreferedPowerStation.Owner.RelationshipWith(self.Owner) != PlayerRelationship.Ally) { this.PreferedPowerStation = null; } if (this.PreferedPowerStation != null && !OilUtils.IsUsable(this.PreferedPowerStation, this.PreferedPowerStation.TraitOrDefault <PowerStation>())) { this.PreferedPowerStation = null; } }