Beispiel #1
0
        public override StateGraph CreateGraph()
        {
            StateGraph            stateGraph      = new StateGraph();
            LordToil_AttendSermon lordToil_Sermon = new LordToil_AttendSermon(this.spot);

            stateGraph.AddToil(lordToil_Sermon);
            LordToil_End lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);
            Transition transition = new Transition(lordToil_Sermon, lordToil_End);

            transition.AddTrigger(new Trigger_TickCondition(() => this.ShouldBeCalledOff()));
            transition.AddTrigger(new Trigger_PawnLostViolently());
            transition.AddAction(new TransitionAction_Message("MessagePartyCalledOff".Translate(), MessageSound.Negative, this.spot));
            stateGraph.AddTransition(transition);
            this.timeoutTrigger = new Trigger_TicksPassed(Rand.RangeInclusive(5000, 15000));
            Transition transition2 = new Transition(lordToil_Sermon, lordToil_End);

            transition2.AddTrigger(this.timeoutTrigger);
            transition2.AddAction(new TransitionAction_Message("MessagePartyFinished".Translate(), MessageSound.Negative, this.spot));

            transition2.AddAction(new TransitionAction_Cus(delegate
            {
                this.Finished();
            }));
            stateGraph.AddTransition(transition2);
            return(stateGraph);
        }
Beispiel #2
0
        public override StateGraph CreateGraph()
        {
            StateGraph             stateGraph      = new StateGraph();
            LordToil_DefendOutpost lordToil_Defend = new LordToil_DefendOutpost(this.rallyPoint);

            stateGraph.AddToil(lordToil_Defend);
            LordToil_End lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);

            this.timeoutTrigger = new Trigger_TicksPassed(8000);
            Transition transition = new Transition(lordToil_Defend, lordToil_End);

            transition.AddTrigger(this.timeoutTrigger);
            //transition.AddPreAction(new TransitionAction_Message("Defend lord timeout.", MessageSound.Standard, this.rallyPoint));
            stateGraph.AddTransition(transition);

            Trigger_Memo memoTrigger = new Trigger_Memo("ThreatIsFinished");
            Transition   transition2 = new Transition(lordToil_Defend, lordToil_End);

            transition2.AddTrigger(memoTrigger);
            //transition2.AddPreAction(new TransitionAction_Message("Defend lord threat is finished.", MessageSound.Standard, this.rallyPoint));
            stateGraph.AddTransition(transition2);

            return(stateGraph);
        }
Beispiel #3
0
        public override StateGraph CreateGraph()
        {
            StateGraph             stateGraph     = new StateGraph();
            LordToil_SetLeadership lordToil_Party = new LordToil_SetLeadership(this.spot);

            stateGraph.AddToil(lordToil_Party);
            LordToil_End lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);
            Transition transition = new Transition(lordToil_Party, lordToil_End);

            transition.AddTrigger(new Trigger_TickCondition(() => this.ShouldBeCalledOff()));
            transition.AddTrigger(new Trigger_PawnLostViolently());
            transition.AddPreAction(new TransitionAction_Message("ElectionFail_Disaster".Translate(), MessageTypeDefOf.NegativeEvent, new TargetInfo(this.spot, base.Map, false)));
            stateGraph.AddTransition(transition);
            this.timeoutTrigger = new Trigger_TicksPassed(Rand.RangeInclusive(5000, 8000));
            Transition transition2 = new Transition(lordToil_Party, lordToil_End);

            transition2.AddTrigger(this.timeoutTrigger);

            transition2.AddPreAction(new TransitionAction_Message("ElectionFinished".Translate(), MessageTypeDefOf.PositiveEvent, new TargetInfo(this.spot, base.Map, false)));
            transition2.AddPreAction(new TransitionAction_Custom(new Action(delegate
            {
                this.Finished();
            })));
            stateGraph.AddTransition(transition2);
            return(stateGraph);
        }
        // Token: 0x06000005 RID: 5 RVA: 0x000020A0 File Offset: 0x000002A0
        public override StateGraph CreateGraph()
        {
            var stateGraph      = new StateGraph();
            var lordToil_CParty = new LordToil_CParty(spot);

            stateGraph.AddToil(lordToil_CParty);
            var lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);
            var transition = new Transition(lordToil_CParty, lordToil_End);

            transition.AddTrigger(new Trigger_TickCondition(ShouldBeCalledOff));
            transition.AddTrigger(new Trigger_PawnKilled());
            transition.AddPreAction(new TransitionAction_Message("MessagePartyCalledOff".Translate(),
                                                                 MessageTypeDefOf.NegativeEvent, new TargetInfo(spot, Map)));
            stateGraph.AddTransition(transition);
            timeoutTrigger = new Trigger_TicksPassed(Rand.RangeInclusive(5000, 15000));
            var transition2 = new Transition(lordToil_CParty, lordToil_End);

            transition2.AddTrigger(timeoutTrigger);
            transition2.AddPreAction(new TransitionAction_Message("MessagePartyFinished".Translate(),
                                                                  MessageTypeDefOf.SituationResolved, new TargetInfo(spot, Map)));
            stateGraph.AddTransition(transition2);
            return(stateGraph);
        }
