Des changements de scènes sans bugs

du moins je l'espère!
This commit is contained in:
Thomas
2025-04-15 11:09:07 +02:00
parent 5e32ed4196
commit 9350825614
17 changed files with 278 additions and 97 deletions

View File

@@ -17,6 +17,7 @@ var humanInteractionTarget: Human = null
var interactionClueFor : Human
var interactionPaused= false
var kill_path_finder = false
var pause_everything = true
signal start_intracting
signal loadFromGameState
@@ -35,7 +36,8 @@ func face(whereToFace: Vector2) -> void:
last_facing_direction = (whereToFace - global_position).normalized()
func decideAction() -> void:
pass
if pause_everything:
return
func _unhandled_input(event: InputEvent) -> void:
if interactionPaused and interactionClueFor:
@@ -59,6 +61,10 @@ func _physics_process(delta):
if state_machine.get_current_node() == "grabing" or humanInteractionTarget != null :
velocity = Vector2(0,0);
if pause_everything:
velocity = Vector2(0,0);
# move the caracter
move_and_slide()
@@ -115,3 +121,12 @@ func _on_load_from_game_state() -> void:
emit_signal("loadFromGameState")
feetSound.play()
feetSound.stream_paused = true
func _on_pause_game() -> void:
pause_everything = true
func _on_resume_game() -> void:
pause_everything = false
_on_load_from_game_state()

View File

@@ -102,7 +102,6 @@ autoplay = true
bus = &"player_foot_step"
playback_type = 1
[connection signal="loadFromGameState" from="." to="controleur" method="_on_character_body_2d_load_from_game_state"]
[connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"]
[connection signal="area_entered" from="Area2D" to="controleur" method="_on_declencheur"]
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]

View File

@@ -26,10 +26,11 @@ func _unhandled_input(event: InputEvent) -> void:
human.velocityVector = Vector2(0, 0)
human.wants_to_grab = false
human.wants_to_interact_with = null
if human.pause_everything:
return
human.velocityVector = Input.get_vector("move_left", "move_right", "move_up", "move_down")
if human.velocityVector != Vector2(0, 0):
GameState.isUsingTouch = false
update_game_state()
if event.is_action_pressed("grab"):
if can_interact_with:
@@ -45,9 +46,15 @@ func _unhandled_input(event: InputEvent) -> void:
pathFinder.destination = get_global_mouse_position()
func update_game_state():
if human.pause_everything:
return
GameState.update_position(human.get_feet_global_position())
GameState.vec_last_facing_direction = human.last_facing_direction
func _process(delta) -> void:
if human.pause_everything:
return
update_game_state()
ray.target_position = human.last_facing_direction * 48
if human.last_facing_direction.y > 0 :
@@ -102,12 +109,11 @@ func _process(delta) -> void:
can_interact_with.enable_interaction_clue(human)
func _on_area_2d_body_entered(body: Node2D) -> void:
if human.pause_everything:
return
if body.has_method("do_trap") :
human.kill_path_finder = true
body.do_trap()
func _on_area_2d_body_exited(body: Node2D) -> void:
pass
func _on_character_body_2d_load_from_game_state() -> void:
human.set_feet_global_position(GameState.position_outside)