Ejemplo n.º 1
0
        ///<summary>
        ///Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1" />.
        ///</summary>
        ///
        ///<param name="item">The object to add to 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 void Add(T item)
        {
            QuadTreeObject <T> wrappedObject = quadTreeObjectPool.New();

            wrappedObject.Data   = item;
            wrappedObject.Active = true;
            wrappedDictionary.Add(item, wrappedObject);
            quadTreeRoot.Insert(wrappedObject);
        }
        private void RegisterObject(IGameObject theObject)
        {
            //Link ourselves to the OnMove event for the game object itself, and the OnDestroyed event for the collision component.
            theObject.OnMove += OnMove;

            var collisionComponent = theObject.GetComponent <ICollisionComponent>();

            collisionTree.Insert(collisionComponent);

            //Add an entry to the current collision dictionary...
            currentCollisions.Add(theObject.GUID, listPool.New());
            currentCollisions[theObject.GUID].Source    = collisionComponent;
            currentCollisions[theObject.GUID].Destroyed = false;

            //..and the collision event dictionaries
            onCollisionEventListeners.Add(theObject.GUID, null);
            onCollisionStoppedEventListeners.Add(theObject.GUID, null);
        }