Beispiel #5
0
        public override StateGraph CreateGraph()
        {
            StateGraph     stateGraph = new StateGraph();
            LordToil_Arson fireToil   = new LordToil_Arson(FireSpot);

            stateGraph.StartingToil = fireToil;
            LordToil_End lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);

            LordToil   startingToil2 = stateGraph.AttachSubgraph(new LordJob_AssaultColony(Faction).CreateGraph()).StartingToil;
            Transition transition2   = new Transition(fireToil, startingToil2);

            transition2.AddTrigger(new Trigger_FractionPawnsLost(0.1f));
            stateGraph.AddTransition(transition2);

            timeoutTrigger = new Trigger_TicksPassed(Rand.RangeInclusive(25000, 50000));
            Transition transition3 = new Transition(fireToil, lordToil_End);

            transition3.AddTrigger(timeoutTrigger);
            transition3.AddPreAction(new TransitionAction_Message("ArsonOut".Translate(), MessageTypeDefOf.SituationResolved));
            stateGraph.AddTransition(transition3);

            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph     stateGraph     = new StateGraph();
            LordToil_Party lordToil_Party = new LordToil_Party(this.spot, 2200);

            stateGraph.AddToil(lordToil_Party);
            LordToil_MarriageCeremony lordToil_MarriageCeremony = new LordToil_MarriageCeremony(this.firstPawn, this.secondPawn, this.spot);

            stateGraph.AddToil(lordToil_MarriageCeremony);
            LordToil_Party lordToil_Party2 = new LordToil_Party(this.spot, 2200);

            stateGraph.AddToil(lordToil_Party2);
            LordToil_End lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);
            Transition transition = new Transition(lordToil_Party, lordToil_MarriageCeremony, false, true);

            transition.AddTrigger(new Trigger_TickCondition(() => this.lord.ticksInToil >= 5000 && this.AreFiancesInPartyArea(), 1));
            transition.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyStarts".Translate(this.firstPawn.LabelShort, this.secondPawn.LabelShort, this.firstPawn.Named("PAWN1"), this.secondPawn.Named("PAWN2")), MessageTypeDefOf.PositiveEvent, this.firstPawn, null, 1f));
            stateGraph.AddTransition(transition, false);
            Transition transition2 = new Transition(lordToil_MarriageCeremony, lordToil_Party2, false, true);

            transition2.AddTrigger(new Trigger_TickCondition(() => this.firstPawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, this.secondPawn), 1));
            transition2.AddPreAction(new TransitionAction_Message("MessageNewlyMarried".Translate(this.firstPawn.LabelShort, this.secondPawn.LabelShort, this.firstPawn.Named("PAWN1"), this.secondPawn.Named("PAWN2")), MessageTypeDefOf.PositiveEvent, new TargetInfo(this.spot, base.Map, false), null, 1f));
            transition2.AddPreAction(new TransitionAction_Custom(delegate
            {
                this.AddAttendedWeddingThoughts();
            }));
            stateGraph.AddTransition(transition2, false);
            Transition transition3 = new Transition(lordToil_Party2, lordToil_End, false, true);

            transition3.AddTrigger(new Trigger_TickCondition(() => this.ShouldAfterPartyBeCalledOff(), 1));
            transition3.AddTrigger(new Trigger_PawnKilled());
            transition3.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyCalledOff".Translate(this.firstPawn.LabelShort, this.secondPawn.LabelShort, this.firstPawn.Named("PAWN1"), this.secondPawn.Named("PAWN2")), MessageTypeDefOf.NegativeEvent, new TargetInfo(this.spot, base.Map, false), null, 1f));
            stateGraph.AddTransition(transition3, false);
            this.afterPartyTimeoutTrigger = new Trigger_TicksPassed(7500);
            Transition transition4 = new Transition(lordToil_Party2, lordToil_End, false, true);

            transition4.AddTrigger(this.afterPartyTimeoutTrigger);
            transition4.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyAfterPartyFinished".Translate(this.firstPawn.LabelShort, this.secondPawn.LabelShort, this.firstPawn.Named("PAWN1"), this.secondPawn.Named("PAWN2")), MessageTypeDefOf.PositiveEvent, this.firstPawn, null, 1f));
            stateGraph.AddTransition(transition4, false);
            Transition transition5 = new Transition(lordToil_MarriageCeremony, lordToil_End, false, true);

            transition5.AddSource(lordToil_Party);
            transition5.AddTrigger(new Trigger_TickCondition(() => this.lord.ticksInToil >= 120000 && (this.firstPawn.Drafted || this.secondPawn.Drafted || !this.firstPawn.Position.InHorDistOf(this.spot, 4f) || !this.secondPawn.Position.InHorDistOf(this.spot, 4f)), 1));
            transition5.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyCalledOff".Translate(this.firstPawn.LabelShort, this.secondPawn.LabelShort, this.firstPawn.Named("PAWN1"), this.secondPawn.Named("PAWN2")), MessageTypeDefOf.NegativeEvent, new TargetInfo(this.spot, base.Map, false), null, 1f));
            stateGraph.AddTransition(transition5, false);
            Transition transition6 = new Transition(lordToil_MarriageCeremony, lordToil_End, false, true);

            transition6.AddSource(lordToil_Party);
            transition6.AddTrigger(new Trigger_TickCondition(() => this.ShouldCeremonyBeCalledOff(), 1));
            transition6.AddTrigger(new Trigger_PawnKilled());
            transition6.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyCalledOff".Translate(this.firstPawn.LabelShort, this.secondPawn.LabelShort, this.firstPawn.Named("PAWN1"), this.secondPawn.Named("PAWN2")), MessageTypeDefOf.NegativeEvent, new TargetInfo(this.spot, base.Map, false), null, 1f));
            stateGraph.AddTransition(transition6, false);
            return(stateGraph);
        }
