This commit is contained in:
2026-01-21 23:40:20 +01:00
commit d1f8068081
478 changed files with 24902 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
extends Node
class_name EnemyState
signal Transitioned(state: EnemyState, new_state_name: String)
var enemy_ref: BaseEnemy
func Enter() -> void:
pass
func Exit() -> void:
pass
func Update(_delta: float) -> void:
pass
func Physics_Update(_delta: float) -> void:
pass
#Transition State by calling Transitioned.emit(self, "name of other state")

View File

@@ -0,0 +1 @@
uid://dvg03ta13bj84

View File

@@ -0,0 +1,46 @@
extends Node
class_name EnemyStateMachiene
@export var initial_state: EnemyState
@export var enemy_ref: BaseEnemy
var current_state: EnemyState
var states: Dictionary = {}
func _ready() -> void:
for child in get_children():
if child is EnemyState:
states[child.name.to_lower()] = child
child.Transitioned.connect(on_child_transition)
child.enemy_ref = enemy_ref
if initial_state:
initial_state.Enter()
current_state = initial_state
func _process(delta: float) -> void:
if not is_multiplayer_authority(): return
if current_state:
current_state.Update(delta)
func _physics_process(delta: float) -> void:
if not is_multiplayer_authority(): return
if current_state:
current_state.Physics_Update(delta)
func on_child_transition(state: EnemyState, new_state_name: String):
if state != current_state:
return
var new_state = states.get(new_state_name.to_lower())
if !new_state:
return
if current_state:
current_state.Exit()
new_state.Enter()
current_state = new_state

View File

@@ -0,0 +1 @@
uid://biujgdpsjonmi