/// <summary>
        /// Register an ICollidable component in the collidables list
        /// and associates it with the specific listeener
        /// Colliders might not have an entity Listeening,
        /// they still have to be registered for collision detection for other entities
        /// </summary>
        /// <param name="collidable">ICollidable to register</param>
        public void RegisterCollidable(ICollidable collidable)
        {
            collidables.Add(collidable);
            int index = collidables.Count - 1;

            //For every collider create a status list representing it status with all other colliders
            currentStatus.Add(new List <int>());
            //Add the number of values to the list equal to the number of current colliers
            for (int i = 0; i < collidables.Count - 1; i++)
            {
                currentStatus[index].Add(0);
            }
            //If there are no listeners subscribed -> links can't be created yet
            if (CollisionEnter == null)
            {
                return;
            }


            //Checks if the collidable belongs to an already registered entity
            Delegate[] list = CollisionEnter.GetInvocationList();
            for (int i = 0; i < list.Length; i++)
            {
                IEntity entity = list[i].Target as IEntity;
                if (collidable.Owner == entity)
                {
                    //Links the collider with the listeener
                    links[i].Add(collidable);
                    break;
                }
            }
        }
        /// <summary>
        /// Unregisters a collider, stopping tracking collisions
        /// This is called before an entity is removed and listener are unregitered
        /// </summary>
        /// <param name="collidable">ICollidable to stop tracking</param>
        public void UnregisterCollidable(ICollidable collidable)
        {
            int index = collidables.IndexOf(collidable);

            //Removes collision info from CurrentStatuslist for this specific collider
            for (int i = collidables.Count - 1; i >= 0; i--)
            {
                if (i == index)
                {
                    //When it reachs the index of the collider it means previous index have no reference to this collider
                    currentStatus.RemoveAt(index);
                    break;
                }
                currentStatus[i].RemoveAt(index);
            }
            Delegate[] list = CollisionEnter.GetInvocationList();
            //Checks if the collidable belongs to a already registered entity
            for (int i = 0; i < list.Length; i++)
            {
                IEntity entity = list[i].Target as IEntity;
                if (collidable.Owner == entity)
                {
                    //Links the collider with the listeener
                    links[i].Remove(collidable);
                    break;
                }
            }

            //Remove the collidable from the list
            collidables.Remove(collidable);
        }
 /// <summary>
 /// Notifies one entities listenning onEnterCollision event
 /// It will only invoke collision events in the entity that
 /// is involved in that specific collision
 /// Usefull for when only one side of the collision needs to be notified
 /// If there are no listeeners correspoding to that index, nothing happens
 /// </summary>
 /// <param name="index">index of the entity to signal. Index in the Delegate[] is the same in the links list</param>
 /// <param name="collidable">collider that collided with the entity</param>
 void NotifyOnCollisionEnter(int index, ICollidable collidable)
 {
     if (CollisionEnter != null)
     {
         //Console.WriteLine("OnCollisionEnter");
         Delegate[] list = CollisionEnter.GetInvocationList();
         //Check if the index of the entity is valid
         if (index < list.Length && index > -1)
         {
             Collision collision = new Collision();
             collision.other = collidable;
             list[index].DynamicInvoke(collision);
         }
     }
 }
        /// <summary>
        /// Unregisters listeners to collision events
        /// Removes collision info from the current status
        /// Removes links of the listener and collides from the links list
        /// This is called after all the colliders have been removed
        /// </summary>
        /// <param name="listener">Listener</param>
        public void UnregisterListener(ICollisionListener listener)
        {
            //Remove the listeener links from the links lists
            Delegate[] list = CollisionEnter.GetInvocationList();
            for (int i = 0; i < list.Length; i++)
            {
                ICollisionListener t_listener = list[i].Target as ICollisionListener;
                if (t_listener == listener)
                {
                    links.RemoveAt(i);
                    break;
                }
            }

            //Unsubscribe to events
            CollisionEnter -= new CollisionHandler(listener.OnCollisionEnter);
            CollisionExit  -= new CollisionHandler(listener.OnCollisionExit);
            CollisionStay  -= new CollisionHandler(listener.OnCollisionStay);
        }