Пример #1
0
 public void SetJob(LordJob lordJob)
 {
     if (this.curJob != null)
     {
         this.curJob.Cleanup();
     }
     this.curJob      = lordJob;
     this.curLordToil = null;
     lordJob.lord     = this;
     Rand.PushState();
     Rand.Seed  = this.loadID * 193;
     this.graph = lordJob.CreateGraph();
     Rand.PopState();
     this.graph.ErrorCheck();
     if (this.faction != null && !this.faction.IsPlayer && this.faction.def.autoFlee && lordJob.AddFleeToil)
     {
         LordToil_PanicFlee lordToil_PanicFlee = new LordToil_PanicFlee();
         lordToil_PanicFlee.avoidGridMode = AvoidGridMode.Smart;
         for (int i = 0; i < this.graph.lordToils.Count; i++)
         {
             Transition transition = new Transition(this.graph.lordToils[i], lordToil_PanicFlee, false, true);
             transition.AddPreAction(new TransitionAction_Message("MessageFightersFleeing".Translate(new object[]
             {
                 this.faction.def.pawnsPlural.CapitalizeFirst(),
                 this.faction.Name
             }), null, 1f));
             transition.AddTrigger(new Trigger_FractionPawnsLost(0.5f));
             this.graph.AddTransition(transition, true);
         }
         this.graph.AddToil(lordToil_PanicFlee);
     }
     for (int j = 0; j < this.graph.lordToils.Count; j++)
     {
         this.graph.lordToils[j].lord = this;
     }
     for (int k = 0; k < this.ownedPawns.Count; k++)
     {
         this.Map.attackTargetsCache.UpdateTarget(this.ownedPawns[k]);
     }
 }
Пример #2
0
        public override StateGraph CreateGraph()
        {
            StateGraph      stateGraph      = new StateGraph();
            LordToil_Travel lordToil_Travel = new LordToil_Travel(this.travelDest);

            stateGraph.StartingToil = lordToil_Travel;
            LordToil_DefendPoint lordToil_DefendPoint = new LordToil_DefendPoint(false);

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

            transition.AddTrigger(new Trigger_PawnHarmed(1f, false, null));
            transition.AddPreAction(new TransitionAction_SetDefendLocalGroup());
            transition.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition, false);
            Transition transition2 = new Transition(lordToil_DefendPoint, lordToil_Travel, false, true);

            transition2.AddTrigger(new Trigger_TicksPassedWithoutHarm(1200));
            transition2.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            stateGraph.AddTransition(transition2, false);
            return(stateGraph);
        }
Пример #3
0
 public void SetJob(LordJob lordJob)
 {
     if (curJob != null)
     {
         curJob.Cleanup();
     }
     curJob       = lordJob;
     curLordToil  = null;
     lordJob.lord = this;
     Rand.PushState();
     Rand.Seed = loadID * 193;
     graph     = lordJob.CreateGraph();
     Rand.PopState();
     graph.ErrorCheck();
     if (faction != null && !faction.IsPlayer && faction.def.autoFlee && lordJob.AddFleeToil)
     {
         LordToil_PanicFlee lordToil_PanicFlee = new LordToil_PanicFlee();
         lordToil_PanicFlee.useAvoidGrid = true;
         for (int i = 0; i < graph.lordToils.Count; i++)
         {
             Transition transition = new Transition(graph.lordToils[i], lordToil_PanicFlee);
             transition.AddPreAction(new TransitionAction_Message("MessageFightersFleeing".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name)));
             transition.AddTrigger(new Trigger_FractionPawnsLost(faction.def.attackersDownPercentageRangeForAutoFlee.RandomInRangeSeeded(loadID)));
             graph.AddTransition(transition, highPriority: true);
         }
         graph.AddToil(lordToil_PanicFlee);
     }
     for (int j = 0; j < graph.lordToils.Count; j++)
     {
         graph.lordToils[j].lord = this;
     }
     for (int k = 0; k < ownedPawns.Count; k++)
     {
         Map.attackTargetsCache.UpdateTarget(ownedPawns[k]);
     }
 }