diff --git a/src/player/shot_setup/shot_setup.gd b/src/player/shot_setup/shot_setup.gd index 2845738..c14fa85 100644 --- a/src/player/shot_setup/shot_setup.gd +++ b/src/player/shot_setup/shot_setup.gd @@ -426,7 +426,6 @@ func finish_death() -> void: print_debug("finishing death sequence") get_tree().paused = false player.die() - queue_free() func _set_club_type(new_club_type: Club.Type) -> void: @@ -530,6 +529,8 @@ func _process(delta: float) -> void: # REMOVEME if Input.is_action_just_pressed("ui_menu"): print("Debugging...") + if Input.is_action_just_pressed("debug_2"): + player.life -= 90 ## Visual updates # Rotation @@ -645,6 +646,7 @@ func _process(delta: float) -> void: phase = Phase.AIM Phase.DEAD: start_death() + phase = Phase.FINISHED func _on_ball_sleeping_state_changed() -> void: diff --git a/src/player/world_player.gd b/src/player/world_player.gd index 84faacb..7f9a7f7 100644 --- a/src/player/world_player.gd +++ b/src/player/world_player.gd @@ -101,6 +101,11 @@ func die() -> void: on_death.emit(self) +func deconstruct() -> void: + if is_instance_valid(shot_setup): + shot_setup.queue_free() + + ## Create a debug player instance static func create_debug() -> WorldPlayer: var instance := WorldPlayer.new() diff --git a/src/world/play_manager/practice_manager.gd b/src/world/play_manager/practice_manager.gd index 9d6a7ea..dd9278d 100644 --- a/src/world/play_manager/practice_manager.gd +++ b/src/world/play_manager/practice_manager.gd @@ -22,5 +22,6 @@ func on_turn_finished(_source: ShotSetup) -> void: func on_player_death(source: WorldPlayer) -> void: - # TODO game over screen - winner.emit(source) + # Respawn player + source.life = WorldPlayer.MAX_LIFE + spawning.emit(source) diff --git a/src/world/play_manager/round_robin_manager.gd b/src/world/play_manager/round_robin_manager.gd index 8eddaaf..c319f93 100644 --- a/src/world/play_manager/round_robin_manager.gd +++ b/src/world/play_manager/round_robin_manager.gd @@ -25,6 +25,7 @@ func on_player_death(player: WorldPlayer) -> void: on_turn_finished(player.shot_setup) players.erase(player) + player.deconstruct() print("Player 0 phase: ", ShotSetup.Phase.keys()[players[0].shot_setup.phase]) if len(players) == 1: on_win_condition() diff --git a/src/world/world.gd b/src/world/world.gd index d25e25c..718c763 100644 --- a/src/world/world.gd +++ b/src/world/world.gd @@ -31,6 +31,7 @@ func _ready() -> void: manager.winner.connect(_on_winner) manager.initialize() + if not manager.players: push_warning("Warning: Starting game world with no players!") @@ -51,7 +52,8 @@ func _spawn_player(player: WorldPlayer) -> void: var spawn_point := _random_spawn() var shot_setup := player.shot_setup shot_setup.global_transform = spawn_point.global_transform - spawn_point.add_sibling(shot_setup) + if not shot_setup.get_parent(): + spawn_point.add_sibling(shot_setup) func _on_winner(_player: WorldPlayer) -> void: