2025-08-01 18:47:55 +08:00

74 lines
1.7 KiB
C++

#ifndef TILEMAP_BIOME_H
#define TILEMAP_BIOME_H
#include <cstdint>
#include <string_view>
namespace istd {
// Biome types based on temperature and humidity
enum class BiomeType : std::uint8_t {
SnowyPeeks = 0, // Cold & Dry
SnowyPlains = 1, // Cold & Moderate
FrozenOcean = 2, // Cold & Wet
Plains = 3, // Temperate & Dry
Forest = 4, // Temperate & Moderate
Ocean = 5, // Temperate & Wet
Desert = 6, // Hot & Dry
Savanna = 7, // Hot & Moderate
LukeOcean = 8, // Hot & Wet
};
enum class BiomeTemperature : std::uint8_t {
Cold = 0,
Temperate = 1,
Hot = 2,
};
enum class BiomeHumidity : std::uint8_t {
Dry = 0,
Moderate = 1,
Wet = 2,
};
// Biome properties for terrain generation
struct BiomeProperties {
// Biome name for debugging
std::string_view name;
// Base terrain thresholds (0.0 - 1.0)
double water_threshold;
double ice_threshold;
double sand_threshold;
double land_threshold;
// Noise parameters for base terrain
int base_octaves = 3;
double base_persistence = 0.5;
};
// Get biome properties for terrain generation
const BiomeProperties &get_biome_properties(BiomeType biome);
// Determine biome type based on temperature and humidity
BiomeType determine_biome(double temperature, double humidity);
// Sub-chunk position within a chunk (4x4 grid of 16x16 sub-chunks)
struct SubChunkPos {
std::uint8_t sub_x; // 0-3
std::uint8_t sub_y; // 0-3
constexpr SubChunkPos(std::uint8_t x, std::uint8_t y): sub_x(x), sub_y(y) {}
};
// Get the starting tile coordinates for a sub-chunk
constexpr std::pair<std::uint8_t, std::uint8_t> subchunk_to_tile_start(
const SubChunkPos &pos
) {
return {pos.sub_x * 16, pos.sub_y * 16};
}
} // namespace istd
#endif