Example #1
0
        public static void AddTakeToBedOrder(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, ForEscortToBed(pawn), true))
                {
                    LocalTargetInfo dest = current;


                    if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, false, TraverseMode.ByPawn))
                    {
                        opts.Add(new FloatMenuOption("PrisonLabor_CannotTakeToBed".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    else
                    {
                        Pawn   pTarg  = (Pawn)dest.Thing;
                        Action action = delegate
                        {
                            ArrestUtility.TakePrisonerToBed(pTarg, pawn);
                        };
                        string             label    = "PrisonLabor_TakingToBed".Translate(dest.Thing.LabelCap);
                        MenuOptionPriority priority = MenuOptionPriority.High;
                        Thing thing = dest.Thing;
                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority, null, thing, 0f, null, null), pawn, pTarg, "ReservedBy"));
                    }
                }
            }
        }
Example #2
0
        public static void AddArrestOrder(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            //TODO this is some copy-pasted example, refactor it so it should add arrest option
            IntVec3 c = IntVec3.FromVector3(clickPos);

            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, ForArrest(pawn), true))
                {
                    LocalTargetInfo dest = current;
                    bool            flag = dest.HasThing && dest.Thing is Pawn && ((Pawn)dest.Thing).IsWildMan();
                    if (!pawn.Drafted || flag)
                    {
                        if (dest.Thing is Pawn && (pawn.InSameExtraFaction((Pawn)dest.Thing, ExtraFactionType.HomeFaction, (Quest)null) || pawn.InSameExtraFaction((Pawn)dest.Thing, ExtraFactionType.MiniFaction, (Quest)null)))
                        {
                            opts.Add(new FloatMenuOption((string)("CannotArrest".Translate() + ": " + "SameFaction".Translate((NamedArgument)dest.Thing)), (Action)null, MenuOptionPriority.Default, (Action <Rect>)null, (Thing)null, 0.0f, (Func <Rect, bool>)null, (WorldObject)null, true, 0));
                        }
                        else if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, 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;
                            string label   = "TryToArrest".Translate(pTarg.LabelCap, pTarg, pTarg.GetAcceptArrestChance(pawn).ToStringPercent());
                            Action action2 = delegate
                            {
                                ArrestUtility.ArrestPrisoner(pTarg, pawn);
                            };
                            MenuOptionPriority priority = MenuOptionPriority.High;
                            Thing thing = dest.Thing;
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action2, priority, null, thing, 0f, null, null), pawn, pTarg, "ReservedBy"));
                        }
                    }
                }
            }
        }