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