public static List <FloatMenuOption> ChoicesAtFor(Vector3 clickPos, Pawn pawn) { IntVec3 intVec = IntVec3.FromVector3(clickPos); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (intVec.InBounds(pawn.Map) && FloatMenuMakerMap.CanTakeOrder(pawn)) { if (pawn.Map != Find.VisibleMap) { return(list); } FloatMenuMakerMap.makingFor = pawn; try { if (intVec.Fogged(pawn.Map)) { FloatMenuOption floatMenuOption = FloatMenuMakerMap.GotoLocationOption(intVec, pawn); if (floatMenuOption != null) { if (!floatMenuOption.Disabled) { list.Add(floatMenuOption); return(list); } return(list); } return(list); } if (pawn.Drafted) { FloatMenuMakerMap.AddDraftedOrders(clickPos, pawn, list); } if (pawn.RaceProps.Humanlike) { FloatMenuMakerMap.AddHumanlikeOrders(clickPos, pawn, list); } if (!pawn.Drafted) { FloatMenuMakerMap.AddUndraftedOrders(clickPos, pawn, list); } foreach (FloatMenuOption item in pawn.GetExtraFloatMenuOptionsFor(intVec)) { list.Add(item); } return(list); } finally { FloatMenuMakerMap.makingFor = null; } } return(list); }
private static void AddDraftedOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 clickCell = IntVec3.FromVector3(clickPos); foreach (LocalTargetInfo item in GenUI.TargetsAt(clickPos, TargetingParameters.ForAttackHostile(), true)) { LocalTargetInfo attackTarg = item; if (pawn.equipment.Primary != null && !pawn.equipment.PrimaryEq.PrimaryVerb.verbProps.MeleeRange) { string str = default(string); Action rangedAct = FloatMenuUtility.GetRangedAttackAction(pawn, attackTarg, out str); string text = "FireAt".Translate(attackTarg.Thing.Label); FloatMenuOption floatMenuOption = new FloatMenuOption(MenuOptionPriority.High); if (rangedAct == null) { text = text + " (" + str + ")"; } else { floatMenuOption.autoTakeable = true; floatMenuOption.action = delegate { MoteMaker.MakeStaticMote(attackTarg.Thing.DrawPos, attackTarg.Thing.Map, ThingDefOf.Mote_FeedbackAttack, 1f); rangedAct(); }; } floatMenuOption.Label = text; opts.Add(floatMenuOption); } string str2 = default(string); Action meleeAct = FloatMenuUtility.GetMeleeAttackAction(pawn, attackTarg, out str2); Pawn pawn2 = attackTarg.Thing as Pawn; string text2 = (pawn2 == null || !pawn2.Downed) ? "MeleeAttack".Translate(attackTarg.Thing.Label) : "MeleeAttackToDeath".Translate(attackTarg.Thing.Label); MenuOptionPriority menuOptionPriority = (MenuOptionPriority)((!attackTarg.HasThing || !pawn.HostileTo(attackTarg.Thing)) ? 1 : 6); string empty = string.Empty; Action action = null; MenuOptionPriority priority = menuOptionPriority; Thing thing = attackTarg.Thing; FloatMenuOption floatMenuOption2 = new FloatMenuOption(empty, action, priority, null, thing, 0f, null, null); if (meleeAct == null) { text2 = text2 + " (" + str2 + ")"; } else { floatMenuOption2.action = delegate { MoteMaker.MakeStaticMote(attackTarg.Thing.DrawPos, attackTarg.Thing.Map, ThingDefOf.Mote_FeedbackAttack, 1f); meleeAct(); }; } floatMenuOption2.Label = text2; opts.Add(floatMenuOption2); } if (pawn.RaceProps.Humanlike && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (LocalTargetInfo item2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForArrest(pawn), true)) { LocalTargetInfo dest = item2; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotArrest".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action2 = delegate { Building_Bed building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, false); if (building_Bed == null) { building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, true); } if (building_Bed == null) { Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageTypeDefOf.RejectInput); } else { Job job = new Job(JobDefOf.Arrest, pTarg, building_Bed); job.count = 1; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies); } }; string empty = "TryToArrest".Translate(dest.Thing.LabelCap); Action action = action2; MenuOptionPriority priority = MenuOptionPriority.High; Thing thing = dest.Thing; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(empty, action, priority, null, thing, 0f, null, null), pawn, pTarg, "ReservedBy")); } } } FloatMenuOption floatMenuOption3 = FloatMenuMakerMap.GotoLocationOption(clickCell, pawn); if (floatMenuOption3 != null) { opts.Add(floatMenuOption3); } }