Moved some event handling to the root state
This commit is contained in:
		
							parent
							
								
									9c9a3ecc26
								
							
						
					
					
						commit
						bcff3d172e
					
				|  | @ -141,8 +141,8 @@ event = &"Airborne" | |||
| [node name="Falling" type="Node" parent="StateChart/Root/Airborne"] | ||||
| script = ExtResource("6_8xdrw") | ||||
| 
 | ||||
| [connection signal="state_processing" from="StateChart/Root" to="." method="_on_root_state_processing"] | ||||
| [connection signal="state_processing" from="StateChart/Root/Grounded/Idle" to="." method="_on_idle_state_processing"] | ||||
| [connection signal="state_processing" from="StateChart/Root/Grounded/Moving" to="." method="_on_moving_state_processing"] | ||||
| [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Moving/Running" to="." method="_on_running_state_physics_processing"] | ||||
| [connection signal="state_physics_processing" from="StateChart/Root/Airborne/Jumping" to="." method="_on_jumping_state_physics_processing"] | ||||
| [connection signal="state_physics_processing" from="StateChart/Root/Airborne/Falling" to="." method="_on_falling_state_physics_processing"] | ||||
|  |  | |||
|  | @ -440,11 +440,6 @@ func _on_running_state_physics_processing(delta: float) -> void: | |||
| 	var target_velocity := Vector3(target_velocity_h.x, target_velocity_v, target_velocity_h.y) | ||||
| 	move(target_velocity, delta) | ||||
| 
 | ||||
| 	if Input.is_action_just_pressed("cc_jump"): | ||||
| 		state_chart.send_event("Jump") | ||||
| 	elif !grounded: | ||||
| 		state_chart.send_event("Airborne") | ||||
| 
 | ||||
| 
 | ||||
| func _on_falling_state_physics_processing(delta: float) -> void: | ||||
| 	var move_speed := run_speed | ||||
|  | @ -464,24 +459,21 @@ func _on_jumping_state_physics_processing(delta: float) -> void: | |||
| 	var target_velocity := Vector3(target_velocity_h.x, target_velocity_v, target_velocity_h.y) | ||||
| 	move(target_velocity, delta) | ||||
| 
 | ||||
| 	state_chart.send_event("Airborne") | ||||
| 
 | ||||
| 
 | ||||
| # TODO Rename sprint to crouch | ||||
| func _on_idle_state_processing(_delta: float) -> void: | ||||
| 	# !HACK - No deceleration. Just reset the target speed for now | ||||
| 	target_speed = 0.0 | ||||
| 
 | ||||
| 	if get_move_dir() != Vector2.ZERO: | ||||
| 
 | ||||
| func _on_root_state_processing(_delta: float) -> void: | ||||
| 	if get_move_dir() == Vector2.ZERO: | ||||
| 		state_chart.send_event("Idle") | ||||
| 	else: | ||||
| 		state_chart.send_event("Move") | ||||
| 	if Input.is_action_just_pressed("cc_sprint"): | ||||
| 		state_chart.send_event("Crouch") | ||||
| 	if Input.is_action_just_pressed("cc_jump"): | ||||
| 		state_chart.send_event("Jump") | ||||
| 
 | ||||
| 
 | ||||
| func _on_moving_state_processing(_delta: float) -> void: | ||||
| 	if get_move_dir() == Vector2.ZERO: | ||||
| 		state_chart.send_event("Idle") | ||||
| 	if Input.is_action_just_pressed("cc_sprint"): | ||||
| 		state_chart.send_event("Crouch") | ||||
| 	if !grounded: | ||||
| 		state_chart.send_event("Airborne") | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue