#pragma once

#include <memory>
#include <fstream>
#include <string>
#include <vector>           // ← for std::vector<>
#include <glm/vec2.hpp>     // ← for glm::vec2

class Object;
class ScriptComponent;
class PhysicsComponent;
class ParticleComponent;
class AnimationComponent;
class TilemapComponent;

class Engine
{
public:
    Engine();
    ~Engine();
    void Run();
    std::shared_ptr<Object> GetObjectByTag(const std::string &tag);

private:
    void Init();
    void Shutdown();
    void DrawObjectNode(const std::shared_ptr<Object> &obj);
    void SaveScene(const std::string &path);
    void LoadScene(const std::string &path);
    void ShowDebugOverlay(float deltaTime);

    void collectObjects(bool playing, const glm::vec2& camPos, float camZoom);

    void SaveState();
    void LoadState();

    int m_Reserved_draws;

    std::vector<Object *>                  m_toDraw;
    std::vector<ScriptComponent *>         m_scriptUpdates;
    std::vector<AnimationComponent *>      m_animationsUpdates;
    
    int m_OnUpdateCalls;

    std::vector<std::shared_ptr<Object>>   m_collectStack;
    std::vector<PhysicsComponent*> m_physicsUpdates;
    std::vector<ParticleComponent*> m_particleUpdates;

};
