예제 #1
0
        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 bool CanUsePawn(Pawn p, List <Pawn> otherPawns)
 {
     if (otherPawns.Count == 0)
     {
         if (!SappersUtility.IsGoodSapper(p) && !SappersUtility.IsGoodBackupSapper(p))
         {
             return(false);
         }
     }
     return(!p.kindDef.canBeSapper || !SappersUtility.HasBuildingDestroyerWeapon(p) || SappersUtility.IsGoodSapper(p));
 }
예제 #3
0
 public static bool IsGoodSapper(Pawn p)
 {
     return(p.kindDef.canBeSapper && SappersUtility.HasBuildingDestroyerWeapon(p) && SappersUtility.CanMineReasonablyFast(p));
 }
예제 #4
0
 public static bool IsGoodBackupSapper(Pawn p)
 {
     return(p.kindDef.canBeSapper && SappersUtility.CanMineReasonablyFast(p));
 }
예제 #5
0
        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);
                }
            }
        }