#pragma once

#include <frostbite2D/2d/actor.h>
#include <frostbite2D/types/type_math.h>

struct _SDL_GameController;
typedef struct _SDL_GameController SDL_GameController;

namespace frostbite2D {

class GameMap;

class GameCameraController {
public:
  GameCameraController() = default;
  ~GameCameraController();

  void SetMap(GameMap* map);
  void SetTarget(Actor* target);
  void ClearTarget();

  void SetDebugEnabled(bool enabled);
  bool IsDebugEnabled() const { return debugEnabled_; }

  void SetZoom(float zoom);
  float GetZoom() const { return zoom_; }

  void SetFocus(const Vec2& focus);
  const Vec2& GetFocus() const { return focus_; }

  void SnapToDefaultFocus();
  void Update(float deltaTime);

private:
  void openDebugController();
  void closeDebugController();
  void updateDebugInput(float deltaTime);
  void applyFocus() const;

  GameMap* map_ = nullptr;
  Actor* target_ = nullptr;
  SDL_GameController* debugController_ = nullptr;
  Vec2 focus_ = Vec2::Zero();

  bool debugEnabled_ = false;
  bool initialized_ = false;

  float zoom_ = 1.0f;
  float debugMoveSpeed_ = 800.0f;
};

} // namespace frostbite2D
