local world = starlit.world
local lib = starlit.mod.lib

world.ecology.biomes.link('starlit:steppe', {
	nightTempDelta = -30;
	waterTempDelta = 0;
	--               W    Sp   Su    Au   W
	seasonalTemp = {-50, -10, 5, 5, -20, -50};
	def = {
		node_top      = 'starlit:greengraze', depth_top = 1;
		node_filler   = 'starlit:soil',    depth_filler = 4;
		node_riverbed = 'starlit:sand',  depth_riverbed = 4;
		y_min = 0;
		y_max = 56;
		heat_point = 50;
		humidity_point = 40;
	};
	weather = {
		{-0.900, 'starlit:meteorShower'};
		{-0.700, 'starlit:sstorm'};
		{-0.100, 'starlit:clear'};
		{0.300, 'starlit:cloudy'};
		{0.400, 'starlit:precip'};
		{0.450, 'starlit:storm'};
		{0.500, 'starlit:tstorm'};
	};
})

world.ecology.biomes.link('starlit:forest', {
	nightTempDelta = -20;
	waterTempDelta = 0;
	--               W    Sp   Su    Au   W
	seasonalTemp = {-40, -8, 10, 10, -14, -40};
	def = {
		node_top      = 'starlit:greengraze', depth_top = 1;
		node_filler   = 'starlit:soil',    depth_filler = 4;
		node_riverbed = 'starlit:sand',  depth_riverbed = 4;
		y_min = 0;
		y_max = 256;
		heat_point = 60;
		humidity_point = 45;
	};
	weather = {
		{-0.900, 'starlit:meteorShower'};
		{-0.700, 'starlit:sstorm'};
		{-0.100, 'starlit:clear'};
		{0.200, 'starlit:cloudy'};
		{0.400, 'starlit:precip'};
		{0.650, 'starlit:storm'};
		{0.800, 'starlit:tstorm'};
	};
})

world.ecology.biomes.link('starlit:desert', {
	nightTempDelta = -40;
	waterTempDelta = 0;
	--               W    Sp  Su    Au   W
	seasonalTemp = {-10, -5, 15, 15, -5, -10};
	def = {
		node_top      = 'starlit:sand',  depth_top = 1;
		node_filler   = 'starlit:sand',  depth_filler = 4;
		node_riverbed = 'starlit:sand',  depth_riverbed = 4;
		y_min = 0;
		y_max = 512;
		heat_point = 70;
		humidity_point = 10;
	};
	weather = {
		{-0.900, 'starlit:meteorShower'};
		{-0.700, 'starlit:sstorm'};
		{-0.100, 'starlit:clear'};
		{0.400, 'starlit:cloudy'};
		{0.850, 'starlit:tstorm'};
	};
})

world.ecology.biomes.link('starlit:ocean', {
	nightTempDelta = -35;
	waterTempDelta = 5;
	seasonalTemp = {0}; -- no seasonal variance
	def = {
		y_max = 3;
		y_min = -512;
		heat_point = 60;
		humidity_point = 70;
		node_top    = 'starlit:sand', depth_top    = 1;
		node_filler = 'starlit:sand', depth_filler = 3;
	};
	weather = {
		{-0.900, 'starlit:meteorShower'};
		{-0.700, 'starlit:sstorm'};
		{-0.100, 'starlit:clear'};
		{0.300, 'starlit:cloudy'};
		{0.500, 'starlit:precip'};
		{0.650, 'starlit:storm'};
		{0.800, 'starlit:tstorm'};
	};
})

world.ecology.biomes.link('starlit:shiverdeep', {
	nightTempDelta = -25;
	waterTempDelta = 5;
	--               W    Sp  Su   Au   W
	seasonalTemp = {-70, -30, 0,  -60, -70};
	def = {
		y_max = 70;
		y_min = 0;
		heat_point = 20;
		humidity_point = 30;
		node_water_top = 'starlit:ice', depth_water_top = 1;
		node_top    = 'starlit:undergloam', depth_top    = 1;
		node_filler = 'starlit:soil',       depth_filler = 2;
	};
	weather = {
		{-0.900, 'starlit:meteorShower'};
		{-0.700, 'starlit:sstorm'};
		{-0.100, 'starlit:clear'};
		{0.200, 'starlit:cloudy'};
		{0.400, 'starlit:precip'};
		{0.650, 'starlit:storm'};
		{0.900, 'starlit:tstorm'};
	};
})

world.ecology.biomes.link('starlit:silthaven', {
	nightTempDelta = -5;
	waterTempDelta = 5;
	--               W  Sp  Su   Au   W
	seasonalTemp = {-15, 5, 15,  7, -15};
	def = {
		y_max = 30;
		y_min = 0;
		heat_point = 30;
		humidity_point = 30;
-- 		node_top    = 'starlit:undergloam', depth_top    = 1;
		node_filler = 'starlit:lifesilt',       depth_filler = 5;
	};
	weather = {
		{-0.900, 'starlit:meteorShower'};
		{-0.700, 'starlit:sstorm'};
		{-0.100, 'starlit:clear'};
		{0.400, 'starlit:cloudy'};
		{0.600, 'starlit:precip'};
		{0.750, 'starlit:storm'};
		{0.900, 'starlit:tstorm'};
	};
})

world.ecology.biomes.link('starlit:barrens', {
	nightTempDelta = -20;
	waterTempDelta = 5;
	--                 W  Sp  Su   Au   W
	seasonalTemp = {-30, -20, 0,  -20, -30};
	def = {
		y_max = 512;
		y_min = -512;
		heat_point = 0;
		humidity_point = 0;
	};
	weather = {
		{-0.900, 'starlit:meteorShower'};
		{-0.600, 'starlit:sstorm'};
		{-0.100, 'starlit:clear'};
		{ 0.300, 'starlit:cloudy'};
		{ 0.600, 'starlit:precip'};
		{ 0.850, 'starlit:storm'};
		{ 0.900, 'starlit:tstorm'};
	};
})
minetest.register_craftitem('starlit_eco:fiber', {
	description = "Plant Fiber";
	groups = {fiber = 1};
	inventory_image = lib.image('starlit-eco-plant-fiber.png'):shift(lib.color(0,1,0)):render();
	_starlit = {
		recover_vary = function(rng, ctx)
			return starlit.type.fab {
				element = { carbon   = rng:int(0,1) };
			};
		end;
	};
})

starlit.include 'plants'
starlit.include 'trees'