#pragma once

#include "../data/level_definition.h"
#include "../core/debug_flags.h"

#include <frostbite2D/graphics/texture.h>
#include <string>
#include <unordered_map>

namespace ns_game {

class StageRenderer {
public:
  void Render(const LevelDefinition& level, const DebugFlags& debugFlags) const;
  void RenderForeground(const LevelDefinition& level) const;

private:
  void drawBackground(const LevelDefinition& level) const;
  void drawGrid(const LevelDefinition& level) const;
  void drawLayer(const LevelDefinition& level, const StageLayer& layer) const;
  void drawStageRect(const StageRect& rect,
                     const frostbite2D::Rect& bounds) const;
  frostbite2D::Ptr<frostbite2D::Texture>
  getTexture(const std::string& texturePath) const;

  mutable std::unordered_map<std::string, frostbite2D::Ptr<frostbite2D::Texture>>
      textureCache_;
};

} // namespace ns_game
