Don't spawn mobs at all during world generation on a client.

This commit is contained in:
Relintai 2021-08-29 23:38:15 +02:00
parent f8803b99ab
commit c0280ce6f3
3 changed files with 9 additions and 3 deletions

View File

@ -74,10 +74,10 @@ func _generate_terra_chunk(chunk, spawn_mobs):
if chunk.position_x == 0 && chunk.position_z == 0:
#test
spawn_dungeon(chunk, chunk_seed)
spawn_dungeon(chunk, chunk_seed, spawn_mobs)
else:
if rng.randi() % 10 == 0:
spawn_dungeon(chunk, chunk_seed)
spawn_dungeon(chunk, chunk_seed, spawn_mobs)
for i in range(get_building_count()):
get_building(i).generate_terra_chunk(chunk, spawn_mobs)
@ -143,7 +143,7 @@ func gen_terra_chunk(chunk: TerraChunk, rng : RandomNumberGenerator) -> void:
# chunk.voxel_world.prop_add(tr, prop_tree2)
func spawn_dungeon(chunk: TerraChunk, dungeon_seed : int) -> void:
func spawn_dungeon(chunk: TerraChunk, dungeon_seed : int, spawn_mobs : bool) -> void:
var x : float = chunk.position_x * chunk.voxel_scale * chunk.size_x
var z : float = chunk.position_z * chunk.voxel_scale * chunk.size_z
@ -162,5 +162,6 @@ func spawn_dungeon(chunk: TerraChunk, dungeon_seed : int) -> void:
dt.min_level = level - 1
dt.max_level = level + 1
dt.dungeon_seed = dungeon_seed
dt.spawn_mobs = spawn_mobs
dt.transform = Transform(Basis().scaled(Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale)), Vector3(x, vwh, z))

View File

@ -10,6 +10,7 @@ export(PackedScene) var dungeon_back_teleporter : PackedScene
var min_level : int = 1
var max_level : int = 2
var dungeon_seed : int = 0
var spawn_mobs : bool = true
var owner_chunk : TerraChunk = null
var _dungeon : Spatial = null
@ -91,6 +92,7 @@ func teleport():
_dungeon.transform = t
_dungeon.min_level = min_level
_dungeon.max_level = max_level
_dungeon.spawn_mobs = spawn_mobs
_dungeon.dungeon_seed = dungeon_seed
get_parent().add_child(_dungeon)

View File

@ -13,6 +13,9 @@ func _instance(p_seed, p_instance):
return p_instance
func _generate_terra_chunk(chunk : TerraChunk, spawn_mobs : bool):
if !spawn_mobs:
return
if trainer == null || vendor == null:
return