Skip to content
Snippets Groups Projects
Commit caea3d9a authored by Fabian Keßler's avatar Fabian Keßler
Browse files

Add max retries

parent 84677b46
No related branches found
No related tags found
No related merge requests found
......@@ -108,9 +108,14 @@ func _on_LockTimer_timeout() -> void:
if penguins.is_empty():
return
var tries = 0
var random_index: int = randi() % penguins.size()
while not is_instance_valid(penguins[random_index]) or penguins[random_index].is_queued_for_deletion():
random_index = randi() % penguins.size()
tries += 1
if tries > 10:
printerr("No valid penguins found. probably they are all dead but didnt sign off the pinguins group list")
return
var p = penguins[random_index]
self.target_penguin = p
......
......@@ -46,6 +46,15 @@ func unsuspend():
get_parent().remove_child(self)
position = new_position
ice_floe.add_child(self)
# if no ice floe: die
if not get_parent() is IceFloe:
Globals.pengu_group.n_penguins-=1
self.queue_free()
if(Globals.pengu_group.n_penguins<=0):
Globals.current_state=Globals.GAME_STATE.GAMEOVER
target = position
is_suspended = false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment