public override void UpdateAllDuties() { if (!Data.sapperDest.IsValid && lord.ownedPawns.Any()) { Data.sapperDest = GenAI.RandomRaidDest(lord.ownedPawns[0].Position, base.Map); } List <Pawn> list = null; if (Data.sapperDest.IsValid) { list = new List <Pawn>(); for (int i = 0; i < lord.ownedPawns.Count; i++) { Pawn pawn = lord.ownedPawns[i]; if (SappersUtility.IsGoodSapper(pawn)) { list.Add(pawn); } } if (list.Count == 0 && lord.ownedPawns.Count >= 2) { Pawn pawn2 = null; int num = 0; for (int j = 0; j < lord.ownedPawns.Count; j++) { if (SappersUtility.IsGoodBackupSapper(lord.ownedPawns[j])) { int level = lord.ownedPawns[j].skills.GetSkill(SkillDefOf.Mining).Level; if (pawn2 == null || level > num) { pawn2 = lord.ownedPawns[j]; num = level; } } } if (pawn2 != null) { list.Add(pawn2); } } } for (int k = 0; k < lord.ownedPawns.Count; k++) { Pawn pawn3 = lord.ownedPawns[k]; if (list != null && list.Contains(pawn3)) { pawn3.mindState.duty = new PawnDuty(DutyDefOf.Sapper, Data.sapperDest); } //else if (!list.NullOrEmpty()) //{ // float radius = (pawn3.equipment == null || pawn3.equipment.Primary == null || !pawn3.equipment.Primary.def.IsRangedWeapon) ? EscortRadiusMelee.RandomInRange : EscortRadiusRanged.RandomInRange; // pawn3.mindState.duty = new PawnDuty(DutyDefOf.Escort, list.RandomElement(), radius); //} //else if (pawn3.mindState.duty == null) //{ // //Log.Message(pawn3 + " - " + pawn3.mindState.duty?.def + " changing duty to " + VFEV_DefOf.VFEV_BurnAndStealColony); // pawn3.mindState.duty = new PawnDuty(VFEV_DefOf.VFEV_BurnAndStealColony); //} } }
public override void UpdateAllDuties() { if (!this.Data.sapperDest.IsValid && this.lord.ownedPawns.Any <Pawn>()) { this.Data.sapperDest = GenAI.RandomRaidDest(this.lord.ownedPawns[0].Position, base.Map); } List <Pawn> list = null; if (this.Data.sapperDest.IsValid) { list = new List <Pawn>(); for (int i = 0; i < this.lord.ownedPawns.Count; i++) { Pawn pawn = this.lord.ownedPawns[i]; if (pawn.equipment.Primary != null) { if (pawn.equipment.Primary.GetComp <CompEquippable>().AllVerbs.Any((Verb verb) => verb.verbProps.ai_IsBuildingDestroyer)) { list.Add(pawn); } } } if (list.Count == 0 && this.lord.ownedPawns.Count >= 2) { list.Add(this.lord.ownedPawns[0]); } } for (int j = 0; j < this.lord.ownedPawns.Count; j++) { Pawn pawn2 = this.lord.ownedPawns[j]; if (list != null && list.Contains(pawn2)) { pawn2.mindState.duty = new PawnDuty(DutyDefOf.Sapper, this.Data.sapperDest, -1f); } else if (!list.NullOrEmpty <Pawn>()) { float randomInRange; if (pawn2.equipment != null && pawn2.equipment.Primary != null && pawn2.equipment.Primary.def.IsRangedWeapon) { randomInRange = LordToil_AssaultColonySappers.EscortRadiusRanged.RandomInRange; } else { randomInRange = LordToil_AssaultColonySappers.EscortRadiusMelee.RandomInRange; } pawn2.mindState.duty = new PawnDuty(DutyDefOf.Escort, list.RandomElement <Pawn>(), randomInRange); } else { pawn2.mindState.duty = new PawnDuty(DutyDefOf.AssaultColony); } } }
public override void UpdateAllDuties() { if (!Data.sapperDest.IsValid && lord.ownedPawns.Any()) { Data.sapperDest = GenAI.RandomRaidDest(lord.ownedPawns[0].Position, Map); } List <Pawn> list = null; if (Data.sapperDest.IsValid) { list = new List <Pawn>(); for (int i = 0; i < lord.ownedPawns.Count; i++) { Pawn pawn = lord.ownedPawns[i]; if (pawn.IsGoodLockpicker()) { list.Add(pawn); } } } for (int k = 0; k < lord.ownedPawns.Count; k++) { Pawn pawn3 = lord.ownedPawns[k]; if (list?.Contains(pawn3) ?? false) { pawn3.mindState.duty = new PawnDuty(DutyDefOf.Lockpicker, Data.sapperDest); } else if (!list.NullOrEmpty()) { float radius = (pawn3.equipment == null || pawn3.equipment.Primary == null || !pawn3.equipment.Primary.def.IsRangedWeapon) ? EscortRadiusMelee.RandomInRange : EscortRadiusRanged.RandomInRange; pawn3.mindState.duty = new PawnDuty(RimWorld.DutyDefOf.Escort, list.RandomElement(), radius); } else { pawn3.mindState.duty = new PawnDuty(RimWorld.DutyDefOf.AssaultColony); } } }
public override void UpdateAllDuties() { if (!this.Data.sapperDest.IsValid && this.lord.ownedPawns.Any <Pawn>()) { this.Data.sapperDest = GenAI.RandomRaidDest(this.lord.ownedPawns[0].Position, base.Map); } List <Pawn> list = null; if (this.Data.sapperDest.IsValid) { list = new List <Pawn>(); for (int i = 0; i < this.lord.ownedPawns.Count; i++) { Pawn pawn = this.lord.ownedPawns[i]; if (SappersUtility.IsGoodSapper(pawn)) { list.Add(pawn); } } if (list.Count == 0 && this.lord.ownedPawns.Count >= 2) { Pawn pawn2 = null; int num = 0; for (int j = 0; j < this.lord.ownedPawns.Count; j++) { if (SappersUtility.IsGoodBackupSapper(this.lord.ownedPawns[j])) { int level = this.lord.ownedPawns[j].skills.GetSkill(SkillDefOf.Mining).Level; if (pawn2 == null || level > num) { pawn2 = this.lord.ownedPawns[j]; num = level; } } } if (pawn2 != null) { list.Add(pawn2); } } } for (int k = 0; k < this.lord.ownedPawns.Count; k++) { Pawn pawn3 = this.lord.ownedPawns[k]; if (list != null && list.Contains(pawn3)) { pawn3.mindState.duty = new PawnDuty(DutyDefOf.Sapper, this.Data.sapperDest, -1f); } else if (!list.NullOrEmpty <Pawn>()) { float randomInRange; if (pawn3.equipment != null && pawn3.equipment.Primary != null && pawn3.equipment.Primary.def.IsRangedWeapon) { randomInRange = LordToil_AssaultColonySappers.EscortRadiusRanged.RandomInRange; } else { randomInRange = LordToil_AssaultColonySappers.EscortRadiusMelee.RandomInRange; } pawn3.mindState.duty = new PawnDuty(DutyDefOf.Escort, list.RandomElement <Pawn>(), randomInRange); } else { pawn3.mindState.duty = new PawnDuty(DutyDefOf.AssaultColony); } } }