public override StateGraph CreateGraph()
        {
            StateGraph graphArrive = new StateGraph();
            var        travelGraph = new LordJob_Travel(chillSpot).CreateGraph();

            travelGraph.StartingToil = new LordToil_CustomTravel(chillSpot, 0.49f); // CHANGED: override StartingToil
            LordToil toilArrive = graphArrive.AttachSubgraph(travelGraph).StartingToil;
            var      toilVisit  = new LordToil_VisitPoint(chillSpot);               // CHANGED

            graphArrive.lordToils.Add(toilVisit);
            LordToil toilTakeWounded = new LordToil_TakeWoundedGuest();

            graphArrive.lordToils.Add(toilTakeWounded);
            StateGraph graphExit    = new LordJob_TravelAndExit(IntVec3.Invalid).CreateGraph();
            LordToil   toilExit     = graphArrive.AttachSubgraph(graphExit).StartingToil;
            LordToil   toilLeaveMap = graphExit.lordToils[1];
            LordToil   toilLost     = new LordToil_End();

            graphExit.AddToil(toilLost);
            Transition t1 = new Transition(toilArrive, toilVisit);

            t1.triggers.Add(new Trigger_Memo("TravelArrived"));
            graphArrive.transitions.Add(t1);
            LordToil_ExitMapBest toilExitCold = new LordToil_ExitMapBest(); // ADDED TOIL

            graphArrive.AddToil(toilExitCold);
            Transition t6 = new Transition(toilArrive, toilExitCold); // ADDED TRANSITION

            t6.triggers.Add(new Trigger_UrgentlyCold());
            t6.preActions.Add(new TransitionAction_Message("MessageVisitorsLeavingCold".Translate(new object[] { faction.Name })));
            t6.preActions.Add(new TransitionAction_Custom(() => StopPawns(lord.ownedPawns)));
            graphArrive.transitions.Add(t6);
            Transition t2 = new Transition(toilVisit, toilTakeWounded);

            t2.triggers.Add(new Trigger_WoundedGuestPresent());
            t2.preActions.Add(new TransitionAction_Message("MessageVisitorsTakingWounded".Translate(new object[] { faction.def.pawnsPlural.CapitalizeFirst(), faction.Name })));
            graphArrive.transitions.Add(t2);
            Transition t3 = new Transition(toilVisit, toilLeaveMap);

            t3.triggers.Add(new Trigger_BecameColonyEnemy());
            t3.preActions.Add(new TransitionAction_WakeAll());
            t3.preActions.Add(new TransitionAction_SetDefendLocalGroup());
            graphArrive.transitions.Add(t3);
            Transition t4 = new Transition(toilArrive, toilExit);

            t4.triggers.Add(new Trigger_BecameColonyEnemy());
            //t4.triggers.Add(new Trigger_VisitorsPleasedMax(MaxPleaseAmount(faction.ColonyGoodwill))); // CHANGED
            t4.triggers.Add(new Trigger_VisitorsAngeredMax(IncidentWorker_VisitorGroup.MaxAngerAmount(faction.PlayerGoodwill))); // CHANGED
            t4.preActions.Add(new TransitionAction_WakeAll());
            t4.preActions.Add(new TransitionAction_EnsureHaveExitDestination());
            graphArrive.transitions.Add(t4);
            Transition t5 = new Transition(toilVisit, toilExit);

            t5.triggers.Add(new Trigger_TicksPassed(Rand.Range(16000, 44000)));
            t5.preActions.Add(new TransitionAction_Message("VisitorsLeaving".Translate(new object[] { faction.Name })));
            t5.preActions.Add(new TransitionAction_WakeAll());
            t5.preActions.Add(new TransitionAction_EnsureHaveExitDestination());
            graphArrive.transitions.Add(t5);
            return(graphArrive);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!base.TryResolveParms(parms))
            {
                return(false);
            }
            IntVec3 travelDest;

            if (!RCellFinder.TryFindTravelDestFrom(parms.spawnCenter, map, out travelDest))
            {
                Log.Warning("Failed to do traveler incident from " + parms.spawnCenter + ": couldn't find anywhere for the traveler to go.");
                return(false);
            }
            List <Pawn> list = base.SpawnPawns(parms);

            if (list.Count == 0)
            {
                return(false);
            }
            string text;

            if (list.Count == 1)
            {
                text = "SingleTravelerPassing".Translate(new object[]
                {
                    list[0].story.Title.ToLower(),
                    parms.faction.Name,
                    list[0].Name
                });
                text = text.AdjustedFor(list[0]);
            }
            else
            {
                text = "GroupTravelersPassing".Translate(new object[]
                {
                    parms.faction.Name
                });
            }
            Messages.Message(text, list[0], MessageTypeDefOf.NeutralEvent);
            LordJob_TravelAndExit lordJob = new LordJob_TravelAndExit(travelDest);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            string empty  = string.Empty;
            string empty2 = string.Empty;

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref empty, ref empty2, "LetterRelatedPawnsNeutralGroup".Translate(), true, true);
            if (!empty2.NullOrEmpty())
            {
                Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.NeutralEvent, list[0], null);
            }
            return(true);
        }
Beispiel #3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            bool    result;
            IntVec3 travelDest;

            if (!base.TryResolveParms(parms))
            {
                result = false;
            }
            else if (!RCellFinder.TryFindTravelDestFrom(parms.spawnCenter, map, out travelDest))
            {
                Log.Warning("Failed to do traveler incident from " + parms.spawnCenter + ": Couldn't find anywhere for the traveler to go.", false);
                result = false;
            }
            else
            {
                List <Pawn> list = base.SpawnPawns(parms);
                if (list.Count == 0)
                {
                    result = false;
                }
                else
                {
                    string text;
                    if (list.Count == 1)
                    {
                        text = "SingleTravelerPassing".Translate(new object[]
                        {
                            list[0].story.Title,
                            parms.faction.Name,
                            list[0].Name
                        });
                        text = text.AdjustedFor(list[0], "PAWN");
                    }
                    else
                    {
                        text = "GroupTravelersPassing".Translate(new object[]
                        {
                            parms.faction.Name
                        });
                    }
                    Messages.Message(text, list[0], MessageTypeDefOf.NeutralEvent, true);
                    LordJob_TravelAndExit lordJob = new LordJob_TravelAndExit(travelDest);
                    LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(list, "LetterRelatedPawnsNeutralGroup".Translate(new object[]
                    {
                        Faction.OfPlayer.def.pawnsPlural
                    }), LetterDefOf.NeutralEvent, true, true);
                    result = true;
                }
            }
            return(result);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!TryResolveParms(parms))
            {
                return(false);
            }
            if (!RCellFinder.TryFindTravelDestFrom(parms.spawnCenter, map, out var travelDest))
            {
                Log.Warning(string.Concat("Failed to do traveler incident from ", parms.spawnCenter, ": Couldn't find anywhere for the traveler to go."));
                return(false);
            }
            List <Pawn> list = SpawnPawns(parms);

            if (list.Count == 0)
            {
                return(false);
            }
            string text;

            if (list.Count == 1)
            {
                text = "SingleTravelerPassing".Translate(list[0].story.Title, parms.faction.Name, list[0].Name.ToStringFull, list[0].Named("PAWN"));
                text = text.AdjustedFor(list[0]);
            }
            else
            {
                text = "GroupTravelersPassing".Translate(parms.faction.Name);
            }
            Messages.Message(text, list[0], MessageTypeDefOf.NeutralEvent);
            LordJob_TravelAndExit lordJob = new LordJob_TravelAndExit(travelDest);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(list, "LetterRelatedPawnsNeutralGroup".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, informEvenIfSeenBefore: true);
            return(true);
        }
Beispiel #5
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph   = new StateGraph();
            LordToil   startingToil = stateGraph.AttachSubgraph(new LordJob_Travel(this.chillSpot).CreateGraph()).StartingToil;

            stateGraph.StartingToil = startingToil;
            LordToil_DefendPoint lordToil_DefendPoint = new LordToil_DefendPoint(this.chillSpot, 28f);

            stateGraph.AddToil(lordToil_DefendPoint);
            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_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Walk, true);

            stateGraph.AddToil(lordToil_ExitMap);
            Transition transition = new Transition(startingToil, startingToil2, false, true);

            transition.AddSources(new LordToil[]
            {
                lordToil_DefendPoint
            });
            transition.AddTrigger(new Trigger_PawnExperiencingDangerousTemperatures());
            transition.AddPreAction(new TransitionAction_Message("MessageVisitorsDangerousTemperature".Translate(this.faction.def.pawnsPlural.CapitalizeFirst(), this.faction.Name), null, 1f));
            transition.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            transition.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition, false);
            Transition transition2 = new Transition(startingToil, lordToil_ExitMap, false, true);

            transition2.AddSources(new LordToil[]
            {
                lordToil_DefendPoint,
                lordToil_TakeWoundedGuest
            });
            transition2.AddSources(stateGraph2.lordToils);
            transition2.AddTrigger(new Trigger_PawnCannotReachMapEdge());
            transition2.AddPreAction(new TransitionAction_Message("MessageVisitorsTrappedLeaving".Translate(this.faction.def.pawnsPlural.CapitalizeFirst(), this.faction.Name), null, 1f));
            stateGraph.AddTransition(transition2, false);
            Transition transition3 = new Transition(lordToil_ExitMap, startingToil2, false, true);

            transition3.AddTrigger(new Trigger_PawnCanReachMapEdge());
            transition3.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            transition3.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition3, false);
            Transition transition4 = new Transition(startingToil, lordToil_DefendPoint, false, true);

            transition4.AddTrigger(new Trigger_Memo("TravelArrived"));
            stateGraph.AddTransition(transition4, false);
            Transition transition5 = new Transition(lordToil_DefendPoint, lordToil_TakeWoundedGuest, false, true);

            transition5.AddTrigger(new Trigger_WoundedGuestPresent());
            transition5.AddPreAction(new TransitionAction_Message("MessageVisitorsTakingWounded".Translate(this.faction.def.pawnsPlural.CapitalizeFirst(), this.faction.Name), null, 1f));
            stateGraph.AddTransition(transition5, false);
            Transition transition6 = new Transition(lordToil_DefendPoint, target, false, true);

            transition6.AddSources(new LordToil[]
            {
                lordToil_TakeWoundedGuest,
                startingToil
            });
            transition6.AddTrigger(new Trigger_BecamePlayerEnemy());
            transition6.AddPreAction(new TransitionAction_SetDefendLocalGroup());
            transition6.AddPostAction(new TransitionAction_WakeAll());
            transition6.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition6, false);
            Transition transition7 = new Transition(lordToil_DefendPoint, startingToil2, false, true);

            transition7.AddTrigger(new Trigger_TicksPassed((!DebugSettings.instantVisitorsGift) ? Rand.Range(8000, 22000) : 0));
            transition7.AddPreAction(new TransitionAction_Message("VisitorsLeaving".Translate(this.faction.Name), null, 1f));
            transition7.AddPreAction(new TransitionAction_CheckGiveGift());
            transition7.AddPostAction(new TransitionAction_WakeAll());
            transition7.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            stateGraph.AddTransition(transition7, false);
            return(stateGraph);
        }
Beispiel #6
0
        public override StateGraph CreateGraph()
        {
            StateGraph graphArrive = new StateGraph();
            StateGraph graphExit   = new LordJob_TravelAndExit(IntVec3.Invalid).CreateGraph();
            StateGraph travelGraph = new LordJob_Travel(chillSpot).CreateGraph();

            travelGraph.StartingToil = new LordToil_CustomTravel(chillSpot, 0.49f, 85);
            // Arriving
            LordToil toilArriving = graphArrive.AttachSubgraph(travelGraph).StartingToil;
            // Visiting
            var toilVisiting = new LordToil_VisitPoint();

            graphArrive.lordToils.Add(toilVisiting);
            // Exit
            LordToil toilExit = graphArrive.AttachSubgraph(graphExit).StartingToil;
            // Leave map
            LordToil toilLeaveMap = graphExit.lordToils[1];
            // Take wounded
            LordToil toilTakeWounded = new LordToil_TakeWoundedGuest {
                lord = lord
            };                                                                      // This fixes the issue of missing lord when showing leave message

            graphExit.AddToil(toilTakeWounded);
            // Exit (TODO: Remove for 1.2)
            LordToil_ExitMap toilExitMap = new LordToil_ExitMap();

            graphArrive.AddToil(toilExitMap);
            // Arrived
            {
                Transition t1 = new Transition(toilArriving, toilVisiting);
                t1.triggers.Add(new Trigger_Memo("TravelArrived"));
                graphArrive.transitions.Add(t1);
            }
            // Too cold / hot
            {
                Transition t6 = new Transition(toilArriving, toilExit);
                t6.AddTrigger(new Trigger_PawnExperiencingDangerousTemperatures());
                t6.AddPreAction(new TransitionAction_Message("MessageVisitorsDangerousTemperature".Translate(faction?.def.pawnsPlural.CapitalizeFirst(), faction?.Name)));
                t6.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
                t6.AddPostAction(new TransitionAction_EndAllJobs());
                graphArrive.AddTransition(t6);
            }
            // Became enemy while arriving
            {
                Transition t3 = new Transition(toilVisiting, toilLeaveMap);
                t3.triggers.Add(new Trigger_BecamePlayerEnemy());
                t3.preActions.Add(new TransitionAction_SetDefendLocalGroup());
                t3.postActions.Add(new TransitionAction_WakeAll());
                graphArrive.transitions.Add(t3);
            }
            // Leave if became angry
            {
                Transition t4 = new Transition(toilArriving, toilExit);
                t4.triggers.Add(new Trigger_BecamePlayerEnemy());
                t4.triggers.Add(new Trigger_VisitorsAngeredMax(IncidentWorker_VisitorGroup.MaxAngerAmount(faction?.PlayerGoodwill ?? 0)));
                t4.preActions.Add(new TransitionAction_EnsureHaveExitDestination());
                t4.postActions.Add(new TransitionAction_WakeAll());
                graphArrive.transitions.Add(t4);
            }
            // Leave if stayed long enough
            {
                Transition t5 = new Transition(toilVisiting, toilExit);
                t5.triggers.Add(new Trigger_TicksPassedAndOkayToLeave(stayDuration));
                t5.triggers.Add(new Trigger_SentAway()); // Sent away during stay
                t5.preActions.Add(new TransitionAction_Message("VisitorsLeaving".Translate(faction?.Name)));
                t5.preActions.Add(new TransitionAction_EnsureHaveExitDestination());
                t5.postActions.Add(new TransitionAction_WakeAll());
                graphArrive.transitions.Add(t5);
            }
            // Leave if sent away (before fully arriving!)
            {
                Transition t7 = new Transition(toilArriving, toilExit);
                t7.triggers.Add(new Trigger_SentAway());
                t7.preActions.Add(new TransitionAction_Message("VisitorsLeaving".Translate(faction?.Name)));
                t7.preActions.Add(new TransitionAction_WakeAll());
                t7.preActions.Add(new TransitionAction_SendAway());
                graphArrive.transitions.Add(t7);
            }
            // Take wounded guest when arriving
            {
                Transition t8 = new Transition(toilArriving, toilTakeWounded);
                t8.AddTrigger(new Trigger_WoundedGuestPresent());
                t8.AddPreAction(new TransitionAction_Message("MessageVisitorsTakingWounded".Translate(faction?.def.pawnsPlural.CapitalizeFirst(), faction?.Name)));
                graphArrive.AddTransition(t8);
            }
            // Take wounded guest when leaving - couldn't get this to work
            //{
            //Transition t9 = new Transition(toilExit, toilTakeWounded);
            //t9.AddTrigger(new Trigger_WoundedGuestPresent());
            //t9.AddPreAction(new TransitionAction_Message("MessageVisitorsTakingWounded".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name)));
            //graphExit.AddTransition(t9);
            //}

            return(graphArrive);
        }
Beispiel #7
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);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph           stateGraph           = new StateGraph();
            LordToil             lordToil             = stateGraph.StartingToil = stateGraph.AttachSubgraph(new LordJob_Travel(chillSpot).CreateGraph()).StartingToil;
            LordToil_DefendPoint lordToil_DefendPoint = new LordToil_DefendPoint(chillSpot);

            stateGraph.AddToil(lordToil_DefendPoint);
            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_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Walk, canDig: true);

            stateGraph.AddToil(lordToil_ExitMap);

            //
            Transition transition = new Transition(lordToil, startingToil2);

            transition.AddSources(lordToil_DefendPoint);
            transition.AddTrigger(new Trigger_PawnExperiencingDangerousTemperatures());
            transition.AddPreAction(new TransitionAction_Message("MessageVisitorsDangerousTemperature".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name)));
            transition.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            transition.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition);

            //
            Transition transition2 = new Transition(lordToil, lordToil_ExitMap);

            transition2.AddSources(lordToil_DefendPoint, lordToil_TakeWoundedGuest);
            transition2.AddSources(stateGraph2.lordToils);
            transition2.AddTrigger(new Trigger_PawnCannotReachMapEdge());
            transition2.AddPreAction(new TransitionAction_Message("MessageVisitorsTrappedLeaving".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name)));
            stateGraph.AddTransition(transition2);

            //
            Transition transition3 = new Transition(lordToil_ExitMap, startingToil2);

            transition3.AddTrigger(new Trigger_PawnCanReachMapEdge());
            transition3.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            transition3.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition3);

            //
            Transition transition4 = new Transition(lordToil, lordToil_DefendPoint);

            transition4.AddTrigger(new Trigger_Memo("TravelArrived"));
            stateGraph.AddTransition(transition4);

            //
            Transition transition5 = new Transition(lordToil_DefendPoint, lordToil_TakeWoundedGuest);

            transition5.AddTrigger(new Trigger_WoundedGuestPresent());
            transition5.AddPreAction(new TransitionAction_Message("MessageVisitorsTakingWounded".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name)));
            stateGraph.AddTransition(transition5);

            //?
            Transition transition6 = new Transition(lordToil_DefendPoint, target);

            transition6.AddSources(lordToil_TakeWoundedGuest, lordToil);
            transition6.AddTrigger(new Trigger_BecamePlayerEnemy());
            transition6.AddPreAction(new TransitionAction_SetDefendLocalGroup());
            transition6.AddPostAction(new TransitionAction_WakeAll());
            transition6.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition6);

            //Leaving!
            Transition transition7 = new Transition(lordToil_DefendPoint, startingToil2);

            transition7.AddTrigger(new Trigger_TickCondition(() => Find.World.GetComponent <WorldComponent_FactionsTracker>().joinedFactionDef != null, 250));
            //transition7.AddTrigger(new Trigger_Memo("GetOutOfDodge"));
            //Trigger_Custom((TriggerSignal x) =>
            //));
            //transition7.AddTrigger(new Trigger_TicksPassed((!DebugSettings.instantVisitorsGift) ? Rand.Range(8000, 22000) : 0));
            transition7.AddPreAction(new TransitionAction_Message("VisitorsLeaving".Translate(faction.Name)));
            transition7.AddPreAction(new TransitionAction_CheckGiveGift());
            transition7.AddPostAction(new TransitionAction_WakeAll());
            transition7.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            stateGraph.AddTransition(transition7);
            return(stateGraph);
        }