Example #1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            this.FailOnMentalState(TargetIndex.A);
            this.FailOnNotAwake(TargetIndex.A);
            this.FailOn(() => IoM_StoryUtilities.PawnInPrivateQuarters(Talkee));
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_InterpersonalToilsIoM.GotoPawn(this.pawn, this.Talkee, this.Talkee.guest.interactionMode));

            yield return(Toils_Interpersonal.WaitToBeAbleToInteract(this.pawn));

            yield return(Toils_InterpersonalToilsIoM.ChatToPawn(this.pawn, this.Talkee, ChatType));

            for (int i = 0; i < Rand.Range(2, 5); i++)
            {
                yield return(Toils_InterpersonalToilsIoM.GotoPawn(this.pawn, this.Talkee, PrisonerInteractionMode.Chat));

                yield return(Toils_InterpersonalToilsIoM.ChatToPawn(this.pawn, this.Talkee, ChatType));
            }

            yield return(Toils_Interpersonal.SetLastInteractTime(TargetIndex.A));

            if (base.CurJob.def == JobDefOf.PrisonerAttemptRecruit)
            {
                yield return(Toils_Interpersonal.TryRecruit(TargetIndex.A));
            }
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            Pawn colonist = pawn.Map.mapPawns.FreeColonistsSpawned.Where((Pawn p) => p.Awake()).RandomElement();

            if (!IoM_StoryUtilities.PawnInPrivateQuarters(colonist))
            {
                return(this.FollowJob(colonist));
            }
            return(null);
        }
Example #3
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph   = new StateGraph();
            LordToil   startingToil = stateGraph.AttachSubgraph(new LordJob_Travel(this.chillSpot).CreateGraph()).StartingToil;

            stateGraph.StartingToil = startingToil;
            var lordToil_WanderAndChat = IoM_StoryUtilities.GetWandererChatToil(this.chatType);

            stateGraph.AddToil(lordToil_WanderAndChat);
            LordToil_TakeWoundedGuest lordToil_TakeWoundedGuest = new LordToil_TakeWoundedGuest();

            stateGraph.AddToil(lordToil_TakeWoundedGuest);
            StateGraph           stateGraph2          = new LordJob_TravelAndExit(IntVec3.Invalid).CreateGraph();
            LordToil             startingToil2        = stateGraph.AttachSubgraph(stateGraph2).StartingToil;
            LordToil             target               = stateGraph2.lordToils[1];
            LordToil_ExitMapBest lordToil_ExitMapBest = new LordToil_ExitMapBest(LocomotionUrgency.Walk, true);

            stateGraph.AddToil(lordToil_ExitMapBest);
            Transition transition = new Transition(startingToil, lordToil_ExitMapBest);

            transition.AddSources(new LordToil[]
            {
                lordToil_WanderAndChat,
                lordToil_TakeWoundedGuest
            });
            transition.AddSources(stateGraph2.lordToils);
            transition.AddTrigger(new Trigger_PawnCannotReachMapEdge());
            string leavingMessage;

            if (this.isLonePawn)
            {
                leavingMessage = "MessageLoneWandererLeaving".Translate(new object[] { this.centralPawn.Name });
            }
            else
            {
                leavingMessage = "MessageGroupWandererLeaving".Translate();
            }

            transition.AddPreAction(new TransitionAction_Message(leavingMessage));
            stateGraph.AddTransition(transition);
            Transition transition2 = new Transition(lordToil_ExitMapBest, startingToil2);

            transition2.AddTrigger(new Trigger_PawnCanReachMapEdge());
            transition2.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            transition2.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition2);
            Transition transition3 = new Transition(startingToil, lordToil_WanderAndChat);

            transition3.AddTrigger(new Trigger_Memo("TravelArrived"));
            stateGraph.AddTransition(transition3);
            Transition transition4 = new Transition(lordToil_WanderAndChat, lordToil_TakeWoundedGuest);

            transition4.AddTrigger(new Trigger_WoundedGuestPresent());

            stateGraph.AddTransition(transition4);
            Transition transition5 = new Transition(lordToil_WanderAndChat, target);

            transition5.AddSources(new LordToil[]
            {
                lordToil_TakeWoundedGuest,
                startingToil
            });
            transition5.AddTrigger(new Trigger_PawnLostViolently());
            transition5.AddPreAction(new TransitionAction_Custom(new Action(delegate { this.SwitchToHostileFaction(); })));
            transition5.AddPreAction(new TransitionAction_WakeAll());
            transition5.AddPreAction(new TransitionAction_SetDefendLocalGroup());
            transition5.AddPreAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition5);
            Transition transition6 = new Transition(lordToil_WanderAndChat, startingToil2);

            transition6.AddTrigger(new Trigger_TicksPassed(Rand.Range(8000, 22000)));
            transition6.AddPreAction(new TransitionAction_Message(leavingMessage));
            transition6.AddPreAction(new TransitionAction_WakeAll());
            transition6.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            stateGraph.AddTransition(transition6);

            LordToil_AssaultColony lordtoilAssault = new LordToil_AssaultColony();

            stateGraph.AddToil(lordtoilAssault);
            lordtoilAssault.avoidGridMode = AvoidGridMode.Smart;
            Transition transition7 = new Transition(lordToil_WanderAndChat, lordtoilAssault);

            transition7.AddPreAction(new TransitionAction_Custom(new Action(delegate { this.factionInt.SetHostileTo(Faction.OfPlayer, true); })));
            transition7.AddTrigger(new Trigger_Custom((TriggerSignal x) => this.InquisitorFoundHeretic && IoM_StoryUtilities.InquisitorShouldStartDirectAttack(this.Map, this.centralPawn.GetLord().ownedPawns)));
            stateGraph.AddTransition(transition7);

            LordToil_PanicFlee lordToilFlee = new LordToil_PanicFlee();
            Transition         transition8  = new Transition(lordToil_WanderAndChat, lordToilFlee);

            transition8.AddPreAction(new TransitionAction_Custom(new Action(delegate { this.factionInt.SetHostileTo(Faction.OfPlayer, true); })));
            transition8.AddTrigger(new Trigger_Custom((TriggerSignal x) => this.InquisitorFoundHeretic && !IoM_StoryUtilities.InquisitorShouldStartDirectAttack(this.Map, this.centralPawn.GetLord().ownedPawns)));
            stateGraph.AddTransition(transition8);
            return(stateGraph);
        }