diff --git a/Source/Vehicles/AI/JobGivers/JobGiver_AwaitOrders.cs b/Source/Vehicles/AI/JobGivers/JobGiver_AwaitOrders.cs index 2a673db0..81aa58f6 100644 --- a/Source/Vehicles/AI/JobGivers/JobGiver_AwaitOrders.cs +++ b/Source/Vehicles/AI/JobGivers/JobGiver_AwaitOrders.cs @@ -24,11 +24,10 @@ protected override Job TryGiveJob(Pawn pawn) { vehicle.vehiclePather.EngageBrakes(); } - Job job = new(JobDefOf_Vehicles.IdleVehicle, vehicle) - { - checkOverrideOnExpire = true, - expiryInterval = overrideExpiryInterval > 0 ? overrideExpiryInterval : 180 - }; + + Job job = JobMaker.MakeJob(JobDefOf_Vehicles.IdleVehicle, vehicle); + job.checkOverrideOnExpire = true; + job.expiryInterval = overrideExpiryInterval > 0 ? overrideExpiryInterval : 180; return job; } } diff --git a/Source/Vehicles/AI/JobGivers/JobGiver_BoardVehicle.cs b/Source/Vehicles/AI/JobGivers/JobGiver_BoardVehicle.cs index 14ce3dcf..ed4bbff3 100644 --- a/Source/Vehicles/AI/JobGivers/JobGiver_BoardVehicle.cs +++ b/Source/Vehicles/AI/JobGivers/JobGiver_BoardVehicle.cs @@ -27,15 +27,14 @@ protected override Job TryGiveJob(Pawn pawn) if (!JobDriver_FollowClose.FarEnoughAndPossibleToStartJob(pawn, assignedSeat.Vehicle, FollowRadius)) return null; - return new Job(JobDefOf.FollowClose, assignedSeat.Vehicle) - { - lord = pawn.GetLord(), - expiryInterval = 140, - checkOverrideOnExpire = true, - followRadius = FollowRadius - }; + Job job = JobMaker.MakeJob(JobDefOf.FollowClose, assignedSeat.Vehicle); + job.lord = pawn.GetLord(); + job.expiryInterval = 140; + job.checkOverrideOnExpire = true; + job.followRadius = FollowRadius; + return job; } - return new Job(JobDefOf_Vehicles.Board, assignedSeat.Vehicle); + return JobMaker.MakeJob(JobDefOf_Vehicles.Board, assignedSeat.Vehicle); } return null; } diff --git a/Source/Vehicles/AI/JobGivers/JobGiver_GotoTravelDestinationVehicle.cs b/Source/Vehicles/AI/JobGivers/JobGiver_GotoTravelDestinationVehicle.cs index dce8c0e5..b02fe3dc 100644 --- a/Source/Vehicles/AI/JobGivers/JobGiver_GotoTravelDestinationVehicle.cs +++ b/Source/Vehicles/AI/JobGivers/JobGiver_GotoTravelDestinationVehicle.cs @@ -11,7 +11,7 @@ namespace Vehicles; public class JobGiver_GotoTravelDestinationVehicle : JobGiver_GotoTravelDestination { // Amble = Raiders + Vehicle Formations - // Walk = + // Walk = // Jog = Normal Speed // Sprint = Speed Away (escaping raiders?) @@ -34,11 +34,10 @@ protected override Job TryGiveJob(Pawn pawn) { return null; } - Job job = new(JobDefOf.Goto, cell) - { - locomotionUrgency = LocomotionUrgency.Jog, - expiryInterval = jobMaxDuration - }; + + Job job = JobMaker.MakeJob(JobDefOf.Goto, cell); + job.locomotionUrgency = LocomotionUrgency.Jog; + job.expiryInterval = jobMaxDuration; if (vehicle.InhabitedCellsProjected(cell, Rot8.Invalid) .Any(projCell => pawn.Map.exitMapGrid.IsExitCell(projCell))) { diff --git a/Source/Vehicles/AI/JobGivers/JobGiver_PrepareVehicleCaravan_GatheringItems.cs b/Source/Vehicles/AI/JobGivers/JobGiver_PrepareVehicleCaravan_GatheringItems.cs index b34728ed..fe92f99a 100644 --- a/Source/Vehicles/AI/JobGivers/JobGiver_PrepareVehicleCaravan_GatheringItems.cs +++ b/Source/Vehicles/AI/JobGivers/JobGiver_PrepareVehicleCaravan_GatheringItems.cs @@ -22,9 +22,8 @@ protected override Job TryGiveJob(Pawn pawn) if (thing is null) return null; - return new Job(JobDef, thing) - { - lord = lord - }; - } + Job job = JobMaker.MakeJob(JobDef, thing); + job.lord = lord; + return job; + } } \ No newline at end of file diff --git a/Source/Vehicles/AI/JobGivers/JobGiver_SendSlavesToVehicle.cs b/Source/Vehicles/AI/JobGivers/JobGiver_SendSlavesToVehicle.cs index 6c87e07f..6a528425 100644 --- a/Source/Vehicles/AI/JobGivers/JobGiver_SendSlavesToVehicle.cs +++ b/Source/Vehicles/AI/JobGivers/JobGiver_SendSlavesToVehicle.cs @@ -18,11 +18,10 @@ protected override Job TryGiveJob(Pawn pawn) return null; VehiclePawn vehicle = FindShipToDeposit(pawn, pawn2); VehicleRoleHandler handler = vehicle.handlers.Find(x => x.role.HandlingTypes == HandlingType.None); - return new Job(JobDefOf.PrepareCaravan_GatherDownedPawns, pawn2) - { - count = 1 - }; - } + Job job = JobMaker.MakeJob(JobDefOf.PrepareCaravan_GatherDownedPawns, pawn2); + job.count = 1; + return job; + } private Pawn FindPrisoner(Pawn pawn) { diff --git a/Source/Vehicles/AI/JobGivers/NPC/JobGiver_SabotageVehicle.cs b/Source/Vehicles/AI/JobGivers/NPC/JobGiver_SabotageVehicle.cs index 540e0430..b25c97d5 100644 --- a/Source/Vehicles/AI/JobGivers/NPC/JobGiver_SabotageVehicle.cs +++ b/Source/Vehicles/AI/JobGivers/NPC/JobGiver_SabotageVehicle.cs @@ -41,7 +41,7 @@ protected override Job TryGiveJob(Pawn pawn) IntVec3 jobCell = vehicle.SurroundingCells.RandomOrFallback(cell => resMgr.CanReserve(vehicle, pawn, cell), IntVec3.Invalid); - return new Job(JobDefOf_Vehicles.SabotageVehicle, vehicle, jobCell); + return JobMaker.MakeJob(JobDefOf_Vehicles.SabotageVehicle, vehicle, jobCell); } } } diff --git a/Source/Vehicles/Components/Vehicles/FloatOptionProviders/FloatMenuOptionProvider_OrderVehicle.cs b/Source/Vehicles/Components/Vehicles/FloatOptionProviders/FloatMenuOptionProvider_OrderVehicle.cs index cf5a0c37..5a1fb09c 100644 --- a/Source/Vehicles/Components/Vehicles/FloatOptionProviders/FloatMenuOptionProvider_OrderVehicle.cs +++ b/Source/Vehicles/Components/Vehicles/FloatOptionProviders/FloatMenuOptionProvider_OrderVehicle.cs @@ -119,7 +119,7 @@ internal static void PawnGotoAction(IntVec3 clickCell, VehiclePawn vehicle, IntV if (!IsFeatureEnabled(PathFinderV2)) { - Job job = new(JobDefOf.Goto, gotoLoc); + Job job = JobMaker.MakeJob(JobDefOf.Goto, gotoLoc); vehicle.jobs.TryTakeOrderedJob(job, JobTag.Misc); return; } diff --git a/Source/Vehicles/Components/Vehicles/VehiclePathFollower.cs b/Source/Vehicles/Components/Vehicles/VehiclePathFollower.cs index 73a55a59..cd7a5644 100644 --- a/Source/Vehicles/Components/Vehicles/VehiclePathFollower.cs +++ b/Source/Vehicles/Components/Vehicles/VehiclePathFollower.cs @@ -413,10 +413,8 @@ public bool TryOrderMoveTo(in PathOrderData data) return true; } - Job job = new(JobDefOf.Goto, new LocalTargetInfo(data.destination)) - { - exitMapOnArrival = data.exitMapOnArrival - }; + Job job = JobMaker.MakeJob(JobDefOf.Goto, new LocalTargetInfo(data.destination)); + job.exitMapOnArrival = data.exitMapOnArrival; if (vehicle.jobs.TryTakeOrderedJob(job, JobTag.Misc)) { endRot = data.endRotation; diff --git a/Source/Vehicles/Components/Vehicles/VehiclePawn/VehiclePawn_Rendering.cs b/Source/Vehicles/Components/Vehicles/VehiclePawn/VehiclePawn_Rendering.cs index 44ceab57..fd4b0ae6 100644 --- a/Source/Vehicles/Components/Vehicles/VehiclePawn/VehiclePawn_Rendering.cs +++ b/Source/Vehicles/Components/Vehicles/VehiclePawn/VehiclePawn_Rendering.cs @@ -991,7 +991,7 @@ public void PromptToBoardVehicle(Pawn pawn, VehicleRoleHandler handler) return; } - Job job = new(JobDefOf_Vehicles.Board, this); + Job job = JobMaker.MakeJob(JobDefOf_Vehicles.Board, this); GiveLoadJob(pawn, handler); pawn.jobs.TryTakeOrderedJob(job, JobTag.DraftedOrder); if (!pawn.Spawned) diff --git a/Source/Vehicles/Comps/FueledTravel/CompFueledTravel.cs b/Source/Vehicles/Comps/FueledTravel/CompFueledTravel.cs index f06c94de..40136ada 100644 --- a/Source/Vehicles/Comps/FueledTravel/CompFueledTravel.cs +++ b/Source/Vehicles/Comps/FueledTravel/CompFueledTravel.cs @@ -483,7 +483,7 @@ public override IEnumerable CompFloatMenuOptions(Pawn selPawn) yield return new FloatMenuOption("Refuel".Translate().ToString(), delegate { - Job job = new(JobDefOf_Vehicles.RefuelVehicle, parent, ClosestFuelAvailable(selPawn)); + Job job = JobMaker.MakeJob(JobDefOf_Vehicles.RefuelVehicle, parent, ClosestFuelAvailable(selPawn)); selPawn.jobs.TryTakeOrderedJob(job, JobTag.DraftedOrder); }); } diff --git a/Source/Vehicles/Comps/Turrets/CompVehicleTurrets.cs b/Source/Vehicles/Comps/Turrets/CompVehicleTurrets.cs index eea00b58..37e19361 100644 --- a/Source/Vehicles/Comps/Turrets/CompVehicleTurrets.cs +++ b/Source/Vehicles/Comps/Turrets/CompVehicleTurrets.cs @@ -175,7 +175,7 @@ private void RecacheGizmos() { toggleAction = delegate { - Vehicle.jobs.StartJob(new Job(JobDefOf_Vehicles.DeployVehicle, targetA: Vehicle), + Vehicle.jobs.StartJob(JobMaker.MakeJob(JobDefOf_Vehicles.DeployVehicle, targetA: Vehicle), JobCondition.InterruptForced); deployTicks = DeployTicks; }, @@ -750,7 +750,7 @@ public void RevalidateTurrets() private void ResolveAllTurretChildren() { - // Break all connections, then reassign. Out of sequence parent and renderer registration can result in child + // Break all connections, then reassign. Out of sequence parent and renderer registration can result in child // turrets being registered as renderers, even though they're drawn by their parents. foreach (VehicleTurret turret in turrets) { @@ -1077,7 +1077,7 @@ public void ExposeData() } /// - /// Used for serializing turret quotas of turrets that were removed, + /// Used for serializing turret quotas of turrets that were removed, /// such that they will reload the quota if re-added /// [UsedImplicitly] diff --git a/Source/Vehicles/Harmony/Patches/Patch_JobSystem.cs b/Source/Vehicles/Harmony/Patches/Patch_JobSystem.cs index 7af56447..71078ba5 100644 --- a/Source/Vehicles/Harmony/Patches/Patch_JobSystem.cs +++ b/Source/Vehicles/Harmony/Patches/Patch_JobSystem.cs @@ -84,7 +84,7 @@ public static bool VehicleErrorRecoverJob(Pawn pawn, string message, Exception e } else { - pawn.jobs.StartJob(new Job(JobDefOf_Vehicles.IdleVehicle, -1), + pawn.jobs.StartJob(JobMaker.MakeJob(JobDefOf_Vehicles.IdleVehicle, -1), JobCondition.Incompletable); } startingErrorRecoverJob = false; @@ -108,7 +108,11 @@ public static bool VehiclesDontWander(Pawn pawn, ref Job __result) { if (pawn is VehiclePawn) { - __result = new Job(JobDefOf_Vehicles.IdleVehicle); + if (__result is not null) + { + JobMaker.ReturnToPool(__result); + } + __result = JobMaker.MakeJob(JobDefOf_Vehicles.IdleVehicle); return false; } return true;