From a8a16dfdb8bcf6be4c34070c95f035c90876a776 Mon Sep 17 00:00:00 2001 From: antimundo Date: Sun, 17 Mar 2024 15:52:59 +0100 Subject: [PATCH] Allow playing game_world without gamemode selected --- scenes/game_world/game_world.gd | 9 +++++---- scenes/game_world/player_manager.gd | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/scenes/game_world/game_world.gd b/scenes/game_world/game_world.gd index a72cafd..6c4125d 100644 --- a/scenes/game_world/game_world.gd +++ b/scenes/game_world/game_world.gd @@ -7,10 +7,11 @@ var count_kills := 0 @onready var gameplay_ui = $CanvasLayer/GameplayUI func _ready() -> void: - timer.wait_time = Global.current_gamemode.time - - for target: int in range(Global.current_gamemode.initial_targets): - spawn_target() + if Global.current_gamemode: + timer.wait_time = Global.current_gamemode.time + + for target: int in range(Global.current_gamemode.initial_targets): + spawn_target() update_world_environment() func _process(_delta) -> void: diff --git a/scenes/game_world/player_manager.gd b/scenes/game_world/player_manager.gd index b61b3a2..f991836 100644 --- a/scenes/game_world/player_manager.gd +++ b/scenes/game_world/player_manager.gd @@ -30,16 +30,16 @@ func _input(event) -> void: rotate_y(deg_to_rad(-event.relative.x * mouse_sensitivity)) camera.rotate_x(deg_to_rad(-event.relative.y * mouse_sensitivity)) camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-MAX_CAMERA_ANGLE), deg_to_rad(MAX_CAMERA_ANGLE)) - if Global.current_gamemode.health == 0: + if Global.current_gamemode and Global.current_gamemode.health == 0: if event.is_action_pressed("shoot"): shoot(1) - if event.is_action_pressed("jump") and Global.current_gamemode.player_movement: + if event.is_action_pressed("jump") and ((Global.current_gamemode and Global.current_gamemode.player_movement) or Global.current_gamemode.is_empty()): jump() var elapsed: float func _process(delta): const COOLDOWN = .2 - if Global.current_gamemode.health > 0: + if Global.current_gamemode and Global.current_gamemode.health > 0: elapsed += delta if elapsed > COOLDOWN: if Input.is_action_pressed("shoot"): @@ -49,7 +49,7 @@ func _process(delta): handle_joypad_rotation(delta) func _physics_process(delta) -> void: - if Global.current_gamemode.player_movement: + if (Global.current_gamemode and Global.current_gamemode.player_movement) or Global.current_gamemode.is_empty(): handle_gravity(delta) var input := Input.get_vector("move_left", "move_right", "move_forward", "move_back") var movement_velocity := Vector3(input.x, 0, input.y) * SPEED