public override ThinkNode DeepCopy(bool resolve = true) { JobGiver_Work obj = (JobGiver_Work)base.DeepCopy(resolve); obj.emergency = emergency; return(obj); }
public override ThinkNode DeepCopy(bool resolve = true) { JobGiver_Work jobGiver_Work = (JobGiver_Work)base.DeepCopy(resolve); jobGiver_Work.emergency = this.emergency; return(jobGiver_Work); }
private static void AddUndraftedOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 clickCell = IntVec3.FromVector3(clickPos); bool flag = false; bool flag2 = false; foreach (Thing item in pawn.Map.thingGrid.ThingsAt(clickCell)) { flag2 = true; if (pawn.CanReach(item, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { flag = true; break; } } if (flag2 && !flag) { opts.Add(new FloatMenuOption("(" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { JobGiver_Work jobGiver_Work = pawn.thinker.TryGetMainTreeThinkNode <JobGiver_Work>(); if (jobGiver_Work != null) { foreach (Thing item2 in pawn.Map.thingGrid.ThingsAt(clickCell)) { foreach (WorkTypeDef item3 in DefDatabase <WorkTypeDef> .AllDefsListForReading) { for (int i = 0; i < item3.workGiversByPriority.Count; i++) { WorkGiver_Scanner workGiver_Scanner = item3.workGiversByPriority[i].Worker as WorkGiver_Scanner; string label; Action action; if (workGiver_Scanner != null && workGiver_Scanner.def.directOrderable && !workGiver_Scanner.ShouldSkip(pawn)) { JobFailReason.Clear(); if (!workGiver_Scanner.PotentialWorkThingRequest.Accepts(item2) && (workGiver_Scanner.PotentialWorkThingsGlobal(pawn) == null || !workGiver_Scanner.PotentialWorkThingsGlobal(pawn).Contains(item2))) { continue; } label = null; action = null; PawnCapacityDef pawnCapacityDef = workGiver_Scanner.MissingRequiredCapacity(pawn); if (pawnCapacityDef != null) { label = "CannotMissingHealthActivities".Translate(pawnCapacityDef.label); } else { Job job = workGiver_Scanner.HasJobOnThing(pawn, item2, true) ? workGiver_Scanner.JobOnThing(pawn, item2, true) : null; if (job == null) { if (JobFailReason.HaveReason) { label = "CannotGenericWork".Translate(workGiver_Scanner.def.verb, item2.LabelShort) + " (" + JobFailReason.Reason + ")"; goto IL_0589; } continue; } WorkTypeDef workType = workGiver_Scanner.def.workType; if (pawn.story != null && pawn.story.WorkTagIsDisabled(workGiver_Scanner.def.workTags)) { label = "CannotPrioritizeWorkGiverDisabled".Translate(workGiver_Scanner.def.label); } else if (pawn.jobs.curJob != null && pawn.jobs.curJob.JobIsSameAs(job)) { label = "CannotGenericAlreadyAm".Translate(workType.gerundLabel, item2.LabelShort); } else if (pawn.workSettings.GetPriority(workType) == 0) { if (pawn.story.WorkTypeIsDisabled(workType)) { label = "CannotPrioritizeWorkTypeDisabled".Translate(workType.gerundLabel); } else if ("CannotPrioritizeNotAssignedToWorkType".CanTranslate()) { label = "CannotPrioritizeNotAssignedToWorkType".Translate(workType.gerundLabel); } else { label = "CannotPrioritizeIsNotA".Translate(pawn.NameStringShort, workType.pawnLabel); } } else if (job.def == JobDefOf.Research && item2 is Building_ResearchBench) { label = "CannotPrioritizeResearch".Translate(); } else if (item2.IsForbidden(pawn)) { if (!item2.Position.InAllowedArea(pawn)) { label = "CannotPrioritizeForbiddenOutsideAllowedArea".Translate(item2.Label); } else { label = "CannotPrioritizeForbidden".Translate(item2.Label); } } else if (!pawn.CanReach(item2, workGiver_Scanner.PathEndMode, Danger.Deadly, false, TraverseMode.ByPawn)) { label = (item2.Label + ": " + "NoPath".Translate()).CapitalizeFirst(); } else { label = "PrioritizeGeneric".Translate(workGiver_Scanner.def.gerund, item2.Label); Job localJob = job; WorkGiver_Scanner localScanner = workGiver_Scanner; action = delegate { pawn.jobs.TryTakeOrderedJobPrioritizedWork(localJob, localScanner, clickCell); }; } } goto IL_0589; } continue; IL_0589: if (!opts.Any((FloatMenuOption op) => op.Label == label.TrimEnd())) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.Default, null, null, 0f, null, null), pawn, item2, "ReservedBy")); } } } } foreach (WorkTypeDef item4 in DefDatabase <WorkTypeDef> .AllDefsListForReading) { for (int j = 0; j < item4.workGiversByPriority.Count; j++) { WorkGiver_Scanner workGiver_Scanner2 = item4.workGiversByPriority[j].Worker as WorkGiver_Scanner; Action action2; string label2; if (workGiver_Scanner2 != null && workGiver_Scanner2.def.directOrderable && !workGiver_Scanner2.ShouldSkip(pawn)) { JobFailReason.Clear(); if (workGiver_Scanner2.PotentialWorkCellsGlobal(pawn).Contains(clickCell)) { action2 = null; label2 = null; PawnCapacityDef pawnCapacityDef2 = workGiver_Scanner2.MissingRequiredCapacity(pawn); if (pawnCapacityDef2 != null) { label2 = "CannotMissingHealthActivities".Translate(pawnCapacityDef2.label); } else { Job job2 = workGiver_Scanner2.HasJobOnCell(pawn, clickCell) ? workGiver_Scanner2.JobOnCell(pawn, clickCell) : null; if (job2 == null) { if (JobFailReason.HaveReason) { label2 = "CannotGenericWork".Translate(workGiver_Scanner2.def.verb, "AreaLower".Translate()) + " (" + JobFailReason.Reason + ")"; goto IL_098f; } continue; } WorkTypeDef workType2 = workGiver_Scanner2.def.workType; if (pawn.jobs.curJob != null && pawn.jobs.curJob.JobIsSameAs(job2)) { label2 = "CannotGenericAlreadyAm".Translate(workType2.gerundLabel, "AreaLower".Translate()); } else if (pawn.workSettings.GetPriority(workType2) == 0) { if (pawn.story.WorkTypeIsDisabled(workType2)) { label2 = "CannotPrioritizeWorkTypeDisabled".Translate(workType2.gerundLabel); } else if ("CannotPrioritizeNotAssignedToWorkType".CanTranslate()) { label2 = "CannotPrioritizeNotAssignedToWorkType".Translate(workType2.gerundLabel); } else { label2 = "CannotPrioritizeIsNotA".Translate(pawn.NameStringShort, workType2.pawnLabel); } } else if (!pawn.CanReach(clickCell, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { label2 = "AreaLower".Translate().CapitalizeFirst() + ": " + "NoPath".Translate(); } else { label2 = "PrioritizeGeneric".Translate(workGiver_Scanner2.def.gerund, "AreaLower".Translate()); Job localJob2 = job2; WorkGiver_Scanner localScanner2 = workGiver_Scanner2; action2 = delegate { pawn.jobs.TryTakeOrderedJobPrioritizedWork(localJob2, localScanner2, clickCell); }; } } goto IL_098f; } } continue; IL_098f: if (!opts.Any((FloatMenuOption op) => op.Label == label2.TrimEnd())) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label2, action2, MenuOptionPriority.Default, null, null, 0f, null, null), pawn, clickCell, "ReservedBy")); } } } } } }