The world generator now will look up the a spawner node, and get the starting coordinates from it.

This commit is contained in:
Relintai 2021-12-27 03:50:11 +01:00
parent fbd232df1b
commit 9fad900a51
2 changed files with 19 additions and 5 deletions

View File

@ -35,9 +35,19 @@ func setup(world : TerraWorld, level_seed : int, spawn_mobs : bool, library: Ter
_library = library
if world_gen_world != null:
world_gen_world.setup()
world_gen_world.setup_terra_library(_library, _level_seed)
_library.refresh_rects()
func get_spawn_chunk_position() -> Vector2:
if world_gen_world != null:
var spawner = world_gen_world.get_content_with_name("Spawner")
if spawner:
return spawner.get_spawn_chunk_position()
return Vector2()
func _generate_chunk(chunk : TerraChunk) -> void:
if world_gen_world == null:
return

View File

@ -347,15 +347,19 @@ func load_character(file_name : String) -> void:
mob_level = _player.clevel
set_player(_player.get_body())
#_player.sseed = 2
Server.sset_seed(_player.sseed)
if level_generator != null:
level_generator.setup(self, _player.sseed, true, library)
spawn(0, 0)
var spawn_chunk_pos : Vector2 = level_generator.get_spawn_chunk_position()
var ppos : Vector3 = Vector3(spawn_chunk_pos.x * chunk_size_x * voxel_scale, 100, spawn_chunk_pos.y * chunk_size_z * voxel_scale)
_player.set_transform_3d(Transform(Basis(), ppos))
set_player(_player.get_body())
spawn(spawn_chunk_pos.x, spawn_chunk_pos.y)
set_process(true)