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