示例#1
0
        public void UpdateFoundDefCache()
        {
            long now = DateTime.Now.Ticks;

            if (now - this.lastCacheUpdate > TimeSpan.TicksPerSecond)
            {
                this.lastCacheUpdate = now;

                this.foundDefCache.Clear();
                foreach (ThingDef def in this.AllowedDefs)
                {
                    if (CombatExtendedUtil.GetAmmoCount(def) > 0)
                    {
                        this.foundDefCache.Add(def);
                        continue;
                    }
                    foreach (Building_WeaponStorage s in WorldComp.GetWeaponStorages(null))
                    {
                        if (s.HasWeapon(this, def))
                        {
                            this.foundDefCache.Add(def);
                            break;
                        }
                    }
                }
            }
        }
示例#2
0
 public void UpdateDefCache(ThingDef def)
 {
     if (this.AllowedDefs.Contains(def))
     {
         if (CombatExtendedUtil.GetAmmoCount(def) > 0)
         {
             this.foundDefCache.Add(def);
             return;
         }
         foreach (Building_WeaponStorage s in WorldComp.GetWeaponStorages(null))
         {
             if (s.HasWeapon(this, def))
             {
                 this.foundDefCache.Add(def);
                 return;
             }
         }
     }
     this.foundDefCache.Remove(def);
 }