Exemple #1
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil   lordToil   = stateGraph.StartingToil = stateGraph.AttachSubgraph(new LordJob_Travel(spot).CreateGraph()).StartingToil;

            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Walk, canDig: true);

            stateGraph.AddToil(lordToil_ExitMap);

            Transition transition = new Transition(lordToil, lordToil_ExitMap);

            transition.AddTrigger(new Trigger_Memo("TravelArrived"));
            transition.AddPreAction(new TransitionAction_Custom(delegate(Transition t)
            {
                IntVec3 seekPos = gifters.First().Position;
                foreach (var p in gifters)
                {
                    p.inventory.innerContainer.TryDropAll(p.Position, p.Map, ThingPlaceMode.Near);
                }

                Find.LetterStack.ReceiveLetter("GiftHasBeenDroppedTitle".Translate(), "GiftHasBeenDropped".Translate(), LetterDefOf.PositiveEvent, new LookTargets(seekPos, Map));
            }));
            stateGraph.AddTransition(transition);

            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph             = new StateGraph();
            LordToil_MillAboutCloseBy chillax = new LordToil_MillAboutCloseBy(locus);

            stateGraph.AddToil(chillax);
            LordToil_ExitMap leaveMap = new LordToil_ExitMap(LocomotionUrgency.Jog);

            Transition signalToLeave = new Transition(chillax, leaveMap);

            signalToLeave.AddTrigger(new Trigger_PawnRecruited());
            signalToLeave.AddTrigger(new Trigger_Custom((signal) => signal.type == TriggerSignalType.FactionRelationsChanged));
            signalToLeave.AddTrigger(new Trigger_FightWon());
            signalToLeave.AddTrigger(new Trigger_Memo("SetFree")); //triggered by ThingComp_RescueMe
            //signalToLeave.AddPostAction(new TransitionAction_Message("prisoners leaving.")); <- in case you want to use that one instead, for added clarity (more generic than PrisonersFreedLGE)
            signalToLeave.AddPostAction(new TransitionAction_WakeAll());
            signalToLeave.AddPostAction(new TransitionAction_Custom(() =>
            {
                Find.World.worldObjects.SiteAt(lord.Map.Tile)?.GetComponent <PrisonerRescueQuestComp>()?.GiveRewardsAndSendLetter();
            }));
            signalToLeave.AddPostAction(new TransitionAction_EndAllJobs());

            stateGraph.AddTransition(signalToLeave);
            stateGraph.AddToil(leaveMap);

            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph      stateGraph  = new StateGraph();
            List <LordToil> list        = new List <LordToil>();
            LordToil        assaultToil = new LordToil_AssaultColonyWendigo(attackDownedIfStarving: true);

            stateGraph.AddToil(assaultToil);
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Jog, canDig: false, interruptCurrentJob: true);

            lordToil_ExitMap.useAvoidGrid = true;
            stateGraph.AddToil(lordToil_ExitMap);

            Transition transitionLeaveOnSunLight = new Transition(assaultToil, lordToil_ExitMap);

            transitionLeaveOnSunLight.AddTrigger(new Trigger_SunLight());
            transitionLeaveOnSunLight.AddPreAction(new TransitionAction_Message("Wendigos.MessageRaidersLeavingDueSunLight"
                                                                                .Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name)));
            stateGraph.AddTransition(transitionLeaveOnSunLight);
            if (assaulterFaction != null)
            {
                Transition transition7 = new Transition(assaultToil, lordToil_ExitMap);
                transition7.AddSources(list);
                transition7.AddTrigger(new Trigger_BecameNonHostileToPlayer());
                transition7.AddPreAction(new TransitionAction_Message("MessageRaidersLeaving".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name)));
                stateGraph.AddTransition(transition7);
            }
            return(stateGraph);
        }
        public static bool Prefix(LordJob_AssaultColony __instance, ref StateGraph __result)
        {
            StateGraph stateGraph             = new StateGraph();
            LordToil   lordToil_assaultColony = new RealRaids.LordToil_AssaultColony();

            stateGraph.AddToil(lordToil_assaultColony);

            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Jog, canDig: false, interruptCurrentJob: true);

            lordToil_ExitMap.useAvoidGrid = true;
            stateGraph.AddToil(lordToil_ExitMap);

            if (__instance.assaulterFaction.def.humanlikeFaction)
            {
                if (__instance.canTimeoutOrFlee)
                {
                    Transition assaultToGiveUp = new Transition(lordToil_assaultColony, lordToil_ExitMap);
                    assaultToGiveUp.AddTrigger(new Trigger_TicksPassed(50000));
                    assaultToGiveUp.AddPreAction(new TransitionAction_Message("MessageRaidersGivenUpLeaving".Translate(__instance.assaulterFaction.def.pawnsPlural.CapitalizeFirst(), __instance.assaulterFaction.Name)));
                    stateGraph.AddTransition(assaultToGiveUp);
                }
            }

            Transition assaultToExit = new Transition(lordToil_assaultColony, lordToil_ExitMap);

            assaultToExit.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            assaultToExit.AddPreAction(new TransitionAction_Message("MessageRaidersLeaving".Translate(__instance.assaulterFaction.def.pawnsPlural.CapitalizeFirst(), __instance.assaulterFaction.Name)));

            stateGraph.AddTransition(assaultToExit);
            __result = stateGraph;
            return(false);
        }
    public override StateGraph CreateGraph()
    {
        var StateGraph = new StateGraph();

        Mailbox ??= Map.listerThings.ThingsOfDef(ThingDefOf.Tenants_MailBox).RandomElement();

        LordToil toilTravel = new LordToil_Travel(Mailbox.Position)
        {
            useAvoidGrid = true
        };

        StateGraph.AddToil(toilTravel);
        LordToil toilDeliver = new LordToil_CourierDeliver(Mailbox);

        StateGraph.AddToil(toilDeliver);
        LordToil toilLeave = new LordToil_ExitMap
        {
            useAvoidGrid = true
        };

        StateGraph.AddToil(toilLeave);

        var transitionWait = new Transition(toilTravel, toilDeliver);

        transitionWait.AddTrigger(new Trigger_Memo("TravelArrived"));
        StateGraph.AddTransition(transitionWait);

        var transitionLeave = new Transition(toilDeliver, toilLeave);

        transitionLeave.AddTrigger(new Trigger_TicksPassedAndNoRecentHarm(3000));
        StateGraph.AddTransition(transitionLeave);
        return(StateGraph);
    }
        public override StateGraph CreateGraph()
        {
            StateGraph           stateGraph           = new StateGraph();
            LordToil_HuntEnemies lordToil_HuntEnemies = new LordToil_HuntEnemies(this.fallbackLocation);

            stateGraph.AddToil(lordToil_HuntEnemies);
            StateGraph       stateGraph2      = new LordJob_Travel(IntVec3.Invalid).CreateGraph();
            LordToil         startingToil     = stateGraph.AttachSubgraph(stateGraph2).StartingToil;
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.None, false);

            stateGraph.AddToil(lordToil_ExitMap);
            LordToil_ExitMap lordToil_ExitMap2 = new LordToil_ExitMap(LocomotionUrgency.Jog, true);

            stateGraph.AddToil(lordToil_ExitMap2);
            Transition transition = new Transition(lordToil_HuntEnemies, startingToil, false, true);

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

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

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

            transition4.AddPreAction(new TransitionAction_Message("MessageFriendlyFightersLeaving".Translate(new object[]
            {
                this.faction.def.pawnsPlural.CapitalizeFirst(),
                this.faction.Name
            }), null, 1f));
            transition4.AddTrigger(new Trigger_TicksPassed(25000));
            transition4.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            stateGraph.AddTransition(transition4, false);
            Transition transition5 = new Transition(startingToil, lordToil_ExitMap, false, true);

            transition5.AddTrigger(new Trigger_Memo("TravelArrived"));
            stateGraph.AddTransition(transition5, false);
            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph       stateGraph       = new StateGraph();
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(locomotion, canDig);

            lordToil_ExitMap.useAvoidGrid = true;
            stateGraph.AddToil(lordToil_ExitMap);
            return(stateGraph);
        }
Exemple #8
0
        public override StateGraph CreateGraph()
        {
            StateGraph       stateGraph       = new StateGraph();
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(this.locomotion, this.canDig);

            lordToil_ExitMap.avoidGridMode = AvoidGridMode.Smart;
            stateGraph.AddToil(lordToil_ExitMap);
            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph      stateGraph      = new StateGraph();
            LordToil_Travel lordToil_Travel = new LordToil_Travel(this.groupUpLoc);

            lordToil_Travel.maxDanger     = Danger.Deadly;
            lordToil_Travel.avoidGridMode = AvoidGridMode.Smart;
            stateGraph.StartingToil       = lordToil_Travel;
            LordToil_PrisonerEscape lordToil_PrisonerEscape = new LordToil_PrisonerEscape(this.exitPoint, this.sapperThingID);

            lordToil_PrisonerEscape.avoidGridMode = AvoidGridMode.Smart;
            stateGraph.AddToil(lordToil_PrisonerEscape);
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Jog, false);

            lordToil_ExitMap.avoidGridMode = AvoidGridMode.Smart;
            stateGraph.AddToil(lordToil_ExitMap);
            LordToil_ExitMap lordToil_ExitMap2 = new LordToil_ExitMap(LocomotionUrgency.Jog, true);

            stateGraph.AddToil(lordToil_ExitMap2);
            Transition transition = new Transition(lordToil_Travel, lordToil_ExitMap2);

            transition.AddSources(new LordToil[]
            {
                lordToil_PrisonerEscape,
                lordToil_ExitMap
            });
            transition.AddTrigger(new Trigger_PawnCannotReachMapEdge());
            stateGraph.AddTransition(transition);
            Transition transition2 = new Transition(lordToil_ExitMap2, lordToil_ExitMap);

            transition2.AddTrigger(new Trigger_PawnCanReachMapEdge());
            transition2.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition2);
            Transition transition3 = new Transition(lordToil_Travel, lordToil_PrisonerEscape);

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

            transition4.AddTrigger(new Trigger_PawnLost());
            stateGraph.AddTransition(transition4);
            Transition transition5 = new Transition(lordToil_PrisonerEscape, lordToil_PrisonerEscape);

            transition5.canMoveToSameState = true;
            transition5.AddTrigger(new Trigger_PawnLost());
            transition5.AddTrigger(new Trigger_PawnHarmed(1f, false));
            stateGraph.AddTransition(transition5);
            Transition transition6 = new Transition(lordToil_PrisonerEscape, lordToil_ExitMap);

            transition6.AddTrigger(new Trigger_Memo("TravelArrived"));
            stateGraph.AddTransition(transition6);
            return(stateGraph);
        }
Exemple #10
0
        public override StateGraph CreateGraph()
        {
            StateGraph       stateGraph       = new StateGraph();
            LordToil         firstSource      = stateGraph.StartingToil = stateGraph.AttachSubgraph(new LordJob_Travel(travelDest).CreateGraph()).StartingToil;
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap();

            stateGraph.AddToil(lordToil_ExitMap);
            Transition transition = new Transition(firstSource, lordToil_ExitMap);

            transition.triggers.Add(new Trigger_Memo("TravelArrived"));
            stateGraph.AddTransition(transition);
            return(stateGraph);
        }
        //NewRatkin.LordJob_BombPlanting:LordJob
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph   = new StateGraph();
            LordToil   startingToil = stateGraph.AttachSubgraph(new LordJob_Travel(defendingSpot).CreateGraph()).StartingToil;
            //거점 방어 상태
            LordToil_DefendBomb lordToil_Siege = new LordToil_DefendBomb(defendingSpot, eventPoint);

            stateGraph.AddToil(lordToil_Siege);

            //목적지 이동 트랜지션
            Transition moveToDest = new Transition(startingToil, lordToil_Siege, false, true);

            moveToDest.AddTrigger(new Trigger_Memo("TravelArrived"));
            moveToDest.AddTrigger(new Trigger_TicksPassed(5000));
            stateGraph.AddTransition(moveToDest, false);

            //정착지 공격 상태
            LordToil noFleeAssaultColony = new LordToil_AssaultColony(false);

            noFleeAssaultColony.useAvoidGrid = true;
            stateGraph.AddToil(noFleeAssaultColony);

            //정착지 공격 트랜잭션
            Transition assultColony = new Transition(lordToil_Siege, noFleeAssaultColony, false, true);

            assultColony.AddTrigger(new Trigger_Memo("NoBuilders"));
            assultColony.AddTrigger(new Trigger_Memo("NoBomb"));
            assultColony.AddTrigger(new Trigger_TicksPassed(15000));

            FloatRange floatRange    = new FloatRange(0.25f, 0.35f);
            float      randomInRange = floatRange.RandomInRange;

            assultColony.AddPreAction(new TransitionAction_Message("MessageCommandoAssaulting".Translate(faction.def.pawnsPlural, faction), MessageTypeDefOf.ThreatBig, null, 1f));
            assultColony.AddPostAction(new TransitionAction_WakeAll());

            //퇴각 상태
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Jog, false);

            lordToil_ExitMap.useAvoidGrid = true;
            stateGraph.AddToil(lordToil_ExitMap);

            //퇴각 트랜지션
            Transition exitMap = new Transition(noFleeAssaultColony, lordToil_ExitMap, false, true);

            exitMap.AddTrigger(new Trigger_FractionColonyDamageTaken(randomInRange, 1200));
            exitMap.AddPreAction(new TransitionAction_Message("MessageRaidersSatisfiedLeaving".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name), null, 1f));
            stateGraph.AddTransition(assultColony, false);
            stateGraph.AddTransition(exitMap, false);

            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil_DefendTraderCaravan firstSource      = (LordToil_DefendTraderCaravan)(stateGraph.StartingToil = new LordToil_DefendTraderCaravan(this.defendSpot));
            LordToil_ExitMap             lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.None, false);

            stateGraph.AddToil(lordToil_ExitMap);
            Transition transition = new Transition(firstSource, lordToil_ExitMap);

            transition.AddTrigger(new Trigger_BecameColonyAlly());
            transition.AddTrigger(new Trigger_TraderAndAllTraderCaravanGuardsLost());
            stateGraph.AddTransition(transition);
            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil_DefendTraderCaravan firstSource      = (LordToil_DefendTraderCaravan)(stateGraph.StartingToil = new LordToil_DefendTraderCaravan(defendSpot));
            LordToil_ExitMap             lordToil_ExitMap = new LordToil_ExitMap();

            stateGraph.AddToil(lordToil_ExitMap);
            Transition transition = new Transition(firstSource, lordToil_ExitMap);

            transition.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            transition.AddTrigger(new Trigger_TraderAndAllTraderCaravanGuardsLost());
            stateGraph.AddTransition(transition);
            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil_DefendTraderCaravan lordToil_DefendTraderCaravan = new LordToil_DefendTraderCaravan(this.defendSpot);

            stateGraph.StartingToil = lordToil_DefendTraderCaravan;
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.None, false);

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

            transition.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            transition.AddTrigger(new Trigger_TraderAndAllTraderCaravanGuardsLost());
            stateGraph.AddTransition(transition, false);
            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph       stateGraph       = new StateGraph();
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(locomotion, canDig);

            lordToil_ExitMap.useAvoidGrid = true;
            stateGraph.AddToil(lordToil_ExitMap);
            if (canDefendSelf)
            {
                LordToil_ExitMapFighting lordToil_ExitMapFighting = new LordToil_ExitMapFighting(LocomotionUrgency.Jog, canDig);
                stateGraph.AddToil(lordToil_ExitMapFighting);
                Transition transition = new Transition(lordToil_ExitMap, lordToil_ExitMapFighting);
                transition.AddTrigger(new Trigger_PawnHarmed());
                transition.AddPostAction(new TransitionAction_WakeAll());
                transition.AddPostAction(new TransitionAction_EndAllJobs());
                stateGraph.AddTransition(transition);
            }
            return(stateGraph);
        }
