diff --git a/game/modules/planets/test_planet/test_world.tres b/game/modules/planets/test_planet/test_world.tres index 8c90b5aa..8610acd8 100644 --- a/game/modules/planets/test_planet/test_world.tres +++ b/game/modules/planets/test_planet/test_world.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" load_steps=11 format=2] +[gd_resource type="Resource" load_steps=13 format=2] [ext_resource path="res://addons/world_generator/resources/world_gen_world.gd" type="Script" id=1] [ext_resource path="res://world_generator/continents/test_continent.gd" type="Script" id=2] @@ -7,12 +7,16 @@ [ext_resource path="res://modules/planets/test_planet/dungeons/dung_teleporter.tscn" type="PackedScene" id=5] [ext_resource path="res://modules/planets/test_planet/biomes/simple_biome/low_poly_rpg_item_collection_3/t1.tres" type="PropData" id=6] [ext_resource path="res://modules/planets/test_planet/biomes/simple_biome/low_poly_rpg_item_collection_3/t2.tres" type="PropData" id=7] +[ext_resource path="res://modules/entity_classes/naturalist/entities/3_naturalist_trainer.tres" type="EntityData" id=8] +[ext_resource path="res://modules/entity_classes/naturalist/entities/4_naturalist_vendor.tres" type="EntityData" id=9] [sub_resource type="Resource" id=2] resource_name = "Spawner" script = ExtResource( 4 ) -rect = Rect2( 162, 172, 22, 25 ) +rect = Rect2( 165, 197, 22, 25 ) locked = false +trainer = ExtResource( 8 ) +vendor = ExtResource( 9 ) [sub_resource type="Resource" id=3] resource_name = "TestForest" diff --git a/game/world_generator/subzones/spawner.gd b/game/world_generator/subzones/spawner.gd index 17157e09..11abf19f 100644 --- a/game/world_generator/subzones/spawner.gd +++ b/game/world_generator/subzones/spawner.gd @@ -1,6 +1,36 @@ tool extends SubZone +export (EntityData) var trainer : EntityData +export (EntityData) var vendor : EntityData + +var main_chunk_pos_x : int = 0 +var main_chunk_pos_z : int = 0 + +func _setup() -> void: + main_chunk_pos_x = get_parent_pos().x + get_rect().position.x + get_rect().size.x / 2 + main_chunk_pos_z = get_parent_pos().y + get_rect().position.y + get_rect().size.y / 2 + +func get_spawn_chunk_position() -> Vector2: + return Vector2(main_chunk_pos_x, main_chunk_pos_z) + +func _generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool, stack : Array, stack_index : int) -> void: + if !spawn_mobs: + return + + if trainer == null || vendor == null: + return + + #var r : Rect2 = get_rect() + #var cpx : int = r.position.x + (r.size.x / 2) + + if chunk.position_x == main_chunk_pos_x && chunk.position_z == main_chunk_pos_z: + var pos : Vector3 = Vector3(4 * chunk.voxel_scale, 8 * chunk.voxel_scale, 4 * chunk.voxel_scale) + ESS.entity_spawner.spawn_mob(trainer.id, 1, pos) + pos = Vector3(2 * chunk.voxel_scale, 8 * chunk.voxel_scale, 2 * chunk.voxel_scale) + ESS.entity_spawner.spawn_mob(vendor.id, 1, pos) + + func get_editor_rect_border_color() -> Color: return Color(0.8, 0.8, 0.8, 1)