public override void Update(GameTime gameTime) { foreach (var collisionComponent in movedLastFrame.Values) { collisionTree.ItemMoved(collisionComponent, new RectangleF(collisionComponent.Parent.LastFramePosition.X, collisionComponent.Parent.LastFramePosition.Y, collisionComponent.BoundingBox2D.Width, collisionComponent.BoundingBox2D.Height)); } //Update any of the existing collisions to ensure that: // (a) The objects in question are still colliding, and, // (b) OnCollisionOccurred events are fired if they are still colliding. UpdateExistingCollisions(); //Add any new collisions from movedLastFrame that do not already appear in the existing collisions. UpdateNewCollisions(); //Clear the moved list movedLastFrame.Clear(); listPool.CleanUp(); base.Update(gameTime); }
///<summary> ///Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1" />. ///</summary> /// ///<returns> ///true if <paramref name="item" /> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false. This method also returns false if <paramref name="item" /> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1" />. ///</returns> /// ///<param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1" />.</param> ///<exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only.</exception> public bool Remove(T item) { if (Contains(item)) { quadTreeRoot.Delete(wrappedDictionary[item], true); wrappedDictionary[item].Active = false; wrappedDictionary.Remove(item); quadTreeObjectPool.CleanUp(); return(true); } return(false); }