Exemple #16
0
        public override StateGraph CreateGraph()
        {
            StateGraph     stateGraph     = new StateGraph();
            LordToil       startingToil   = stateGraph.AttachSubgraph(new LordJob_Travel(siegeSpot).CreateGraph()).StartingToil;
            LordToil_Siege lordToil_Siege = new LordToil_Siege(siegeSpot, blueprintPoints);

            stateGraph.AddToil(lordToil_Siege);
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Jog, canDig: false, interruptCurrentJob: true)
            {
                useAvoidGrid = true
            };

            stateGraph.AddToil(lordToil_ExitMap);
            LordToil   startingToil2 = stateGraph.AttachSubgraph(new LordJob_AssaultColony(faction).CreateGraph()).StartingToil;
            Transition transition    = new Transition(startingToil, lordToil_Siege);

            transition.AddTrigger(new Trigger_Memo("TravelArrived"));
            transition.AddTrigger(new Trigger_TicksPassed(5000));
            stateGraph.AddTransition(transition);
            Transition transition2 = new Transition(lordToil_Siege, startingToil2);

            transition2.AddTrigger(new Trigger_Memo("NoBuilders"));
            transition2.AddTrigger(new Trigger_Memo("NoArtillery"));
            transition2.AddTrigger(new Trigger_PawnHarmed(0.08f));
            transition2.AddTrigger(new Trigger_FractionPawnsLost(0.3f));
            transition2.AddTrigger(new Trigger_TicksPassed((int)(60000f * Rand.Range(1.5f, 3f))));
            transition2.AddPreAction(new TransitionAction_Message("MessageSiegersAssaulting".Translate(faction.def.pawnsPlural, faction), MessageTypeDefOf.ThreatBig));
            transition2.AddPostAction(new TransitionAction_WakeAll());
            stateGraph.AddTransition(transition2);
            Transition transition3 = new Transition(lordToil_Siege, lordToil_ExitMap);

            transition3.AddSource(startingToil2);
            transition3.AddSource(startingToil);
            transition3.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            transition3.AddPreAction(new TransitionAction_Message("MessageRaidersLeaving".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name)));
            stateGraph.AddTransition(transition3);
            return(stateGraph);
        }
Exemple #17
0
        public override StateGraph CreateGraph()
        {
            StateGraph           stateGraph = new StateGraph();
            LordToil_DefendPoint dropToil   = new LordToil_DefendPoint(true);

            stateGraph.StartingToil = dropToil; // Just used to verify the exit spot is valid.
            LordToil_Travel travelToil = new LordToil_Travel(this.targetDestination);

            stateGraph.AddToil(travelToil);
            LordToil_DefendPoint defendPointToil = new LordToil_DefendPoint(false);

            stateGraph.AddToil(defendPointToil);
            LordToil_ExitMap exitMapPeacefullyToil = new LordToil_ExitMap(LocomotionUrgency.Walk, false);

            stateGraph.AddToil(exitMapPeacefullyToil);
            LordToil_EscortDownedPawn escortDownedPawnPeacefullyToil = new LordToil_EscortDownedPawn(this.targetDestination, LocomotionUrgency.Walk);

            stateGraph.AddToil(escortDownedPawnPeacefullyToil);
            LordToil_ExitMap exitMapHurryToil = new LordToil_ExitMap(LocomotionUrgency.Jog, true);

            stateGraph.AddToil(exitMapHurryToil);
            LordToil_DefendPoint defendPointHurryToil = new LordToil_DefendPoint(false);

            stateGraph.AddToil(defendPointHurryToil);
            LordToil_EscortDownedPawn escortDownedPawnHurryToil = new LordToil_EscortDownedPawn(this.targetDestination, LocomotionUrgency.Jog);

            stateGraph.AddToil(escortDownedPawnHurryToil);

            // Begin travel.
            stateGraph.AddTransition(new Transition(dropToil, travelToil)
            {
                triggers =
                {
                    new Trigger_TicksPassedWithoutHarm(1)
                },
                preActions =
                {
                    new TransitionAction_CheckExitSpotIsValid()
                },
                postActions =
                {
                    new TransitionAction_EndAllJobs()
                }
            });
            // Defend.
            stateGraph.AddTransition(new Transition(travelToil, defendPointToil)
            {
                triggers =
                {
                    new Trigger_PawnHarmed(1f, false)
                },
                preActions =
                {
                    new TransitionAction_SetDefendLocalGroup()
                },
                postActions =
                {
                    new TransitionAction_EndAllJobs()
                }
            });
            // Back to travel after defending.
            stateGraph.AddTransition(new Transition(defendPointToil, travelToil)
            {
                triggers =
                {
                    new Trigger_TicksPassedWithoutHarm(1200)
                },
                preActions =
                {
                    new TransitionAction_EnsureHaveExitDestination()
                }
            });
            // Escort downed pawn peacefully.
            stateGraph.AddTransition(new Transition(travelToil, escortDownedPawnPeacefullyToil)
            {
                sources =
                {
                    exitMapPeacefullyToil
                },
                triggers =
                {
                    new Trigger_ReachableDownedPawn()
                },
                preActions =
                {
                    new TransitionAction_CheckExitSpotIsValid()
                },
                postActions =
                {
                    new TransitionAction_EndAllJobs()
                }
            });
            // Back to travel after escorting pawn peacefully.
            stateGraph.AddTransition(new Transition(escortDownedPawnPeacefullyToil, travelToil)
            {
                triggers =
                {
                    new Trigger_Memo("RescueEnded")
                }
            });
            // Exit peacefully.
            stateGraph.AddTransition(new Transition(travelToil, exitMapPeacefullyToil)
            {
                triggers =
                {
                    new Trigger_Memo("TravelArrived")
                },
                postActions =
                {
                    new TransitionAction_EndAllJobs()
                }
            });
            // Exit in hurry.
            stateGraph.AddTransition(new Transition(travelToil, exitMapHurryToil)
            {
                sources =
                {
                    exitMapPeacefullyToil,
                    escortDownedPawnPeacefullyToil
                },
                triggers =
                {
                    new Trigger_PawnCannotReachTargetDestination(),
                    new Trigger_HostileToColony()
                },
                postActions =
                {
                    new TransitionAction_EndAllJobs()
                }
            });
            // Defend in hurry.
            stateGraph.AddTransition(new Transition(exitMapHurryToil, defendPointHurryToil)
            {
                triggers =
                {
                    new Trigger_PawnHarmed(1f, false)
                },
                preActions =
                {
                    new TransitionAction_SetDefendLocalGroup()
                },
                postActions =
                {
                    new TransitionAction_EndAllJobs()
                }
            });
            // Back to exit in hurry after defending.
            stateGraph.AddTransition(new Transition(defendPointHurryToil, exitMapHurryToil)
            {
                triggers =
                {
                    new Trigger_TicksPassedWithoutHarm(1200)
                }
            });
            // Escort downed pawn in hurry.
            stateGraph.AddTransition(new Transition(exitMapHurryToil, escortDownedPawnHurryToil)
            {
                triggers =
                {
                    new Trigger_ReachableDownedPawn()
                },
                preActions =
                {
                    new TransitionAction_CheckExitSpotIsValid()
                },
                postActions =
                {
                    new TransitionAction_EndAllJobs()
                }
            });
            // Back to exit in hurry after escorting pawn in hurry.
            stateGraph.AddTransition(new Transition(escortDownedPawnHurryToil, exitMapHurryToil)
            {
                triggers =
                {
                    new Trigger_Memo("RescueEnded")
                }
            });
            return(stateGraph);
        }
