From 6cd06193b53ac860499296dabe85f347f386cbd9 Mon Sep 17 00:00:00 2001 From: Derek Date: Fri, 4 Apr 2025 08:21:46 -0500 Subject: [PATCH] level bounds now don't error out on save/quit --- assets/realtime_day_night_cycle.tscn | 2 +- scripts/LevelManager.gd | 22 ++++++++++++---------- scripts/level_bounds.gd | 6 +++++- scripts/player.gd | 1 - scripts/realtime_day_night_cycle.gd | 2 +- scripts/scene_changer.gd | 3 +++ 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/assets/realtime_day_night_cycle.tscn b/assets/realtime_day_night_cycle.tscn index 8755a6d..a5e52aa 100644 --- a/assets/realtime_day_night_cycle.tscn +++ b/assets/realtime_day_night_cycle.tscn @@ -37,7 +37,7 @@ ssr_enabled = true ssao_enabled = true ssil_enabled = true sdfgi_enabled = true -sdfgi_energy = 3.0 +sdfgi_energy = 2.0 glow_enabled = true glow_intensity = 2.0 fog_mode = 1 diff --git a/scripts/LevelManager.gd b/scripts/LevelManager.gd index b2055db..b955fa4 100644 --- a/scripts/LevelManager.gd +++ b/scripts/LevelManager.gd @@ -60,15 +60,7 @@ func _ready(): else: refresh_scene() - #Spawn Crown - if GameGlobals.last_hit_path: - var crown_spawn = CROWN.instantiate() - var crown_target = get_node(GameGlobals.last_hit_path) - if crown_target: - crown_target.add_child(crown_spawn) - crown_spawn.position = Vector3(0,2,0) - if crown_target.is_in_group("enemy"): - crown_target.loot_amount = 10 + spawn_crown() #global randomize function randomize() @@ -104,7 +96,17 @@ func _ready(): func refresh_scene(): GameGlobals.health = gamemode.start_health - + +func spawn_crown(): + #Spawn Crown + if GameGlobals.last_hit_path: + var crown_spawn = CROWN.instantiate() + var crown_target = get_node(GameGlobals.last_hit_path) + if crown_target: + crown_target.add_child(crown_spawn) + crown_spawn.position = Vector3(0,2,0) + if crown_target.is_in_group("enemy"): + crown_target.loot_amount = 10 func gun_spawn(index): diff --git a/scripts/level_bounds.gd b/scripts/level_bounds.gd index 507d9fa..0f87f64 100644 --- a/scripts/level_bounds.gd +++ b/scripts/level_bounds.gd @@ -5,6 +5,8 @@ var level_collision_shapes : Array[CollisionShape3D] var check_collision = true func _ready() -> void: + SignalBus.player_exiting_tree.connect(player_exiting_tree) + for i in get_children(): if i is CollisionShape3D: level_collision_shapes.append(i) @@ -18,8 +20,10 @@ func _on_body_exited(body: Node3D) -> void: body.global_position = body.last_ground_pos + Vector3(0,10,0) func toggle_collision(collision_state): - print("COLLISION STATE: ",collision_state) check_collision = collision_state if level_collision_shapes != null and level_collision_shapes != []: for i in level_collision_shapes: i.disabled = collision_state + +func player_exiting_tree(): + toggle_collision(false) diff --git a/scripts/player.gd b/scripts/player.gd index 9de6e45..40dc3a6 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -138,7 +138,6 @@ var controlled_elsewhere = false @onready var motion_lines: ColorRect = $Head/Recoil/Camera3D/MotionLines @onready var moveable_holder: Node3D = $Head/Recoil/Camera3D/MoveableHolder @onready var stand_check: RayCast3D = $StandCheck -@onready var r_hand_test: MeshInstance3D = $Head/Recoil/Camera3D/WeaponHolder/RHandTest @onready var enemy_killed_audio: AudioStreamPlayer = $Audio/EnemyKilled @onready var footstep_sound: AudioStreamPlayer3D = $Audio/FootstepSound @onready var standing_collision: CollisionShape3D = $StandingCollision diff --git a/scripts/realtime_day_night_cycle.gd b/scripts/realtime_day_night_cycle.gd index 7b3523c..2698b10 100644 --- a/scripts/realtime_day_night_cycle.gd +++ b/scripts/realtime_day_night_cycle.gd @@ -18,7 +18,7 @@ func change_sun(): sun.rotation.x = sun_details["angle"] sun.rotation.y = north_offset sun.light_energy = sun_details["energy"] - moon.light_energy = (2 - sun_details["energy"]) * .5 + moon.light_energy = (2 - sun_details["energy"]) * .25 func sun_angle_from_time(): var time_dict = Time.get_time_dict_from_system() diff --git a/scripts/scene_changer.gd b/scripts/scene_changer.gd index f50e2d1..ad616ad 100644 --- a/scripts/scene_changer.gd +++ b/scripts/scene_changer.gd @@ -21,6 +21,9 @@ func _on_body_entered(body: Node3D) -> void: scene_holder.add_child(scene) scene.global_position = global_position + SCENE_SPAWN_OFFSET + var level_control = get_tree().current_scene + level_control.spawn_crown() + entered = true if active and entered: var spawned_stuff = scene_holder.get_children()