#pragma once

#include "../movement/platform_world.h"
#include <frostbite2D/types/type_color.h>
#include <frostbite2D/types/type_math.h>
#include <string>
#include <vector>

namespace ns_game {

enum class StageLayerRole {
  BackgroundFar,
  BackgroundMid,
  LevelVisual,
  PropsBack,
  PropsFront
};

struct StageLayerSource {
  std::string texturePath;
  frostbite2D::Rect sourceRect;
  bool useSourceRect = false;
  frostbite2D::Color tint = frostbite2D::Color(1.0f, 1.0f, 1.0f, 1.0f);

  bool hasTexture() const { return !texturePath.empty(); }
};

struct StageRect {
  frostbite2D::Rect bounds;
  frostbite2D::Color color;
  StageLayerRole layer = StageLayerRole::PropsBack;
  StageLayerSource source;
};

struct SpawnPoint {
  std::string id;
  frostbite2D::Vec2 position;
};

struct BattleZoneDefinition {
  std::string id;
  frostbite2D::Rect trigger;
  frostbite2D::Rect cameraBounds;
  std::vector<SpawnPoint> enemySpawns;
};

enum class BattleZoneDebugState {
  Idle,
  Active,
  Cleared
};

struct BattleZoneDebugInfo {
  size_t zoneIndex = 0;
  BattleZoneDebugState state = BattleZoneDebugState::Idle;
};

struct StageLayer {
  std::string id;
  StageLayerRole role = StageLayerRole::LevelVisual;
  float parallax = 1.0f;
  std::vector<StageRect> rects;
};

struct LevelDefinition {
  float worldWidth = 0.0f;
  float worldHeight = 0.0f;
  frostbite2D::Vec2 playerSpawn;
  frostbite2D::Rect cameraBounds;
  PlatformWorld collision;
  std::vector<StageLayer> layers;
  std::vector<BattleZoneDefinition> battleZones;
};

LevelDefinition CreateWhiteboxLevel();

} // namespace ns_game
