From 3081388a799cac941115d49077a051225157adb1 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 4 Mar 2020 18:47:20 +0100 Subject: [PATCH] Actual contents of f2ac08f7. Not sure how I managed to mess up like this. --- HEADS | 2 +- game/player/Mob.gd | 31 +++++++++++------------------ game/scripts/biomes/simple_biome.gd | 4 ++-- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/HEADS b/HEADS index 1fd48517..f2eeac8c 100644 --- a/HEADS +++ b/HEADS @@ -1 +1 @@ -{"engine": {"3.2": "0d5e483a90c41c433056b8cf6e4e8def6316690f", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "a08917370cdef0884042bdb49fb80ece0b2e76ec"}, "entity_spell_system": {"master": "3e10779dbc5258d1e1b08eab287189f9c1ccec64"}, "ui_extensions": {"master": "38acc650db260a831dc26ca96fe9d9a087230bdc"}, "voxelman": {"master": "fbd2903477bc810fba8abec48f9cd6f9252e2fe5"}, "texture_packer": {"master": "b17c174906f84de93d84aa60d010ffe603efaa28"}, "fastnoise": {"master": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e"}, "mesh_data_resource": {"master": "4bda19b12be2c2a79a6121de6d22e48f3934e726"}, "procedural_animations": {"master": "ba464ef04500aa01b2638cf1f890f3f6582ead84"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}} \ No newline at end of file +{"engine": {"3.2": "0d5e483a90c41c433056b8cf6e4e8def6316690f", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "a08917370cdef0884042bdb49fb80ece0b2e76ec"}, "entity_spell_system": {"master": "3e10779dbc5258d1e1b08eab287189f9c1ccec64"}, "ui_extensions": {"master": "38acc650db260a831dc26ca96fe9d9a087230bdc"}, "voxelman": {"master": "59291a9417db2e1ba3a5fc5dc6ae2e8cdda1b09a"}, "texture_packer": {"master": "b17c174906f84de93d84aa60d010ffe603efaa28"}, "fastnoise": {"master": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e"}, "mesh_data_resource": {"master": "4bda19b12be2c2a79a6121de6d22e48f3934e726"}, "procedural_animations": {"master": "ba464ef04500aa01b2638cf1f890f3f6582ead84"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}} \ No newline at end of file diff --git a/game/player/Mob.gd b/game/player/Mob.gd index a39c30bd..5ce4c2a1 100644 --- a/game/player/Mob.gd +++ b/game/player/Mob.gd @@ -51,6 +51,8 @@ var sleep : bool = false var dead : bool = false var death_timer : float = 0 +var _world : VoxelWorld = null + func _ready() -> void: animation_tree = get_character_skeleton().get_animation_tree() @@ -60,27 +62,13 @@ func _ready() -> void: animation_tree["parameters/run-loop/blend_position"] = Vector2(0, -1) ai_state = EntityEnums.AI_STATE_PATROL - - set_process(true) - set_physics_process(true) func _enter_tree(): - var world : VoxelWorld = get_node("..") as VoxelWorld - - if world != null: - if not world.is_position_walkable(get_body().transform.origin): - world.connect("chunk_mesh_generation_finished", self, "chunk_mesh_generation_finished", [], CONNECT_DEFERRED) - set_process(false) - set_physics_process(false) - -func chunk_mesh_generation_finished(chunk): - var world : VoxelWorld = get_node("..") as VoxelWorld - - if world.is_position_walkable(get_body().transform.origin): - world.disconnect("chunk_mesh_generation_finished", self, "chunk_mesh_generation_finished") - set_process(true) - set_physics_process(true) + _world = get_node("..") as VoxelWorld + set_process(true) + set_physics_process(true) + func _process(delta : float) -> void: if dead: @@ -90,6 +78,7 @@ func _process(delta : float) -> void: queue_free() return + var camera : Camera = get_tree().get_root().get_camera() as Camera @@ -118,7 +107,11 @@ func _physics_process(delta : float) -> void: if dead: return - + + if _world != null: + if not _world.is_position_walkable(get_body().transform.origin): + return + process_movement(delta) func process_movement(delta : float) -> void: diff --git a/game/scripts/biomes/simple_biome.gd b/game/scripts/biomes/simple_biome.gd index 224b3241..ee803db3 100644 --- a/game/scripts/biomes/simple_biome.gd +++ b/game/scripts/biomes/simple_biome.gd @@ -96,9 +96,9 @@ func generate_terrarin(chunk : VoxelChunk, spawn_mobs: bool) -> void: # chunk.build() if not Engine.editor_hint and chunk.position_y == 0 and spawn_mobs: - Entities.spawn_mob(1, randi() % 3, Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale - chunk.size_x / 2,\ + Entities.spawn_mob(1, randi() % 3, Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\ (chunk.position_y + 1) * chunk.size_y * chunk.voxel_scale, \ - chunk.position_z * chunk.size_z * chunk.voxel_scale - chunk.size_z / 2)) + chunk.position_z * chunk.size_z * chunk.voxel_scale + chunk.size_z / 2)) func box_blur(chunk : VoxelChunk): for x in range(0, chunk.size_x):