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);
        }
示例#2
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil   lordToil   = null;

            if (sappers)
            {
                lordToil = new LordToil_AssaultColonySappers();
                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_AssaultColony();

            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);
        }