Ejemplo n.º 1
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();

            stateGraph.AddToil(new LordToil_DefendPoint(this.point, 28f));
            return(stateGraph);
        }
Ejemplo n.º 2
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();

            stateGraph.AddToil(new LordToil_ExitMap(this.locomotion, this.canDig)
            {
                useAvoidGrid = true
            });
            return(stateGraph);
        }
Ejemplo n.º 3
0
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();

            stateGraph.AddToil(new LordToil_ExitMap(this.locomotion, this.canDig)
            {
                avoidGridMode = AvoidGridMode.Smart
            });
            return(stateGraph);
        }
Ejemplo n.º 4
0
        public override StateGraph CreateGraph()
        {
            StateGraph           stateGraph           = new StateGraph();
            LordToil_ExitMapNear lordToil_ExitMapNear = new LordToil_ExitMapNear(this.near, this.radius, this.locomotion, this.canDig);

            if (this.useAvoidGridSmart)
            {
                lordToil_ExitMapNear.useAvoidGrid = true;
            }
            stateGraph.AddToil(lordToil_ExitMapNear);
            return(stateGraph);
        }
Ejemplo n.º 5
0
 public StateGraph AttachSubgraph(StateGraph subGraph)
 {
     for (int i = 0; i < subGraph.lordToils.Count; i++)
     {
         this.lordToils.Add(subGraph.lordToils[i]);
     }
     for (int j = 0; j < subGraph.transitions.Count; j++)
     {
         this.transitions.Add(subGraph.transitions[j]);
     }
     return(subGraph);
 }
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph   = new StateGraph();
            LordToil   startingToil = stateGraph.AttachSubgraph(new LordJob_Travel(this.travelDest).CreateGraph()).StartingToil;

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

            stateGraph.AddToil(lordToil_ExitMap);
            stateGraph.AddTransition(new Transition(startingToil, lordToil_ExitMap, false, true)
            {
                triggers =
                {
                    new Trigger_Memo("TravelArrived")
                }
            }, false);
            return(stateGraph);
        }
Ejemplo n.º 7
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]);
     }
 }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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]);
     }
 }