mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
The world generator now will look up the a spawner node, and get the starting coordinates from it.
This commit is contained in:
parent
fbd232df1b
commit
9fad900a51
@ -35,9 +35,19 @@ func setup(world : TerraWorld, level_seed : int, spawn_mobs : bool, library: Ter
|
|||||||
_library = library
|
_library = library
|
||||||
|
|
||||||
if world_gen_world != null:
|
if world_gen_world != null:
|
||||||
|
world_gen_world.setup()
|
||||||
world_gen_world.setup_terra_library(_library, _level_seed)
|
world_gen_world.setup_terra_library(_library, _level_seed)
|
||||||
_library.refresh_rects()
|
_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:
|
func _generate_chunk(chunk : TerraChunk) -> void:
|
||||||
if world_gen_world == null:
|
if world_gen_world == null:
|
||||||
return
|
return
|
||||||
|
@ -287,7 +287,7 @@ func spawn(start_x : int, start_z : int) -> void:
|
|||||||
|
|
||||||
for x in range(start_x - chunk_spawn_range, chunk_spawn_range + start_x):
|
for x in range(start_x - chunk_spawn_range, chunk_spawn_range + start_x):
|
||||||
for z in range(start_z - chunk_spawn_range, chunk_spawn_range + start_z):
|
for z in range(start_z - chunk_spawn_range, chunk_spawn_range + start_z):
|
||||||
|
|
||||||
var l : float = (spv - Vector2(x, z)).length()
|
var l : float = (spv - Vector2(x, z)).length()
|
||||||
|
|
||||||
if l > chunk_spawn_range:
|
if l > chunk_spawn_range:
|
||||||
@ -346,16 +346,20 @@ func load_character(file_name : String) -> void:
|
|||||||
_player.set_physics_process(false)
|
_player.set_physics_process(false)
|
||||||
|
|
||||||
mob_level = _player.clevel
|
mob_level = _player.clevel
|
||||||
|
|
||||||
set_player(_player.get_body())
|
|
||||||
|
|
||||||
#_player.sseed = 2
|
#_player.sseed = 2
|
||||||
|
|
||||||
Server.sset_seed(_player.sseed)
|
Server.sset_seed(_player.sseed)
|
||||||
if level_generator != null:
|
if level_generator != null:
|
||||||
level_generator.setup(self, _player.sseed, true, library)
|
level_generator.setup(self, _player.sseed, true, library)
|
||||||
|
|
||||||
|
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(0, 0)
|
spawn(spawn_chunk_pos.x, spawn_chunk_pos.y)
|
||||||
|
|
||||||
set_process(true)
|
set_process(true)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user