ft: nucleotide prey FSM

This commit is contained in:
djaidjai committed 2026-01-26 23:54:15 +01:00
1 parent c11afd9ddd
commit adf1438bc8
18 files changed
+121 -45

No files matched your search

-3
View File
@@ -1,9 +1,6 @@
extends NPC2D
class_name AbstractPrey2D
enum States {IDLE, FORAGING, FLEEING}
var state = States.IDLE
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
+4 -1
View File
@@ -10,7 +10,7 @@ class_name StateMachine extends Node
# Connect states on ready, then wait.
func _ready() -> void:
for node: State in find_children("*", "State"):
node.finished.connect(_transition_to_next_state)
node.finished.connect(transition_to_next_state)
await owner.ready
state.enter("")
@@ -37,3 +37,6 @@ func _transition_to_next_state(target_path: String, data: Dictionary = {}) -> vo
state.exit()
state = get_node(target_path)
state.enter(previous_state_path, data)
func transition_to_next_state(target: int, data: Dictionary = {}) -> void:
push_error("Child FSM failed to implement transition function.")
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.