From 6b50033f29453b4b43cb4e23054ff210cd625a31 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 23 May 2020 18:49:06 +0200 Subject: [PATCH] Now the visibility/lod/wakeup check has a timer for mobs. --- .../species/Human/models/armature_huf.tscn | 4 ++-- game/player/Body.gd | 22 +++++++++++++++++-- game/scenes/World.tscn | 1 - 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/game/modules/species/Human/models/armature_huf.tscn b/game/modules/species/Human/models/armature_huf.tscn index 6a818191..012143dc 100644 --- a/game/modules/species/Human/models/armature_huf.tscn +++ b/game/modules/species/Human/models/armature_huf.tscn @@ -161,7 +161,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.04, -0.09 ) script = ExtResource( 2 ) [node name="RightHandAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="2"] -transform = Transform( -0.0400955, -0.0242102, -0.998884, -0.127471, -0.991364, 0.0291306, -0.991041, 0.128501, 0.0366712, -0.226341, 0.768569, -0.00640216 ) +transform = Transform( -0.0400954, -0.0242101, -0.998884, -0.127471, -0.991364, 0.0291305, -0.991041, 0.128501, 0.0366712, -0.226341, 0.768569, -0.00640216 ) bone_name = "right_hand" [node name="RightHandAP" type="Spatial" parent="armature/Armature/Skeleton/RightHandAttachment"] @@ -177,7 +177,7 @@ transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0 script = ExtResource( 2 ) [node name="NeckAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="4"] -transform = Transform( 0.99998, -0.00629028, -0.000312272, 0.00629784, 0.997246, 0.0731527, -0.000148758, -0.0731576, 0.99732, 0.00103962, 1.31823, 5.39595e-05 ) +transform = Transform( 0.99998, -0.00629028, -0.000312272, 0.00629784, 0.997246, 0.0731527, -0.000148758, -0.0731576, 0.99732, 0.00103962, 1.31823, 5.39597e-05 ) bone_name = "neck" [node name="TorsoAP" type="Spatial" parent="armature/Armature/Skeleton/NeckAttachment"] diff --git a/game/player/Body.gd b/game/player/Body.gd index e8802676..5736f584 100644 --- a/game/player/Body.gd +++ b/game/player/Body.gd @@ -78,6 +78,7 @@ var moving : bool = false var casting_anim : bool = false var sleep : bool = false +var sleep_recheck_timer : float = 0 var dead : bool = false var death_timer : float = 0 @@ -89,6 +90,8 @@ var entity : Entity var model_rotation_node : Spatial var character_skeleton : CharacterSkeleton3D +var visibility_update_timer : float = 0 + func _ready() -> void: camera = get_node_or_null("CameraPivot/Camera") as Camera camera_pivot = get_node_or_null("CameraPivot") as Spatial @@ -125,6 +128,13 @@ func _enter_tree(): func _process(delta : float) -> void: if entity.ai_state == EntityEnums.AI_STATE_OFF: return + + visibility_update_timer += delta + + if visibility_update_timer < 1: + return + + visibility_update_timer = 0 var camera : Camera = get_tree().get_root().get_camera() as Camera @@ -167,10 +177,18 @@ func _physics_process(delta : float) -> void: if dead: return - if entity.ai_state == EntityEnums.AI_STATE_OFF: + if entity.c_is_controlled: process_input(delta) process_movement_player(delta) else: + if sleep: + sleep_recheck_timer += delta + + if sleep_recheck_timer < 0.5: + return + + sleep_recheck_timer = 0 + if world != null: if not world.is_position_walkable(transform.origin): return @@ -319,7 +337,7 @@ func process_movement_mob(delta : float) -> void: if not moving and sleep: return - + if moving and sleep: sleep = false diff --git a/game/scenes/World.tscn b/game/scenes/World.tscn index 18b4682a..557b7319 100644 --- a/game/scenes/World.tscn +++ b/game/scenes/World.tscn @@ -61,7 +61,6 @@ max_frame_chunk_build_steps = 4 library = ExtResource( 2 ) level_generator = SubResource( 1 ) voxel_scale = 3.0 -chunk_spawn_range = 5 build_flags = 511 script = ExtResource( 8 )