diff --git a/game/modules/planets/test_planet/biomes/1_test.tres b/game/modules/planets/test_planet/biomes/1_test.tres index b8bff07f..c7aa49be 100644 --- a/game/modules/planets/test_planet/biomes/1_test.tres +++ b/game/modules/planets/test_planet/biomes/1_test.tres @@ -1,6 +1,8 @@ -[gd_resource type="Biome" load_steps=2 format=2] +[gd_resource type="Biome" load_steps=3 format=2] [ext_resource path="res://modules/planets/test_planet/biomes/simple_biome.gd" type="Script" id=1] +[ext_resource path="res://modules/planets/test_planet/biomes/simple_biome/low_poly_rpg_item_collection_3/t1.tscn" type="PackedScene" id=2] [resource] script = ExtResource( 1 ) +tree = ExtResource( 2 ) diff --git a/game/modules/planets/test_planet/biomes/2_tdungb.tres b/game/modules/planets/test_planet/biomes/2_tdungb.tres index 872def9d..c3b2f565 100644 --- a/game/modules/planets/test_planet/biomes/2_tdungb.tres +++ b/game/modules/planets/test_planet/biomes/2_tdungb.tres @@ -1,8 +1,10 @@ -[gd_resource type="Biome" load_steps=3 format=2] +[gd_resource type="Biome" load_steps=4 format=2] [ext_resource path="res://modules/planets/test_planet/biomes/simple_biome.gd" type="Script" id=1] [ext_resource path="res://modules/planets/test_planet/villages/village.tres" type="Building" id=2] +[ext_resource path="res://modules/planets/test_planet/biomes/simple_biome/low_poly_rpg_item_collection_3/t1.tscn" type="PackedScene" id=3] [resource] buildings = [ ExtResource( 2 ) ] script = ExtResource( 1 ) +tree = ExtResource( 3 ) diff --git a/game/modules/planets/test_planet/biomes/simple_biome.gd b/game/modules/planets/test_planet/biomes/simple_biome.gd index 920c8faa..83ab1e91 100644 --- a/game/modules/planets/test_planet/biomes/simple_biome.gd +++ b/game/modules/planets/test_planet/biomes/simple_biome.gd @@ -21,6 +21,8 @@ extends Biome # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +export(PackedScene) var tree : PackedScene + var terrarin_gen : BiomeTerrarinGenerator = BiomeTerrarinGenerator.new() var voxel_scale : float = -1 @@ -32,6 +34,11 @@ func _setup(): var d : Building = get_building(i) d.setup() +func _instance(p_seed, p_instance): + p_instance.tree = tree + + return ._instance(p_seed, p_instance) + func _generate_terra_chunk(chunk, spawn_mobs): if voxel_scale < 0: voxel_scale = chunk.voxel_scale @@ -93,3 +100,18 @@ func gen_terra_chunk(chunk: TerraChunk) -> void: chunk.set_voxel(2, x, z, TerraChunkDefault.DEFAULT_CHANNEL_TYPE) elif val > 90: chunk.set_voxel(4, x, z, TerraChunkDefault.DEFAULT_CHANNEL_TYPE) + else: + #Todo use the prop system for this + if randf() > 0.992: + var t = tree.instance() + + var spat : Spatial = t as Spatial + + spat.rotate(Vector3(0, 1, 0), randf() * PI) + spat.rotate(Vector3(1, 0, 0), randf() * 0.2 - 0.1) + spat.rotate(Vector3(0, 0, 1), randf() * 0.2 - 0.1) + spat.transform = spat.transform.scaled(Vector3(0.9 + 0.8 - randf(), 0.9 + 0.8 - randf(), 0.9 + 0.8 - randf())) + spat.transform.origin = Vector3((x + chunk.position_x * chunk.size_x) * chunk.voxel_scale, ((val - 2) / 255.0) * chunk.world_height * chunk.voxel_scale, (z + chunk.position_z * chunk.size_z) * chunk.voxel_scale) + + chunk.voxel_world.call_deferred("add_child", spat) +