#ifndef PHYSICSENGINE_HPP
#define PHYSICSENGINE_HPP

#include <vector>

#include "IPhysicsComponent.hpp"

/**
 * A class to handle all collisions and gravity interactions between @link IPhysicsComponent IPhysicsComponents @endlink.
 */
class PhysicsEngine {
public:
    /**
     * Construct a new Physics Engine object
     */
    PhysicsEngine();

    /**
     * Destroy the Physics Engine object
     */
    ~PhysicsEngine();

    /**
     * Adds a new IPhysicsComponent to be handled by the PhysicsEngine.
     * 
     * @param newComponent a pointer to the added IPhysicsComponent
     */
    void AddComponent(IPhysicsComponent* newComponent);

    /**
     * Update all IPhysicsComponents.
     * Resolve collisions between Components all at once.
     * TODO: scale by deltaTime: the Engine-calculated difference between update calls using SDL_GetTicks()
     */
    void Update();

    /**
     * Change gravity to the new value.
     * 
     * @param newGravity the new value for acceleration due to gravity
     */
    void SetGravity(float newGravity);

private:
    /**
     * The acceleration due to gravity in the game.
     * This can safely change during runtime
     */ 
    float m_gravity = 10.0f / 60.0f;

    /**
     * Collection of all physics components
     */
    std::vector<IPhysicsComponent*> m_components;
};

#endif