Practice manager respawns player on death

This commit is contained in:
Rob Kelly 2024-12-20 12:57:19 -07:00
parent 0952cd7486
commit 478b1e0849
5 changed files with 15 additions and 4 deletions

View File

@ -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:

View File

@ -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()

View File

@ -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)

View File

@ -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()

View File

@ -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: