コード例 #1
0
        public virtual bool CanEverDoBill(Bill bill, out HashSet <Pawn> pawnsAble, MagicRecipeDef mrDefIn = null)
        {
            MagicRecipeDef mrDef = null;

            if (bill != null)
            {
                mrDef = bill.recipe as MagicRecipeDef;
            }
            if (mrDefIn != null)
            {
                mrDef = mrDefIn;
            }
            pawnsAble = new HashSet <Pawn>();
            if (mrDef != null && mrDef is MagicRecipeDef)
            {
                float manaReq = mrDef.manaCost;
                if (mrDef.mageCount > 0)
                {
                    manaReq = mrDef.manaCost / mrDef.mageCount;
                }
                List <Pawn> magePawnsInRange = TM_Calc.FindNearbyMages(this.Position, this.Map, this.Faction, 50, true);
                if (magePawnsInRange != null && magePawnsInRange.Count > 0)
                {
                    for (int i = 0; i < magePawnsInRange.Count; i++)
                    {
                        Pawn p = magePawnsInRange[i];
                        CompAbilityUserMagic comp = p.GetComp <CompAbilityUserMagic>();
                        if (p.Spawned && !p.Drafted && !p.InMentalState && p.GetPosture() == PawnPosture.Standing && p.workSettings.WorkIsActive(TorannMagicDefOf.TM_Magic) && comp != null && comp.Mana != null && comp.Mana.CurLevel >= manaReq)
                        {
                            pawnsAble.Add(p);
                            if (pawnsAble.Count >= mrDef.mageCount)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }