public void StartReload() { this.count = 0; this.needReload = true; if (this.Wielder == null) { Log.ErrorOnce("Wielder of " + this.parent + " is null!", 7381889); this.FinishReload(); } else { if (this.reloaderProp.throwMote) { MoteThrower.ThrowText(this.Wielder.Position.ToVector3Shifted(), Translator.Translate("CR_ReloadingMote"), -1); } Job job = new Job(DefDatabase <JobDef> .GetNamed("VanillaReloadableGuns", true), this.Wielder, this.parent) { playerForced = true }; if (this.Wielder.drafter != null) { this.Wielder.drafter.TakeOrderedJob(job); } else { ExternalPawnDrafter.TakeOrderedJob(this.Wielder, job); } } }
public static void TakeOrderedJob(Pawn pawn, Job newJob) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent("TakeOrderedJob " + newJob); } if (!ExternalPawnDrafter.CanTakeOrderedJob(pawn)) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(" CanTakePlayerJob is false. Returning."); } } else { GenJob.ValidateJob(newJob); if (pawn.jobs.curJob == null || !pawn.jobs.curJob.JobIsSameAs(newJob)) { pawn.stances.CancelBusyStanceSoft(); Find.PawnDestinationManager.UnreserveAllFor(pawn); if (newJob.def == JobDefOf.Goto) { Find.PawnDestinationManager.ReserveDestinationFor(pawn, newJob.targetA.Cell); } if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(" Queueing job"); } if (pawn.jobs.jobQueue == null) { pawn.jobs.jobQueue = new JobQueue(); } pawn.jobs.jobQueue.Clear(); pawn.jobs.jobQueue.EnqueueFirst(newJob); if (pawn.jobs.curJob != null) { pawn.jobs.curDriver.EndJobWith(JobCondition.InterruptForced); } } } }