#pragma once

#include <frostbite2D/2d/actor.h>
namespace frostbite2D {

class CharacterObject;
class GameMap;
class NineSliceActor;
class TextSprite;

/**
 * @brief Reusable singleton debug actor for UI scenes.
 */
class GameDebugActor : public Actor {
public:
  static GameDebugActor& get();
  static Ptr<GameDebugActor> getPtr();

  GameDebugActor(const GameDebugActor&) = delete;
  GameDebugActor& operator=(const GameDebugActor&) = delete;

  bool AttachToScene(Scene* scene);
  bool AttachToParent(Actor* parent);
  void DetachFromParent();

  void SetDebugMap(GameMap* map);
  void SetTrackedCharacter(CharacterObject* character);
  void ClearDebugContext();

  void OnUpdate(float deltaTime) override;

private:
  void initOverlay();
  void updateOverlay();
  void updateMapDebugHighlight();
  void setOverlayVisible(bool visible);

  GameDebugActor();
  ~GameDebugActor() override = default;

  GameMap* debugMap_ = nullptr;
  CharacterObject* trackedCharacter_ = nullptr;
  RefPtr<NineSliceActor> background_;
  RefPtr<TextSprite> coordText_;
  RefPtr<TextSprite> actionText_;
};

} // namespace frostbite2D
