﻿using System.Collections.Generic;

namespace EnergyShell.Physics
{
    /// <summary>
    /// Interface to an implementation of a broadphase collider.
    /// </summary>
    /// <remarks>
    /// The broadphase guarentees that any collisions it detects might be a potential collision in the
    /// narrow phase. If no collision is detected for any two bodies then it is safe to assume they
    /// won't collide.
    /// </remarks>
    public interface IBroadPhase
    {
        /// <summary>
        /// Adds the given body to the broadphase collider.
        /// </summary>
        /// <param name="body">The body to add to the broadphase collider.</param>
        void AddBody(Body body);

        /// <summary>
        /// Removes the given body from the broadphase collider.
        /// </summary>
        /// <param name="body">The body to remove from the broadphase collider.</param>
        void RemoveBody(Body body);

        /// <summary>
        /// Resynchronizes the body within the broadphase collider.
        /// </summary>
        /// <param name="body">The body to move within the broadphase collider.</param>
        /// <remarks>
        /// Generally the ResynchronizeBody method should be called as a post process after main physics
        /// calculations have been performed so that the broad phase collider knows about changes to the body positions
        /// because there is no way for the broad phase to be notified of changes from the body itself.
        /// </remarks>
        void ResynchronizeBody(Body body);

        /// <summary>
        /// Runs the broadphase collider and returns the contact pairs.
        /// </summary>
        /// <returns>The collection of contact pairs detected.</returns>
        IList<ContactPair> GetContactPairs();
    }
}
