Compare commits
No commits in common. "66039b70d9a1b96abd0e161300ee120f72f8d695" and "5e46d7279058af19c8ad2c64d099f3c58f9f066d" have entirely different histories.
66039b70d9
...
5e46d72790
4 changed files with 5 additions and 38 deletions
|
|
@ -1,32 +0,0 @@
|
||||||
class_name PlayerState extends State
|
|
||||||
|
|
||||||
const IDLE = "Idle"
|
|
||||||
const WALKING = "Walking"
|
|
||||||
|
|
||||||
var player: Player
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
await owner.ready
|
|
||||||
player = owner as Player
|
|
||||||
assert(player != null, "The PlayerState state type must be used only in the player scene. It needs the owner to be a Player node.")
|
|
||||||
|
|
||||||
|
|
||||||
func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _exit() -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _handle_input(_event: InputEvent) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _state_update(_delta: float) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _state_physics_update(_delta: float) -> void:
|
|
||||||
pass
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://bebe1y51hwns8
|
|
||||||
|
|
@ -26,7 +26,7 @@ var is_active: bool = false:
|
||||||
|
|
||||||
## Called by the state machine upon changing the active state. The `data` parameter
|
## Called by the state machine upon changing the active state. The `data` parameter
|
||||||
## is a dictionary with arbitrary data the state can use to initialize itself.
|
## is a dictionary with arbitrary data the state can use to initialize itself.
|
||||||
@abstract func _enter(previous_state_path: String, data: Dictionary[StringName, Variant] = {}) -> void
|
@abstract func _enter(previous_state_path: String, data: Dictionary = {}) -> void
|
||||||
|
|
||||||
## Called by the state machine before changing the active state. Use this function
|
## Called by the state machine before changing the active state. Use this function
|
||||||
## to clean up the state.
|
## to clean up the state.
|
||||||
|
|
@ -48,7 +48,7 @@ func state_physics_update(delta: float) -> void:
|
||||||
_state_physics_update(delta)
|
_state_physics_update(delta)
|
||||||
|
|
||||||
|
|
||||||
func enter(previous_state_path: String, data: Dictionary[StringName, Variant] = {}) -> void:
|
func enter(previous_state_path: String, data: Dictionary = {}) -> void:
|
||||||
is_active = true
|
is_active = true
|
||||||
_enter(previous_state_path, data)
|
_enter(previous_state_path, data)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ func _get_initial_state() -> State:
|
||||||
|
|
||||||
## Transitions the active state out after receiving a finished signal.
|
## Transitions the active state out after receiving a finished signal.
|
||||||
func _transition_to_next_state(target_state_path: String, data: Dictionary[StringName, Variant] = {}) -> void:
|
func _transition_to_next_state(target_state_path: String, data: Dictionary[StringName, Variant] = {}) -> void:
|
||||||
print(owner.name+"+++ TRANSITION CALLED: ", target_state_path)
|
print("+++ TRANSITION CALLED: ", target_state_path)
|
||||||
print(owner.name+"+++ has node? ", has_node(target_state_path))
|
print("+++ has node? ", has_node(target_state_path))
|
||||||
print(owner.name+"+++ all children: ", get_children().map(func(c: Node) -> StringName: return c.name))
|
print("+++ all children: ", get_children().map(func(c: Node) -> StringName: return c.name))
|
||||||
|
|
||||||
assert(has_node(target_state_path), owner.name + ": Trying to transition to state " + target_state_path + " but it does not exist.")
|
assert(has_node(target_state_path), owner.name + ": Trying to transition to state " + target_state_path + " but it does not exist.")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue