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
44 lines
1.8 KiB
GDScript
44 lines
1.8 KiB
GDScript
extends Node
|
|
|
|
class_name State
|
|
|
|
#etat generique d'une StateMachine : il ne connait ni le joueur, ni le HUD, ni le jeu. Reutilisable pour un PNJ, un pokemon sauvage...
|
|
#pour le joueur, voir PlayerState (qui ajoute le joueur, l'input, les hints et les helpers de mouvement).
|
|
#
|
|
#un etat surcharge on_enter() / exit() / update() / physics_update() et demande ses transitions avec request_transition().
|
|
|
|
var actor : Node #le node pilote par la machine (CharacterBody3D, joueur, PNJ...), renseigne par enter()
|
|
var machine : StateMachine #renseigne par la StateMachine
|
|
|
|
#donnees echangees entre etats (renseignees par la StateMachine, jamais ecrites a la main dans un autre etat) :
|
|
var enter_data : Dictionary = {} #recues de l'etat precedent, lisibles dans on_enter() et ensuite
|
|
var outgoing_data : Dictionary = {} #envoyees a l'etat suivant par request_transition(), lisibles dans exit()
|
|
var next_state_name : String = "" #destination, renseignee avant exit() : exit() sait ou on va
|
|
|
|
#---------- cycle de vie ----------
|
|
|
|
func enter(new_actor : Node) -> void:
|
|
actor = new_actor
|
|
on_enter()
|
|
|
|
func on_enter() -> void: #a surcharger a la place de enter() : actor est deja assigne
|
|
pass
|
|
|
|
func exit() -> void:
|
|
pass
|
|
|
|
func update(_delta : float) -> void:
|
|
pass
|
|
|
|
func physics_update(_delta : float) -> void:
|
|
pass
|
|
|
|
#---------- transitions ----------
|
|
|
|
func request_transition(new_state_name : String, data : Dictionary = {}) -> bool:
|
|
#demande une transition et renvoie true seulement si elle a vraiment eu lieu
|
|
#(la StateMachine peut la refuser : etat bloque, etat inconnu, ou demande d'un etat qui n'est plus l'etat courant)
|
|
#data : transmise a l'etat suivant (enter_data), et lisible par exit() de celui-ci (outgoing_data)
|
|
if machine == null: return false
|
|
return machine.request(self, new_state_name, data)
|