public void Remove(T item)
 {
     if (item != null && !_valuesToRemove.Contains(item))
     {
         if (_valuesToAdd.Contains(item))
         {
             _valuesToAdd.Remove(item);
         }
         else if (_values.Contains(item))
         {
             _valuesToRemove.Add(item);
         }
     }
 }
        public void Commit()
        {
            foreach (T item in _valuesToAdd)
            {
                _values.Add(item);
            }
            _valuesToAdd.Clear();

            foreach (T item in _valuesToRemove)
            {
                _values.Remove(item);
            }
            _valuesToRemove.Clear();
        }
예제 #3
0
        public IEnumerable <Mob> GetMobsInCircle(Vector2 origin, int radius)
        {
            IEnumerable <Mob> mobsInRectangle = GetMobsInRectangle(
                new Rectangle((int)origin.X - radius, (int)origin.Y - radius, radius * 2, radius * 2));

            HashedList <Mob> results = new HashedList <Mob>();

            foreach (Mob mob in mobsInRectangle)
            {
                if (Vector2.Distance(mob.PositionInWorldByUpdate, origin) <= Math.Abs(mob.CollisionRectangle.Width / 2 + radius))
                {
                    results.Add(mob);
                }
            }

            return(results);
        }