public virtual bool collides(bEntity e, string[] categories, Func<bEntity, bEntity, bool> condition = null)
 {
     foreach (string category in categories)
         if (entities[category] != null)
             foreach (bEntity ge in entities[category])
                 if (ge != e && ge.collidable && e.collides(ge) && (condition == null || condition(e, ge)))
                     return true;
     return false;
 }
        public virtual List<bEntity> instancesCollision(bEntity e, string[] categories, string attr = null, Func<bEntity, bEntity, bool> condition = null)
        {
            List<bEntity> result = new List<bEntity>();

            foreach (string category in categories)
                if (entities[category] != null)
                    foreach (bEntity ge in entities[category])
                        if (ge != e && ge.collidable && e.collides(ge) && (condition == null || condition(e, ge)))
                            if (attr == null || ge.hasAttribute(attr))
                                result.Add(ge);

            return result;
        }
 public virtual bEntity instanceCollision(bEntity e, string[] categories, string attr = null, Func<bEntity, bEntity, bool> condition = null)
 {
     foreach (string category in categories)
         if (entities[category] != null)
             foreach (bEntity ge in entities[category])
                 if (ge != e && ge.collidable && e.collides(ge) && (condition == null || condition(e, ge)))
                     if (attr == null || ge.hasAttribute(attr))
                         return ge;
     return null;
 }