Beispiel #7
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();

            #region LordToils
            LordToil_JoinPrayerService lordToil_JoinPrayerService = new LordToil_JoinPrayerService(organizer, spot);
            stateGraph.AddToil(lordToil_JoinPrayerService);

            LordToil_PrayerService lordToil_PrayerService = new LordToil_PrayerService(pulpit, organizer, spot, spectatorRect);
            stateGraph.AddToil(lordToil_PrayerService);

            LordToil_End lordToil_End = new LordToil_End();
            stateGraph.AddToil(lordToil_End);
            #endregion

            #region Transition JoinPrayerService => Others
            {
                // 주최자가 방에 들어온 다음 일정틱 대기 후 다음 단계로 진행하도록
                Transition transition_JoinPrayerService_to_PrayerService = new Transition(lordToil_JoinPrayerService, lordToil_PrayerService);
                transition_JoinPrayerService_to_PrayerService.AddTrigger(new Trigger_TicksPassedAfterConditionMet(ConstPriest.PrayerServicePreStageTicks, () =>
                {
                    if (organizer.GetRoom() == spot.GetRoom(organizer.Map))
                    {
                        return(true);
                    }

                    return(false);
                }, checkEveryTicks: 250));
                stateGraph.AddTransition(transition_JoinPrayerService_to_PrayerService);
            }

            {
                // 주최자가 피해를 입었거나, 취소될만한 상황이 될 경우 강제로 종료
                Transition transition_JoinPrayerService_to_End = new Transition(lordToil_JoinPrayerService, lordToil_End);
                transition_JoinPrayerService_to_End.AddTrigger(new Trigger_TickCondition(IsAborted));
                transition_JoinPrayerService_to_End.AddTrigger(new Trigger_PawnHarmed());
                transition_JoinPrayerService_to_End.AddPreAction(new TransitionAction_Message("MessagePrayerServiceAborted".Translate(), MessageTypeDefOf.NeutralEvent));
                stateGraph.AddTransition(transition_JoinPrayerService_to_End);
            }
            #endregion

            #region Transition_PrayerService => Others
            {
                // 일정틱 진행되었거나, 취소될만한 상황이 될 경우 강제로 종료
                triggerProgress = new Trigger_TicksPassed(Rand.Range(ConstPriest.PrayerServiceOnStageTicksMin, ConstPriest.PrayerServiceOnStageTicksMax));
                Transition transition_PrayerService_to_End = new Transition(lordToil_PrayerService, lordToil_End);
                transition_PrayerService_to_End.AddTrigger(triggerProgress);
                transition_PrayerService_to_End.AddTrigger(new Trigger_PawnHarmed());
                transition_PrayerService_to_End.AddTrigger(new Trigger_TickCondition(IsAborted));
                transition_PrayerService_to_End.AddPreAction(new TransitionAction_Message("MessagePrayerServiceEnded".Translate()));
                stateGraph.AddTransition(transition_PrayerService_to_End);
            }
            #endregion

            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph     stateGraph     = new StateGraph();
            LordToil_Party lordToil_Party = new LordToil_Party(spot, GatheringDefOf.Party);

            stateGraph.AddToil(lordToil_Party);
            LordToil_MarriageCeremony lordToil_MarriageCeremony = new LordToil_MarriageCeremony(firstPawn, secondPawn, spot);

            stateGraph.AddToil(lordToil_MarriageCeremony);
            LordToil_Party lordToil_Party2 = new LordToil_Party(spot, GatheringDefOf.Party);

            stateGraph.AddToil(lordToil_Party2);
            LordToil_End lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);
            Transition transition = new Transition(lordToil_Party, lordToil_MarriageCeremony);

            transition.AddTrigger(new Trigger_TickCondition(() => lord.ticksInToil >= 5000 && AreFiancesInPartyArea()));
            transition.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyStarts".Translate(firstPawn.LabelShort, secondPawn.LabelShort, firstPawn.Named("PAWN1"), secondPawn.Named("PAWN2")), MessageTypeDefOf.PositiveEvent, firstPawn));
            stateGraph.AddTransition(transition);
            Transition transition2 = new Transition(lordToil_MarriageCeremony, lordToil_Party2);

            transition2.AddTrigger(new Trigger_TickCondition(() => firstPawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, secondPawn)));
            transition2.AddPreAction(new TransitionAction_Message("MessageNewlyMarried".Translate(firstPawn.LabelShort, secondPawn.LabelShort, firstPawn.Named("PAWN1"), secondPawn.Named("PAWN2")), MessageTypeDefOf.PositiveEvent, new TargetInfo(spot, base.Map)));
            transition2.AddPreAction(new TransitionAction_Custom((Action) delegate
            {
                AddAttendedWeddingThoughts();
            }));
            stateGraph.AddTransition(transition2);
            Transition transition3 = new Transition(lordToil_Party2, lordToil_End);

            transition3.AddTrigger(new Trigger_TickCondition(() => ShouldAfterPartyBeCalledOff()));
            transition3.AddTrigger(new Trigger_PawnKilled());
            stateGraph.AddTransition(transition3);
            afterPartyTimeoutTrigger = new Trigger_TicksPassed(7500);
            Transition transition4 = new Transition(lordToil_Party2, lordToil_End);

            transition4.AddTrigger(afterPartyTimeoutTrigger);
            transition4.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyAfterPartyFinished".Translate(firstPawn.LabelShort, secondPawn.LabelShort, firstPawn.Named("PAWN1"), secondPawn.Named("PAWN2")), MessageTypeDefOf.PositiveEvent, firstPawn));
            stateGraph.AddTransition(transition4);
            Transition transition5 = new Transition(lordToil_MarriageCeremony, lordToil_End);

            transition5.AddSource(lordToil_Party);
            transition5.AddTrigger(new Trigger_TickCondition(() => lord.ticksInToil >= 120000 && (firstPawn.Drafted || secondPawn.Drafted || !firstPawn.Position.InHorDistOf(spot, 4f) || !secondPawn.Position.InHorDistOf(spot, 4f))));
            transition5.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyCalledOff".Translate(firstPawn.LabelShort, secondPawn.LabelShort, firstPawn.Named("PAWN1"), secondPawn.Named("PAWN2")), MessageTypeDefOf.NegativeEvent, new TargetInfo(spot, base.Map)));
            stateGraph.AddTransition(transition5);
            Transition transition6 = new Transition(lordToil_MarriageCeremony, lordToil_End);

            transition6.AddSource(lordToil_Party);
            transition6.AddTrigger(new Trigger_TickCondition(() => ShouldCeremonyBeCalledOff()));
            transition6.AddTrigger(new Trigger_PawnKilled());
            transition6.AddPreAction(new TransitionAction_Message("MessageMarriageCeremonyCalledOff".Translate(firstPawn.LabelShort, secondPawn.LabelShort, firstPawn.Named("PAWN1"), secondPawn.Named("PAWN2")), MessageTypeDefOf.NegativeEvent, new TargetInfo(spot, base.Map)));
            stateGraph.AddTransition(transition6);
            return(stateGraph);
        }
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil_DefendOutpost lordToil_Defend = new LordToil_DefendOutpost(this.rallyPoint);
            stateGraph.AddToil(lordToil_Defend);
            LordToil_End lordToil_End = new LordToil_End();
            stateGraph.AddToil(lordToil_End);

            this.timeoutTrigger = new Trigger_TicksPassed(8000);
            Transition transition = new Transition(lordToil_Defend, lordToil_End);
            transition.AddTrigger(this.timeoutTrigger);
            //transition.AddPreAction(new TransitionAction_Message("Defend lord timeout.", MessageSound.Standard, this.rallyPoint));
            stateGraph.AddTransition(transition);

            Trigger_Memo memoTrigger = new Trigger_Memo("ThreatIsFinished");
            Transition transition2 = new Transition(lordToil_Defend, lordToil_End);
            transition2.AddTrigger(memoTrigger);
            //transition2.AddPreAction(new TransitionAction_Message("Defend lord threat is finished.", MessageSound.Standard, this.rallyPoint));
            stateGraph.AddTransition(transition2);

            return stateGraph;
        }
        public override StateGraph CreateGraph()
        {
            StateGraph     stateGraph     = new StateGraph();
            LordToil_Party lordToil_Party = new LordToil_Party(this.spot, 600);

            stateGraph.AddToil(lordToil_Party);
            LordToil_End lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);
            Transition transition = new Transition(lordToil_Party, lordToil_End, false, true);

            transition.AddTrigger(new Trigger_TickCondition(() => this.ShouldBeCalledOff(), 1));
            transition.AddTrigger(new Trigger_PawnKilled());
            transition.AddPreAction(new TransitionAction_Message("MessagePartyCalledOff".Translate(), MessageTypeDefOf.NegativeEvent, new TargetInfo(this.spot, base.Map, false), null, 1f));
            stateGraph.AddTransition(transition);
            this.timeoutTrigger = new Trigger_TicksPassed(Rand.RangeInclusive(5000, 15000));
            Transition transition2 = new Transition(lordToil_Party, lordToil_End, false, true);

            transition2.AddTrigger(this.timeoutTrigger);
            transition2.AddPreAction(new TransitionAction_Message("MessagePartyFinished".Translate(), MessageTypeDefOf.SituationResolved, new TargetInfo(this.spot, base.Map, false), null, 1f));
            stateGraph.AddTransition(transition2);
            return(stateGraph);
        }
Beispiel #11
0
        public override StateGraph CreateGraph()
        {
            StateGraph     stateGraph    = new StateGraph();
            LordToil_Party lordToilParty = new LordToil_Party(_spot);

            stateGraph.AddToil(lordToilParty);
            LordToil_End lordToilEnd = new LordToil_End();

            stateGraph.AddToil(lordToilEnd);
            Transition transition = new Transition(lordToilParty, lordToilEnd);

            transition.AddTrigger(new Trigger_TickCondition(ShouldBeCalledOff));
            transition.AddTrigger(new Trigger_PawnLostViolently());
            transition.AddPreAction(new TransitionAction_Message("MessagePartyCalledOff".Translate(), MessageTypeDefOf.NegativeEvent, new TargetInfo(_spot, Map)));
            stateGraph.AddTransition(transition);
            _timeoutTrigger = new Trigger_TicksPassed(GetRandomPartyLength());
            Transition transition2 = new Transition(lordToilParty, lordToilEnd);

            transition2.AddTrigger(_timeoutTrigger);
            transition2.AddPreAction(new TransitionAction_Message("MessagePartyFinished".Translate(), MessageTypeDefOf.NegativeEvent, new TargetInfo(_spot, Map)));
            stateGraph.AddTransition(transition2);
            return(stateGraph);
        }
Beispiel #12
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);
        }
Beispiel #13
0
 public static void TriggerDataTicksPassedNull(Trigger_TicksPassed trigger)
 {
     trigger.data = new TriggerData_TicksPassed();
 }