Exemplo n.º 1
0
        public virtual bool Allows(Thing t)
        {
            t = t.GetInnerIfMinified();
            bool result;

            if (!this.Allows(t.def))
            {
                result = false;
            }
            else
            {
                if (t.def.useHitPoints)
                {
                    float num = (float)t.HitPoints / (float)t.MaxHitPoints;
                    num = GenMath.RoundedHundredth(num);
                    if (!this.allowedHitPointsPercents.IncludesEpsilon(Mathf.Clamp01(num)))
                    {
                        return(false);
                    }
                }
                if (this.allowedQualities != QualityRange.All && t.def.FollowQualityThingFilter())
                {
                    QualityCategory p;
                    if (!t.TryGetQuality(out p))
                    {
                        p = QualityCategory.Normal;
                    }
                    if (!this.allowedQualities.Includes(p))
                    {
                        return(false);
                    }
                }
                for (int i = 0; i < this.disallowedSpecialFilters.Count; i++)
                {
                    if (this.disallowedSpecialFilters[i].Worker.Matches(t))
                    {
                        return(false);
                    }
                }
                result = true;
            }
            return(result);
        }
Exemplo n.º 2
0
 public virtual bool Allows(Thing t)
 {
     if (!this.Allows(t.def))
     {
         return(false);
     }
     if (t.def.useHitPoints)
     {
         float f = (float)t.HitPoints / (float)t.MaxHitPoints;
         f = GenMath.RoundedHundredth(f);
         if (!this.allowedHitPointsPercents.IncludesEpsilon(Mathf.Clamp01(f)))
         {
             return(false);
         }
     }
     if (this.allowedQualities != QualityRange.All && t.def.FollowQualityThingFilter())
     {
         QualityCategory p = default(QualityCategory);
         if (!t.TryGetQuality(out p))
         {
             p = QualityCategory.Normal;
         }
         if (!this.allowedQualities.Includes(p))
         {
             return(false);
         }
     }
     for (int i = 0; i < this.disallowedSpecialFilters.Count; i++)
     {
         if (this.disallowedSpecialFilters[i].Worker.Matches(t))
         {
             return(false);
         }
     }
     return(true);
 }