Exemple #18
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph                 = new StateGraph();
            string     noFulfilledTradeMsg        = "IR.LordJobFulfillItemRequest.NoFulfillTrade".Translate();
            string     partiallyFulfilledTradeMsg = "IR.LordJobFulfillItemRequest.NoFulfillAllTrade".Translate();
            string     addedMessageText           = faction.RelationKindWith(playerFaction) == FactionRelationKind.Neutral ?
                                                    "IR.LordJobFulfillItemRequest.AttackingOutOfAnger".Translate() :
                                                    "IR.LordJobFulfillItemRequest.RelationsDropped".Translate();
            TransitionAction_Custom clearCaravanRequest = new TransitionAction_Custom(() => {
                Find.World.GetComponent <RequestSession>().CloseOpenDealWith(faction);
            });

            // ===================
            //       TOILS
            // ===================
            LordToil_Travel moving = new LordToil_Travel(chillSpot);

            stateGraph.StartingToil = moving;

            LordToil_DefendPoint defending = new LordToil_DefendTraderCaravan();

            stateGraph.AddToil(defending);

            LordToil_DefendPoint defendingChillPoint = new LordToil_DefendTraderCaravan(chillSpot, 40);

            stateGraph.AddToil(defendingChillPoint);

            LordToil_ExitMapAndEscortCarriers exitingAndEscorting = new LordToil_ExitMapAndEscortCarriers();

            stateGraph.AddToil(exitingAndEscorting);

            LordToil_ExitMap exiting = new LordToil_ExitMap();

            stateGraph.AddToil(exiting);

            LordToil_ExitMap urgentExiting = new LordToil_ExitMap(LocomotionUrgency.Walk, true);

            stateGraph.AddToil(urgentExiting);

            LordToil_ExitMapTraderFighting exitWhileFighting = new LordToil_ExitMapTraderFighting();

            stateGraph.AddToil(exitWhileFighting);

            // ===================
            //    TRANSITIONS
            // ===================
            Transition leaveIfDangerousTemp = new Transition(moving, exitingAndEscorting);

            leaveIfDangerousTemp.AddSources(new LordToil[]
            {
                defending,
                defendingChillPoint
            });
            leaveIfDangerousTemp.AddTrigger(new Trigger_PawnExperiencingDangerousTemperatures());
            leaveIfDangerousTemp.AddPreAction(new TransitionAction_Message("MessageVisitorsDangerousTemperature".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name)));
            leaveIfDangerousTemp.AddPostAction(new TransitionAction_EndAllJobs());
            leaveIfDangerousTemp.AddPostAction(clearCaravanRequest);
            stateGraph.AddTransition(leaveIfDangerousTemp);

            Transition leaveIfTrapped = new Transition(moving, urgentExiting);

            leaveIfTrapped.AddSources(new LordToil[]
            {
                defending,
                defendingChillPoint,
                exitingAndEscorting,
                exiting,
                exitWhileFighting
            });
            leaveIfTrapped.AddTrigger(new Trigger_PawnCannotReachMapEdge());
            leaveIfTrapped.AddPostAction(new TransitionAction_Message("MessageVisitorsTrappedLeaving".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name)));
            leaveIfTrapped.AddPostAction(new TransitionAction_WakeAll());
            leaveIfTrapped.AddPostAction(new TransitionAction_EndAllJobs());
            leaveIfTrapped.AddPostAction(clearCaravanRequest);
            stateGraph.AddTransition(leaveIfTrapped);

            Transition fightIfTrapped = new Transition(urgentExiting, exitWhileFighting);

            fightIfTrapped.AddTrigger(new Trigger_PawnCanReachMapEdge());
            fightIfTrapped.AddPostAction(new TransitionAction_EndAllJobs());
            fightIfTrapped.AddPostAction(clearCaravanRequest);
            stateGraph.AddTransition(fightIfTrapped);

            Transition fightIfFractionPawnsLost = new Transition(moving, exitWhileFighting);

            fightIfFractionPawnsLost.AddSources(new LordToil[]
            {
                defending,
                defendingChillPoint,
                exitingAndEscorting,
                exiting
            });
            fightIfFractionPawnsLost.AddTrigger(new Trigger_FractionPawnsLost(0.2f));
            fightIfFractionPawnsLost.AddPostAction(new TransitionAction_EndAllJobs());
            fightIfFractionPawnsLost.AddPostAction(clearCaravanRequest);
            stateGraph.AddTransition(fightIfFractionPawnsLost);

            Transition defendIfPawnHarmed = new Transition(moving, defending);

            defendIfPawnHarmed.AddTrigger(new Trigger_PawnHarmed());
            defendIfPawnHarmed.AddPreAction(new TransitionAction_SetDefendTrader());
            defendIfPawnHarmed.AddPostAction(new TransitionAction_WakeAll());
            defendIfPawnHarmed.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(defendIfPawnHarmed);

            Transition returnToNormalAfterTimePasses = new Transition(defending, moving);

            returnToNormalAfterTimePasses.AddTrigger(new Trigger_TicksPassedWithoutHarm(1200));
            stateGraph.AddTransition(returnToNormalAfterTimePasses);

            Transition stayPutAtSpot = new Transition(moving, defendingChillPoint);

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

            Transition leaveIfRequestFulfilled = new Transition(moving, exitingAndEscorting);

            leaveIfRequestFulfilled.AddSources(new LordToil[]
            {
                defending,
                defendingChillPoint,
            });
            leaveIfRequestFulfilled.AddTrigger(new Trigger_Memo(MemoOnFulfilled));
            leaveIfRequestFulfilled.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.RequestedCaravanLeaving".Translate(faction.Name)));
            leaveIfRequestFulfilled.AddPostAction(new TransitionAction_WakeAll());
            stateGraph.AddTransition(leaveIfRequestFulfilled);


            int ticksUntilBadThings = Rand.Range(
                Mathf.RoundToInt(CaravanManager.fullDayInTicks / 2),                                   // 0.5  days
                CaravanManager.fullDayInTicks + Mathf.RoundToInt(CaravanManager.fullDayInTicks / 4));  // 1.25 days

            // Determine actions if request goes unfulfilled based on faction relation
            Trigger_TicksPassed      ticksPassed    = new Trigger_TicksPassed(ticksUntilBadThings);
            TransitionAction_Message actionMessage  = new TransitionAction_Message("IR.LordJobFulfillItemRequest.FactionInsulted".Translate(faction.Name) + "\n" + addedMessageText);
            TransitionAction_Message leavingMessage = new TransitionAction_Message("IR.LordJobFulfillItemRequest.RequestedCaravanLeaving".Translate(faction.Name));

            if (isFactionNeutral)
            {
                Action setFactionToHostile = () => faction.TrySetRelationKind(playerFaction, FactionRelationKind.Hostile, true, noFulfilledTradeMsg);

                Transition attackIfNotEnoughSilver = new Transition(moving, defending, true);
                attackIfNotEnoughSilver.AddSources(new LordToil[]
                {
                    defending,
                    defendingChillPoint,
                    exiting,
                    exitingAndEscorting
                });
                attackIfNotEnoughSilver.AddTrigger(new Trigger_Memo(MemoOnUnfulfilled));
                attackIfNotEnoughSilver.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.TradersAttacking".Translate(faction.Name)));
                attackIfNotEnoughSilver.AddPreAction(new TransitionAction_Custom(setFactionToHostile));
                attackIfNotEnoughSilver.AddPostAction(new TransitionAction_WakeAll());
                attackIfNotEnoughSilver.AddPostAction(new TransitionAction_SetDefendLocalGroup());
                stateGraph.AddTransition(attackIfNotEnoughSilver, true);

                Transition attackIfRequestUnfulfilled = new Transition(defendingChillPoint, defending);
                attackIfRequestUnfulfilled.AddTrigger(ticksPassed);
                attackIfRequestUnfulfilled.AddPreAction(actionMessage);
                attackIfRequestUnfulfilled.AddPreAction(new TransitionAction_Custom(setFactionToHostile));
                attackIfRequestUnfulfilled.AddPostAction(new TransitionAction_WakeAll());
                attackIfRequestUnfulfilled.AddPostAction(new TransitionAction_SetDefendLocalGroup());
                stateGraph.AddTransition(attackIfRequestUnfulfilled, true);

                Transition leaveAfterAttacking = new Transition(defendingChillPoint, exitingAndEscorting);
                leaveAfterAttacking.AddSource(defending);
                leaveAfterAttacking.AddTrigger(new Trigger_TicksPassed(ticksUntilBadThings + 10000));
                leaveAfterAttacking.AddPreAction(leavingMessage);
                leaveAfterAttacking.AddPostAction(new TransitionAction_EndAllJobs());
                stateGraph.AddTransition(leaveAfterAttacking);
            }
            else
            {
                Transition leaveIfRequestUnfulfilled = new Transition(moving, exitingAndEscorting);
                leaveIfRequestUnfulfilled.AddSources(new LordToil[]
                {
                    defending,
                    defendingChillPoint
                });
                leaveIfRequestUnfulfilled.AddTrigger(new Trigger_Memo(MemoOnUnfulfilled));
                leaveIfRequestUnfulfilled.AddTrigger(ticksPassed);
                leaveIfRequestUnfulfilled.AddPreAction(actionMessage);
                leaveIfRequestUnfulfilled.AddPreAction(new TransitionAction_Custom(() =>
                {
                    faction.TryAffectGoodwillWith(playerFaction, -30, true, false, noFulfilledTradeMsg);
                }));
                leaveIfRequestUnfulfilled.AddPostAction(leavingMessage);
                leaveIfRequestUnfulfilled.AddPostAction(new TransitionAction_WakeAll());
                stateGraph.AddTransition(leaveIfRequestUnfulfilled);
            }

            // Partial fulfillment
            Transition leaveIfRequestMostlyFulfilled = new Transition(moving, exiting);

            leaveIfRequestMostlyFulfilled.AddSources(new LordToil[]
            {
                defending,
                defendingChillPoint
            });
            leaveIfRequestMostlyFulfilled.AddTrigger(new Trigger_Memo(MemoOnPartiallyFulfilled_S));
            leaveIfRequestMostlyFulfilled.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.DisappointedTraders".Translate(faction.Name), MessageTypeDefOf.CautionInput));
            leaveIfRequestMostlyFulfilled.AddPreAction(new TransitionAction_Custom(() =>
            {
                faction.TryAffectGoodwillWith(playerFaction, -5, true, false, partiallyFulfilledTradeMsg);
            }));
            leaveIfRequestMostlyFulfilled.AddPostAction(leavingMessage);
            leaveIfRequestMostlyFulfilled.AddPostAction(new TransitionAction_WakeAll());
            stateGraph.AddTransition(leaveIfRequestMostlyFulfilled);


            Transition leaveIfRequestSomewhatFulfilled = new Transition(moving, exiting);

            leaveIfRequestSomewhatFulfilled.AddSources(new LordToil[]
            {
                defending,
                defendingChillPoint
            });
            leaveIfRequestSomewhatFulfilled.AddTrigger(new Trigger_Memo(MemoOnPartiallyFulfilled_M));
            leaveIfRequestSomewhatFulfilled.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.AnnoyedTraders".Translate(faction.Name), MessageTypeDefOf.CautionInput));
            leaveIfRequestSomewhatFulfilled.AddPreAction(new TransitionAction_Custom(() =>
            {
                faction.TryAffectGoodwillWith(playerFaction, -10, true, false, partiallyFulfilledTradeMsg);
            }));
            leaveIfRequestSomewhatFulfilled.AddPostAction(leavingMessage);
            leaveIfRequestSomewhatFulfilled.AddPostAction(new TransitionAction_WakeAll());
            stateGraph.AddTransition(leaveIfRequestSomewhatFulfilled);

            Transition leaveIfRequestHardlyFulfilled = new Transition(moving, exiting);

            leaveIfRequestHardlyFulfilled.AddSources(new LordToil[]
            {
                defending,
                defendingChillPoint
            });
            leaveIfRequestHardlyFulfilled.AddTrigger(new Trigger_Memo(MemoOnPartiallyFulfilled_L));
            leaveIfRequestHardlyFulfilled.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.OutragedTraders".Translate(faction.Name), MessageTypeDefOf.CautionInput));
            leaveIfRequestHardlyFulfilled.AddPreAction(new TransitionAction_Custom(() =>
            {
                faction.TryAffectGoodwillWith(playerFaction, -20, true, false, partiallyFulfilledTradeMsg);
            }));
            leaveIfRequestHardlyFulfilled.AddPostAction(leavingMessage);
            leaveIfRequestHardlyFulfilled.AddPostAction(new TransitionAction_WakeAll());
            stateGraph.AddTransition(leaveIfRequestHardlyFulfilled);

            Transition continueToLeaveMap = new Transition(exitingAndEscorting, exitingAndEscorting, true);

            continueToLeaveMap.AddTrigger(new Trigger_PawnLost());
            continueToLeaveMap.AddTrigger(new Trigger_TickCondition(() => LordToil_ExitMapAndEscortCarriers.IsAnyDefendingPosition(lord.ownedPawns) && !GenHostility.AnyHostileActiveThreatTo(Map, faction), 60));
            continueToLeaveMap.AddPostAction(clearCaravanRequest);
            stateGraph.AddTransition(continueToLeaveMap);

            Transition finishLeavingMap = new Transition(exitingAndEscorting, exiting);

            finishLeavingMap.AddTrigger(new Trigger_TicksPassed(60000));
            finishLeavingMap.AddPostAction(new TransitionAction_WakeAll());
            finishLeavingMap.AddPostAction(clearCaravanRequest);
            stateGraph.AddTransition(finishLeavingMap);

            Transition leaveIfBadThingsHappen = new Transition(defendingChillPoint, exitingAndEscorting);

            leaveIfBadThingsHappen.AddSources(new LordToil[]
            {
                moving,
                defending
            });
            leaveIfBadThingsHappen.AddTrigger(new Trigger_ImportantTraderCaravanPeopleLost());
            leaveIfBadThingsHappen.AddPostAction(new TransitionAction_WakeAll());
            leaveIfBadThingsHappen.AddPostAction(new TransitionAction_EndAllJobs());
            leaveIfBadThingsHappen.AddPostAction(clearCaravanRequest);
            stateGraph.AddTransition(leaveIfBadThingsHappen);

            return(stateGraph);
        }
Exemple #19
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);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph      stateGraph      = new StateGraph();
            LordToil_Travel lordToil_Travel = new LordToil_Travel(this.chillSpot);

            stateGraph.StartingToil = lordToil_Travel;
            LordToil_DefendTraderCaravan lordToil_DefendTraderCaravan = new LordToil_DefendTraderCaravan();

            stateGraph.AddToil(lordToil_DefendTraderCaravan);
            LordToil_DefendTraderCaravan lordToil_DefendTraderCaravan2 = new LordToil_DefendTraderCaravan(this.chillSpot);

            stateGraph.AddToil(lordToil_DefendTraderCaravan2);
            LordToil_ExitMapAndEscortCarriers lordToil_ExitMapAndEscortCarriers = new LordToil_ExitMapAndEscortCarriers();

            stateGraph.AddToil(lordToil_ExitMapAndEscortCarriers);
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.None, false);

            stateGraph.AddToil(lordToil_ExitMap);
            LordToil_ExitMap lordToil_ExitMap2 = new LordToil_ExitMap(LocomotionUrgency.Walk, true);

            stateGraph.AddToil(lordToil_ExitMap2);
            LordToil_ExitMapTraderFighting lordToil_ExitMapTraderFighting = new LordToil_ExitMapTraderFighting();

            stateGraph.AddToil(lordToil_ExitMapTraderFighting);
            Transition transition = new Transition(lordToil_Travel, lordToil_ExitMapAndEscortCarriers, false, true);

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

            transition2.AddSources(new LordToil[]
            {
                lordToil_DefendTraderCaravan,
                lordToil_DefendTraderCaravan2,
                lordToil_ExitMapAndEscortCarriers,
                lordToil_ExitMap,
                lordToil_ExitMapTraderFighting
            });
            transition2.AddTrigger(new Trigger_PawnCannotReachMapEdge());
            transition2.AddPostAction(new TransitionAction_Message("MessageVisitorsTrappedLeaving".Translate(new object[]
            {
                this.faction.def.pawnsPlural.CapitalizeFirst(),
                this.faction.Name
            }), null, 1f));
            transition2.AddPostAction(new TransitionAction_WakeAll());
            transition2.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition2, false);
            Transition transition3 = new Transition(lordToil_ExitMap2, lordToil_ExitMapTraderFighting, false, true);

            transition3.AddTrigger(new Trigger_PawnCanReachMapEdge());
            transition3.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition3, false);
            Transition transition4 = new Transition(lordToil_Travel, lordToil_ExitMapTraderFighting, false, true);

            transition4.AddSources(new LordToil[]
            {
                lordToil_DefendTraderCaravan,
                lordToil_DefendTraderCaravan2,
                lordToil_ExitMapAndEscortCarriers,
                lordToil_ExitMap
            });
            transition4.AddTrigger(new Trigger_FractionPawnsLost(0.2f));
            transition4.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition4, false);
            Transition transition5 = new Transition(lordToil_Travel, lordToil_DefendTraderCaravan, false, true);

            transition5.AddTrigger(new Trigger_PawnHarmed(1f, false, null));
            transition5.AddPreAction(new TransitionAction_SetDefendTrader());
            transition5.AddPostAction(new TransitionAction_WakeAll());
            transition5.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition5, false);
            Transition transition6 = new Transition(lordToil_DefendTraderCaravan, lordToil_Travel, false, true);

            transition6.AddTrigger(new Trigger_TicksPassedWithoutHarm(1200));
            stateGraph.AddTransition(transition6, false);
            Transition transition7 = new Transition(lordToil_Travel, lordToil_DefendTraderCaravan2, false, true);

            transition7.AddTrigger(new Trigger_Memo("TravelArrived"));
            stateGraph.AddTransition(transition7, false);
            Transition transition8 = new Transition(lordToil_DefendTraderCaravan2, lordToil_ExitMapAndEscortCarriers, false, true);

            transition8.AddTrigger(new Trigger_TicksPassed((!DebugSettings.instantVisitorsGift) ? Rand.Range(27000, 45000) : 0));
            transition8.AddPreAction(new TransitionAction_CheckGiveGift());
            transition8.AddPreAction(new TransitionAction_Message("MessageTraderCaravanLeaving".Translate(new object[]
            {
                this.faction.Name
            }), null, 1f));
            transition8.AddPostAction(new TransitionAction_WakeAll());
            stateGraph.AddTransition(transition8, false);
            Transition transition9 = new Transition(lordToil_ExitMapAndEscortCarriers, lordToil_ExitMapAndEscortCarriers, true, true);

            transition9.canMoveToSameState = true;
            transition9.AddTrigger(new Trigger_PawnLost());
            transition9.AddTrigger(new Trigger_TickCondition(() => LordToil_ExitMapAndEscortCarriers.IsAnyDefendingPosition(this.lord.ownedPawns) && !GenHostility.AnyHostileActiveThreatTo(base.Map, this.faction), 60));
            stateGraph.AddTransition(transition9, false);
            Transition transition10 = new Transition(lordToil_ExitMapAndEscortCarriers, lordToil_ExitMap, false, true);

            transition10.AddTrigger(new Trigger_TicksPassed(60000));
            transition10.AddPostAction(new TransitionAction_WakeAll());
            stateGraph.AddTransition(transition10, false);
            Transition transition11 = new Transition(lordToil_DefendTraderCaravan2, lordToil_ExitMapAndEscortCarriers, false, true);

            transition11.AddSources(new LordToil[]
            {
                lordToil_Travel,
                lordToil_DefendTraderCaravan
            });
            transition11.AddTrigger(new Trigger_ImportantTraderCaravanPeopleLost());
            transition11.AddTrigger(new Trigger_BecamePlayerEnemy());
            transition11.AddPostAction(new TransitionAction_WakeAll());
            transition11.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition11, false);
            return(stateGraph);
        }
Exemple #21
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil   lordToil   = null;

            LordToil lordToil2 = new LordToil_AssaultColonyArmored();

            stateGraph.AddToil(lordToil2);
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Jog, false, true);

            lordToil_ExitMap.useAvoidGrid = true;
            stateGraph.AddToil(lordToil_ExitMap);
            if (assaulterFaction.def.humanlikeFaction)
            {
                if (canTimeoutOrFlee)
                {
                    Transition transition3 = new Transition(lordToil2, lordToil_ExitMap, false, true);
                    if (lordToil != null)
                    {
                        transition3.AddSource(lordToil);
                    }
                    //transition3.AddTrigger(new Trigger_TicksPassed(sappers ? SapTimeBeforeGiveUp.RandomInRange : AssaultTimeBeforeGiveUp.RandomInRange));
                    transition3.AddPreAction(new TransitionAction_Message("MessageRaidersGivenUpLeaving".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name), null, 1f));
                    stateGraph.AddTransition(transition3, false);
                    Transition transition4 = new Transition(lordToil2, lordToil_ExitMap, false, true);
                    if (lordToil != null)
                    {
                        transition4.AddSource(lordToil);
                    }
                    FloatRange floatRange    = new FloatRange(0.25f, 0.35f);
                    float      randomInRange = floatRange.RandomInRange;
                    transition4.AddTrigger(new Trigger_FractionColonyDamageTaken(randomInRange, 900f));
                    transition4.AddPreAction(new TransitionAction_Message("MessageRaidersSatisfiedLeaving".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name), null, 1f));
                    stateGraph.AddTransition(transition4, false);
                }
                if (canKidnap)
                {
                    LordToil   startingToil = stateGraph.AttachSubgraph(new LordJob_Kidnap().CreateGraph()).StartingToil;
                    Transition transition5  = new Transition(lordToil2, startingToil, false, true);
                    if (lordToil != null)
                    {
                        transition5.AddSource(lordToil);
                    }
                    transition5.AddPreAction(new TransitionAction_Message("MessageRaidersKidnapping".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name), null, 1f));
                    transition5.AddTrigger(new Trigger_KidnapVictimPresent());
                    stateGraph.AddTransition(transition5, false);
                }
                if (canSteal)
                {
                    LordToil   startingToil2 = stateGraph.AttachSubgraph(new LordJob_Steal().CreateGraph()).StartingToil;
                    Transition transition6   = new Transition(lordToil2, startingToil2, false, true);
                    if (lordToil != null)
                    {
                        transition6.AddSource(lordToil);
                    }
                    transition6.AddPreAction(new TransitionAction_Message("MessageRaidersStealing".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name), null, 1f));
                    transition6.AddTrigger(new Trigger_HighValueThingsAround());
                    stateGraph.AddTransition(transition6, false);
                }
            }
            Transition transition7 = new Transition(lordToil2, lordToil_ExitMap, false, true);

            if (lordToil != null)
            {
                transition7.AddSource(lordToil);
            }
            transition7.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            transition7.AddPreAction(new TransitionAction_Message("MessageRaidersLeaving".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name), null, 1f));
            stateGraph.AddTransition(transition7, false);
            return(stateGraph);
        }
Exemple #22
0
        public override StateGraph CreateGraph()
        {
            StateGraph graphArrive = new StateGraph();
            var        travelGraph = new LordJob_Travel(chillSpot).CreateGraph();

            travelGraph.StartingToil = new LordToil_CustomTravel(chillSpot, 0.49f, 85); // CHANGED: override StartingToil
            LordToil toilArrive = graphArrive.AttachSubgraph(travelGraph).StartingToil;
            var      toilVisit  = new LordToil_VisitPoint();                            // 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_ExitMap toilExitCold = new LordToil_ExitMap(); // 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})));
            graphExit.transitions.Add(t2); // Moved to exit from arrive
            Transition t3 = new Transition(toilVisit, toilLeaveMap);

            t3.triggers.Add(new Trigger_BecamePlayerEnemy());
            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_BecamePlayerEnemy());
            //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_TicksPassedAndOkayToLeave(stayDuration));
            t5.triggers.Add(new Trigger_SentAway());
            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);
            Transition t7 = new Transition(toilArrive, toilExitCold);

            t7.triggers.Add(new Trigger_SentAway());
            t7.preActions.Add(new TransitionAction_Message("VisitorsLeaving".Translate(new object[] { faction.Name })));
            t7.preActions.Add(new TransitionAction_WakeAll());
            t7.preActions.Add(new TransitionAction_Custom(() => StopPawns(lord.ownedPawns)));
            t7.preActions.Add(new TransitionAction_Custom(() => LordToil_VisitPoint.DisplayLeaveMessage(Mathf.InverseLerp(-100, 100, faction.PlayerGoodwill), faction, lord.ownedPawns.Count, Map, true)));
            graphArrive.transitions.Add(t7);

            return(graphArrive);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil   lordToil   = null;

            if (this.sappers)
            {
                lordToil = new LordToil_AssaultColonySappers();
                if (this.useAvoidGridSmart)
                {
                    lordToil.avoidGridMode = AvoidGridMode.Smart;
                }
                stateGraph.AddToil(lordToil);
                Transition transition = new Transition(lordToil, lordToil, true, true);
                transition.AddTrigger(new Trigger_PawnLost());
                stateGraph.AddTransition(transition);
                Transition transition2 = new Transition(lordToil, lordToil, true, false);
                transition2.AddTrigger(new Trigger_PawnHarmed(1f, false, null));
                transition2.AddPostAction(new TransitionAction_CheckForJobOverride());
                stateGraph.AddTransition(transition2);
            }
            LordToil lordToil2 = new LordToil_AssaultColony(false);

            if (this.useAvoidGridSmart)
            {
                lordToil2.avoidGridMode = AvoidGridMode.Smart;
            }
            stateGraph.AddToil(lordToil2);
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Jog, false);

            lordToil_ExitMap.avoidGridMode = AvoidGridMode.Smart;
            stateGraph.AddToil(lordToil_ExitMap);
            if (this.sappers)
            {
                Transition transition3 = new Transition(lordToil, lordToil2, false, true);
                transition3.AddTrigger(new Trigger_NoFightingSappers());
                stateGraph.AddTransition(transition3);
            }
            if (this.assaulterFaction.def.humanlikeFaction)
            {
                if (this.canTimeoutOrFlee)
                {
                    Transition transition4 = new Transition(lordToil2, lordToil_ExitMap, false, true);
                    if (lordToil != null)
                    {
                        transition4.AddSource(lordToil);
                    }
                    transition4.AddTrigger(new Trigger_TicksPassed((!this.sappers) ? LordJob_AssaultColony.AssaultTimeBeforeGiveUp.RandomInRange : LordJob_AssaultColony.SapTimeBeforeGiveUp.RandomInRange));
                    transition4.AddPreAction(new TransitionAction_Message("MessageRaidersGivenUpLeaving".Translate(new object[]
                    {
                        this.assaulterFaction.def.pawnsPlural.CapitalizeFirst(),
                        this.assaulterFaction.Name
                    }), null, 1f));
                    stateGraph.AddTransition(transition4);
                    Transition transition5 = new Transition(lordToil2, lordToil_ExitMap, false, true);
                    if (lordToil != null)
                    {
                        transition5.AddSource(lordToil);
                    }
                    FloatRange floatRange    = new FloatRange(0.25f, 0.35f);
                    float      randomInRange = floatRange.RandomInRange;
                    transition5.AddTrigger(new Trigger_FractionColonyDamageTaken(randomInRange, 900f));
                    transition5.AddPreAction(new TransitionAction_Message("MessageRaidersSatisfiedLeaving".Translate(new object[]
                    {
                        this.assaulterFaction.def.pawnsPlural.CapitalizeFirst(),
                        this.assaulterFaction.Name
                    }), null, 1f));
                    stateGraph.AddTransition(transition5);
                }
                if (this.canKidnap)
                {
                    LordToil   startingToil = stateGraph.AttachSubgraph(new LordJob_Kidnap().CreateGraph()).StartingToil;
                    Transition transition6  = new Transition(lordToil2, startingToil, false, true);
                    if (lordToil != null)
                    {
                        transition6.AddSource(lordToil);
                    }
                    transition6.AddPreAction(new TransitionAction_Message("MessageRaidersKidnapping".Translate(new object[]
                    {
                        this.assaulterFaction.def.pawnsPlural.CapitalizeFirst(),
                        this.assaulterFaction.Name
                    }), null, 1f));
                    transition6.AddTrigger(new Trigger_KidnapVictimPresent());
                    stateGraph.AddTransition(transition6);
                }
                if (this.canSteal)
                {
                    LordToil   startingToil2 = stateGraph.AttachSubgraph(new LordJob_Steal().CreateGraph()).StartingToil;
                    Transition transition7   = new Transition(lordToil2, startingToil2, false, true);
                    if (lordToil != null)
                    {
                        transition7.AddSource(lordToil);
                    }
                    transition7.AddPreAction(new TransitionAction_Message("MessageRaidersStealing".Translate(new object[]
                    {
                        this.assaulterFaction.def.pawnsPlural.CapitalizeFirst(),
                        this.assaulterFaction.Name
                    }), null, 1f));
                    transition7.AddTrigger(new Trigger_HighValueThingsAround());
                    stateGraph.AddTransition(transition7);
                }
            }
            Transition transition8 = new Transition(lordToil2, lordToil_ExitMap, false, true);

            if (lordToil != null)
            {
                transition8.AddSource(lordToil);
            }
            transition8.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            transition8.AddPreAction(new TransitionAction_Message("MessageRaidersLeaving".Translate(new object[]
            {
                this.assaulterFaction.def.pawnsPlural.CapitalizeFirst(),
                this.assaulterFaction.Name
            }), null, 1f));
            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);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil   lordToil   = null;

            if (sappers)
            {
                lordToil = new LordToil_BurnStealColonySappers();
                if (useAvoidGridSmart)
                {
                    lordToil.useAvoidGrid = true;
                }
                stateGraph.AddToil(lordToil);
                Transition transition = new Transition(lordToil, lordToil, canMoveToSameState: true);
                transition.AddTrigger(new Trigger_PawnLost());
                stateGraph.AddTransition(transition);
            }
            LordToil lordToil2 = new LordToil_BurnStealColony();

            if (useAvoidGridSmart)
            {
                lordToil2.useAvoidGrid = true;
            }
            stateGraph.AddToil(lordToil2);
            LordToil_ExitMap lordToil_ExitMap = new LordToil_ExitMap(LocomotionUrgency.Jog, canDig: false, interruptCurrentJob: true);

            lordToil_ExitMap.useAvoidGrid = true;
            stateGraph.AddToil(lordToil_ExitMap);
            if (sappers)
            {
                Transition transition2 = new Transition(lordToil, lordToil2);
                transition2.AddTrigger(new Trigger_NoFightingSappers());
                stateGraph.AddTransition(transition2);
            }
            if (assaulterFaction.def.humanlikeFaction)
            {
                if (canTimeoutOrFlee)
                {
                    Transition transition3 = new Transition(lordToil2, lordToil_ExitMap);
                    if (lordToil != null)
                    {
                        transition3.AddSource(lordToil);
                    }
                    transition3.AddTrigger(new Trigger_TicksPassed(sappers ? SapTimeBeforeGiveUp.RandomInRange : AssaultTimeBeforeGiveUp.RandomInRange));
                    transition3.AddPreAction(new TransitionAction_Message("MessageRaidersGivenUpLeaving".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name)));
                    stateGraph.AddTransition(transition3);
                    Transition transition4 = new Transition(lordToil2, lordToil_ExitMap);
                    if (lordToil != null)
                    {
                        transition4.AddSource(lordToil);
                    }
                    float randomInRange = new FloatRange(0.25f, 0.35f).RandomInRange;
                    transition4.AddTrigger(new Trigger_FractionColonyDamageTaken(randomInRange, 900f));
                    transition4.AddPreAction(new TransitionAction_Message("MessageRaidersSatisfiedLeaving".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name)));
                    stateGraph.AddTransition(transition4);
                }
                if (canKidnap)
                {
                    LordToil   startingToil = stateGraph.AttachSubgraph(new LordJob_Kidnap().CreateGraph()).StartingToil;
                    Transition transition5  = new Transition(lordToil2, startingToil);
                    if (lordToil != null)
                    {
                        transition5.AddSource(lordToil);
                    }
                    transition5.AddPreAction(new TransitionAction_Message("MessageRaidersKidnapping".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name)));
                    transition5.AddTrigger(new Trigger_KidnapVictimPresent());
                    stateGraph.AddTransition(transition5);
                }
                if (canSteal)
                {
                    LordToil   startingToil2 = stateGraph.AttachSubgraph(new LordJob_Steal().CreateGraph()).StartingToil;
                    Transition transition6   = new Transition(lordToil2, startingToil2);
                    if (lordToil != null)
                    {
                        transition6.AddSource(lordToil);
                    }
                    transition6.AddPreAction(new TransitionAction_Message("MessageRaidersStealing".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name)));
                    transition6.AddTrigger(new Trigger_HighValueThingsAround());
                    stateGraph.AddTransition(transition6);
                }
            }
            Transition transition7 = new Transition(lordToil2, lordToil_ExitMap);

            if (lordToil != null)
            {
                transition7.AddSource(lordToil);
            }
            transition7.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            transition7.AddPreAction(new TransitionAction_Message("MessageRaidersLeaving".Translate(assaulterFaction.def.pawnsPlural.CapitalizeFirst(), assaulterFaction.Name)));
            stateGraph.AddTransition(transition7);
            return(stateGraph);
        }
Exemple #26
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);
        }
        public override StateGraph CreateGraph()
        {
            List <Pawn> lordPawns          = this.lord.ownedPawns;
            StateGraph  stateGraph         = new StateGraph();
            IntVec3     retrieversPosition = default(IntVec3);

            stateGraph.StartingToil = stateGraph.AttachSubgraph(new LordJob_Travel(this.targetCaravan.Position).CreateGraph()).StartingToil;
            LordToil_DefendPoint defendPointLordToil = new LordToil_DefendPoint();

            stateGraph.AddToil(defendPointLordToil);
            LordToil_ExitMap exitMapLordToil = new LordToil_ExitMap();

            stateGraph.AddToil(exitMapLordToil);
            LordToil_ExitMap exitMapOnConditionLordToil = new LordToil_ExitMap();

            stateGraph.AddToil(exitMapOnConditionLordToil);
            stateGraph.AddTransition(new Transition(stateGraph.StartingToil, defendPointLordToil)
            {
                triggers =
                {
                    new Trigger_Memo("TravelArrived")
                },
                postActions =
                {
                    new TransitionAction_Custom(new Action(delegate
                    {
                        if (this.targetCaravan == null || this.targetCaravan.Faction == Faction.OfPlayer)
                        {
                            this.TargetCaravnLost();
                            this.lord.ReceiveMemo("TargetCaravanGone");
                            return;
                        }
                        this.targetCaravan.pather.StartPath(retrieversPosition = lordPawns.First().Position, PathEndMode.ClosestTouch);
                        this.lord.AddPawn(this.targetCaravan);
                    }))
                }
            });
            Transition exitMapTransition = new Transition(defendPointLordToil, exitMapLordToil)
            {
                triggers =
                {
                    new Trigger_Memo("TargetCaravanGone"),
                    new Trigger_Custom(t => t.type == TriggerSignalType.Tick && lordPawns.Contains(this.targetCaravan))
                }
            };

            exitMapTransition.AddSource(stateGraph.StartingToil);
            stateGraph.AddTransition(exitMapTransition);
            stateGraph.AddTransition(new Transition(exitMapLordToil, exitMapOnConditionLordToil)
            {
                triggers =
                {
                    new Trigger_PawnLost()
                },
                preActions =
                {
                    new TransitionAction_Custom(new Action(delegate
                    {
                        if (!lordPawns.Contains(this.targetCaravan))
                        {
                            this.TargetCaravnLost();
                        }
                    }))
                }
            });
            return(stateGraph);
        }