class_name Action extends RefCounted # Action states enum State { PENDING, # Action is waiting to be executed RUNNING, # Action is currently executing COMPLETED, # Action has finished executing FAILED # Action failed during execution } # Public properties var state: int = State.PENDING var name: String = "Action" # Signals signal started() signal completed() signal failed(error_message) signal stopped() # Virtual methods to be implemented by subclasses func start() -> void: # Start executing the action # This method should be overridden by subclasses pass func update(delta: float) -> void: # Update the action (called every frame while running) # This method can be overridden by subclasses pass func is_completed() -> bool: # Check if the action has completed # This method should be overridden by subclasses return state == State.COMPLETED func stop() -> void: # Stop the action (if it's running) # This method can be overridden by subclasses if state == State.RUNNING: state = State.FAILED stopped.emit() # Helper methods func _set_running() -> void: # Set the action state to RUNNING and emit started signal state = State.RUNNING started.emit() func _set_completed() -> void: # Set the action state to COMPLETED and emit completed signal state = State.COMPLETED completed.emit() func _set_failed(error_message: String) -> void: # Set the action state to FAILED and emit failed signal state = State.FAILED failed.emit(error_message)