63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
using Godot;
|
|
|
|
namespace IslaApocalypse.Core
|
|
{
|
|
public static class BiomePalette
|
|
{
|
|
/// <summary>
|
|
/// Determines the exact Block ID for a specific voxel in the 3D world based on its depth and biome.
|
|
/// </summary>
|
|
/// <param name="biome">The 2D biome pixel from the MapData.</param>
|
|
/// <param name="surfaceHeight">The maximum height of the terrain at this X/Z coordinate.</param>
|
|
/// <param name="currentY">The Y coordinate of the specific voxel we are painting.</param>
|
|
/// <param name="isRoad">Is this coordinate part of the highway/branch road network?</param>
|
|
public static byte GetVoxelID(Biome biome, int surfaceHeight, int currentY, bool isRoad)
|
|
{
|
|
// 1. Air Check: If we are above the terrain, it's Air.
|
|
if (currentY > surfaceHeight) return BlockRegistry.AIR;
|
|
|
|
// 2. Bedrock Check: The very bottom of the world is indestructible.
|
|
if (currentY == 0) return BlockRegistry.BEDROCK;
|
|
|
|
// 3. Infrastructure Check: If this is a road, and we are exactly on the surface, paint asphalt.
|
|
if (isRoad && currentY == surfaceHeight) return BlockRegistry.ASPHALT;
|
|
|
|
int depthBelowSurface = surfaceHeight - currentY;
|
|
|
|
// 4. Subsurface Logic (Dirt layer vs Stone layer)
|
|
// The top 4 blocks are usually dirt/sand, everything below that is solid stone.
|
|
if (depthBelowSurface > 4) return BlockRegistry.STONE;
|
|
|
|
// 5. Surface & Shallow Subsurface Logic (Based on Biome)
|
|
switch (biome)
|
|
{
|
|
case Biome.Beach:
|
|
case Biome.Crater:
|
|
return BlockRegistry.SAND; // Craters and Beaches are deep sand
|
|
|
|
case Biome.Snow:
|
|
case Biome.Mountain:
|
|
if (depthBelowSurface == 0) return BlockRegistry.SNOW; // Only the top layer is snow
|
|
return BlockRegistry.STONE; // Mountains have shallow topsoil, mostly stone
|
|
|
|
case Biome.Wasteland:
|
|
return BlockRegistry.WASTELAND_DIRT;
|
|
|
|
case Biome.Jungle:
|
|
if (depthBelowSurface == 0) return BlockRegistry.GRASS_JUNGLE;
|
|
return BlockRegistry.DIRT;
|
|
|
|
case Biome.Paradise:
|
|
if (depthBelowSurface == 0) return BlockRegistry.GRASS_PARADISE;
|
|
return BlockRegistry.DIRT;
|
|
|
|
case Biome.Tropical:
|
|
if (depthBelowSurface == 0) return BlockRegistry.GRASS_TROPICAL;
|
|
return BlockRegistry.DIRT;
|
|
|
|
default:
|
|
return BlockRegistry.DIRT; // Fallback
|
|
}
|
|
}
|
|
}
|
|
}
|