Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions scenes/game_elements/characters/player/components/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ func defeat(falling: bool = false) -> void:
# Stop moving the player.
velocity = Vector2.ZERO

# Decrement lives and save the new count
GameState.decrement_lives()
GameState.state.player_state.decrement_lives()

if falling:
var tween := create_tween()
Expand All @@ -205,7 +204,7 @@ func defeat(falling: bool = false) -> void:
await get_tree().create_timer(2.0).timeout

# Check if player has lives remaining
if GameState.current_lives > 0:
if GameState.state.player_state.lives > 0:
# Still have lives - reload current scene/checkpoint
SceneSwitcher.reload_with_transition(Transition.Effect.FADE, Transition.Effect.FADE)
else:
Expand Down Expand Up @@ -237,11 +236,10 @@ func _on_abilities_changed() -> void:
_toggle_abilities()


## Handles game over logic: restarts from the beginning of the current challenge
## with lives reset to 3.
## Handles game over logic: restarts from the beginning of the current challenge,
## with lives reset.
func _handle_game_over() -> void:
# Reset lives to 3
GameState.reset_lives()
GameState.state.player_state.reset_lives()

# Get the start of the current challenge
var challenge_start_scene: String = GameState.get_challenge_start_scene()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func _ready() -> void:
talk_behavior.title = "have_threads" if _have_threads else "no_threads"
interact_area.interaction_ended.connect(self._on_interaction_ended)

if GameState.incorporating_threads:
if GameState.state.quest_state.incorporating_threads:
if Transitions.is_running():
await Transitions.finished

Expand All @@ -42,7 +42,6 @@ func _ready() -> void:
if elder:
await elder.congratulate_player()

GameState.set_incorporating_threads(false)
GameState.mark_quest_completed()


Expand All @@ -59,7 +58,7 @@ func _on_interaction_ended() -> void:
if not ProjectSettings.get_setting(ThreadbareProjectSettings.SKIP_SOKOBANS):
# Hide interact label during scene transition
interact_area.disabled = true
GameState.set_incorporating_threads(true)
GameState.state.quest_state.incorporating_threads = true
SceneSwitcher.change_to_file_with_transition(SOKOBANS.pick_random())
else:
GameState.mark_quest_completed()
Expand All @@ -73,7 +72,10 @@ func on_offering_succeeded() -> void:

func is_item_offering_possible() -> bool:
return (
GameState.current_quest
and GameState.current_quest.threads_to_collect > 0
and GameState.items_collected().size() >= GameState.current_quest.threads_to_collect
GameState.state.quest_state
and GameState.state.quest_state.quest.threads_to_collect > 0
and (
GameState.items_collected().size()
>= GameState.state.quest_state.quest.threads_to_collect
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func _ready() -> void:
if Engine.is_editor_hint():
return

if GameState.current_spawn_point == get_tree().current_scene.get_path_to(self):
if GameState.state.scene_state.spawn_point == get_tree().current_scene.get_path_to(self):
move_player_to_self_position()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func _ready() -> void:
if Engine.is_editor_hint():
return
initial_energy = light.energy
light.visible = GameState.lights_on
light.enabled = GameState.lights_on
light.visible = GameState.state.scene_state.lights_on
light.enabled = GameState.state.scene_state.lights_on
GameState.lights_changed.connect(_on_lights_changed)


Expand Down
Loading
Loading