Example #1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            Toil prepare = Toils_General.Wait(500);

            prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell);
            prepare.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            yield return(prepare);

            yield return(new Toil
            {
                initAction = delegate
                {
                    Pawn actor = CurToil.actor;
                    Building_AMCell pod = (Building_AMCell)actor.CurJob.targetA.Thing;
                    Action action = delegate
                    {
                        actor.DeSpawn();
                        pod.TryAcceptThing(actor, true);
                    };
                    if (!pod.def.building.isPlayerEjectable)
                    {
                        int freeColonistsSpawnedOrInPlayerEjectablePodsCount = this.Map.mapPawns.FreeColonistsSpawnedOrInPlayerEjectablePodsCount;
                        if (freeColonistsSpawnedOrInPlayerEjectablePodsCount <= 1)
                        {
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CasketWarning".Translate().AdjustedFor(actor), action, false, null));
                        }
                        else
                        {
                            action();
                        }
                    }
                    else
                    {
                        action();
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });
        }
Example #2
0
            public static void AddFloatMenuOption(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
            {
                string str2;
                Action action;
                Pawn   pawn1;

                foreach (LocalTargetInfo localTargetInfo1 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    LocalTargetInfo localTargetInfo2 = localTargetInfo1;
                    Pawn            thing2           = (Pawn)localTargetInfo2.Thing;
                    if (!thing2.Downed || !pawn.CanReserveAndReach(thing2, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true) || Building_AMCell.FindAMCellFor(thing2, pawn, true) == null)
                    {
                        continue;
                    }
                    string str3          = "Job_CarryToAMCell".Translate(new object[] { localTargetInfo2.Thing.LabelCap });
                    JobDef carryToAMCell = DefDatabase <JobDef> .GetNamed("Job_CarryToAMCell");

                    Action action1 = () => {
                        Building_AMCell buildingCryptosleepCasket = Building_AMCell.FindAMCellFor(thing2, pawn, false) ?? Building_AMCell.FindAMCellFor(thing2, pawn, true);
                        if (buildingCryptosleepCasket == null)
                        {
                            Messages.Message(string.Concat("CannotCarryToAMCell".Translate(), ": ", "NoAMCell".Translate()), thing2, MessageTypeDefOf.RejectInput);
                            return;
                        }
                        Job job = new Job(carryToAMCell, thing2, buildingCryptosleepCasket)
                        {
                            count = 1
                        };
                        pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                    };
                    str2   = str3;
                    action = action1;
                    pawn1  = thing2;
                    opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(str2, action, MenuOptionPriority.Default, null, pawn1, 0f, null, null), pawn, thing2, "ReservedBy"));
                }
            }