Tales-of-PKMN/game/player/states/inair_state.gd
TheThomaas 250976d170 Squashed commit of the following:
commit 8e7da96bfcd52b230feaf40fbc6d4a42b80c5723
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Sat Oct 17 18:55:14 2026 +0200

    Make state machine more reusable

commit 37da7248b8c33ce95cff7ef9332c5ccf6e3cd418
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Sat Oct 17 18:44:34 2026 +0200

    Change aim state into flag

commit fbb3a84a12e2cabff9b36390da7483b8de7e9379
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Sat Oct 17 18:33:08 2026 +0200

    Replace fixed references with ui references

commit 913955b13e9980780ac88761845d9e1f165f0d0e
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Fri Oct 16 13:32:21 2026 +0200

    Update camera action handling

commit 4ce0ac13ffea473cf62c2fefd1571e9df1fbbcaa
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Fri Oct 16 13:04:39 2026 +0200

    Update mounting system

commit e410eca38760955b2866eecd6ac0281e2041e76d
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Fri Oct 16 12:57:25 2026 +0200

    Update aiming system

commit 4c788df485ccbff5f91fd51d9f480e495f11da5f
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Thu Oct 15 21:50:26 2026 +0200

    Centralize states names into constants

commit 6059479c87d749e986a48adb520ef33121104da5
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Thu Oct 15 21:25:32 2026 +0200

    Refator Crouch state into flag

commit 08faec70e770042d36eed6f173a63f3aac1f67c6
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Wed Oct 14 10:19:35 2026 +0200

    Update player input management and state machine

commit 11a0aecc58c50c5862a03b4fd0b55e8db024031f
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Wed Oct 14 10:17:06 2026 +0200

    Delete charizard.tres

commit 399eac2b6c64f242a1c2e12360d811127f87681c
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Tue Oct 13 18:20:45 2026 +0200

    Remove unused MountedState

commit 42a3668c52fe96a7509a74290a94fc5a8084b713
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Tue Oct 13 18:18:08 2026 +0200

    Group grounded states under common class
2026-10-17 18:56:13 +02:00

38 lines
1.7 KiB
GDScript

extends AirborneState
class_name InairState
@export var jump_buffer_time : float = 0.15 #appui sur saut juste avant d'atterrir : le saut part a l'atterrissage si l'appui date de moins de ce delai (en secondes)
var _buffer_id : int = 0 #identifie le dernier appui bufferise, pour ne pas qu'un ancien minuteur annule un appui plus recent
func on_air_enter() -> void:
#saut coupe (bouton relache pendant la montee, voir JumpState) : on freine la montee, une seule fois
if player.has_cut_jump:
player.has_cut_jump = false
if player.velocity.y > 0.0: player.velocity.y *= player.jump_cut_multiplier
func handle_input() -> bool:
if !input.jump_pressed(): return false
#coyote jump : on vient de quitter le sol sans sauter, le saut reste permis un court instant
#saut en l'air : il en reste (nb_jumps_in_air_allowed)
var coyote : bool = player.coyote_jump_cooldown > 0.0
if coyote or player.nb_jumps_in_air_allowed > 0:
player.coyote_jump_on = coyote #lu par JumpState.jump() : le coyote jump ne consomme pas de saut en l'air
if request_transition(States.JUMP): return true
player.coyote_jump_on = false #saut refuse (ex : etat bloque) : on ne laisse pas le drapeau traîner
return false
buffer_jump() #plus de saut possible : on garde l'appui un instant pour l'atterrissage
return false
func buffer_jump() -> void:
#jump_buff_on est consomme par GroundedState a l'atterrissage (-> JumpState). Il est retire apres jump_buffer_time
#quel que soit l'etat dans lequel on se trouve, d'ou le minuteur du SceneTree et pas un compteur dans physics_update
player.jump_buff_on = true
_buffer_id += 1
var id : int = _buffer_id
await get_tree().create_timer(jump_buffer_time).timeout
if id == _buffer_id: player.jump_buff_on = false