public bool TryRemoveWeapon(ThingDef def, SharedWeaponFilter filter, bool includeBioencoded, out ThingWithComps weapon)
 {
     if (this.StoredWeapons.TryGetValue(def, out LinkedList <ThingWithComps> l))
     {
         for (LinkedListNode <ThingWithComps> n = l.First; n != null; n = n.Next)
         {
             if (filter.Allows(n.Value))
             {
                 weapon = n.Value;
                 l.Remove(n);
                 return(true);
             }
         }
     }
     if (includeBioencoded)
     {
         if (this.StoredBioEncodedWeapons.TryGetValue(def, out l))
         {
             for (LinkedListNode <ThingWithComps> n = l.First; n != null; n = n.Next)
             {
                 if (filter.Allows(n.Value))
                 {
                     weapon = n.Value;
                     l.Remove(n);
                     return(true);
                 }
             }
         }
     }
     weapon = null;
     return(false);
 }
 public bool HasWeapon(SharedWeaponFilter filter, ThingDef def)
 {
     if (this.StoredWeapons.TryGetValue(def, out LinkedList <ThingWithComps> l))
     {
         if (l == null)
         {
             this.StoredWeapons.Remove(def);
         }
         else
         {
             foreach (ThingWithComps t in l)
             {
                 if (filter.Allows(t))
                 {
                     return(true);
                 }
             }
         }
     }
     // Do not include bio incoded here
     return(false);
 }
        public static bool TryRemoveWeapon(ThingDef def, SharedWeaponFilter filter, bool includeBioencoded, out ThingWithComps weapon)
        {
            if (def != null)
            {
                if (CombatExtendedUtil.TryRemoveAmmo(def, 1, out Thing t))
                {
                    weapon = t as ThingWithComps;
                    if (weapon != null)
                    {
                        return(true);
                    }
                }

                foreach (Building_WeaponStorage ws in WeaponStoragesToUse)
                {
                    if (ws.TryRemoveWeapon(def, filter, includeBioencoded, out weapon))
                    {
                        return(true);
                    }
                }
            }
            weapon = null;
            return(false);
        }