Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

godot-state-machine-advanced

БесплатноЗапускает вложенные скриптыНе проверен

Expert blueprint for hierarchical finite state machines (HSM) and pushdown automata for complex AI/character behaviors. Covers state stacks, sub-states…

thedivergentaiот thedivergentai★ 1 019 звёзд на GitHub

Об этом скилле

Available Scripts

hsm_hierarchical_base.gd

Advanced HSM base delegator for propagating physics and input to sub-states.

hsm_pushdown_stack.gd

Professional Pushdown Automata for interruptive state (Pause/Menu) stacking.

hsm_state_context.gd

Decoupled context object pattern for passing persistent data between states.

hsm_transition_guard.gd

Expert transition validation logic to prevent illegal state changes.

hsm_animation_syncer.gd

Automated Logic-to-AnimationTree syncing with state-based travel logic.

hsm_concurrent_logic.gd

Orchestration for parallel state machines (e.g., Move + Attack).

hsm_resource_state_loader.gd

Data-driven state definition using custom Godot Resources (.tres).

hsm_reentry_aware_state.gd

Handling resume-from-stack logic vs fresh entry events.

hsm_state_history_logger.gd

Debug ring-buffer for tracking state transition history and stack depth.

hsm_state_timer_component.gd

Auto-transition component for finite states like Stun or Dash.

MANDATORY: For hierarchy / pushdown / guards read hsm_hierarchical_base.gd, hsm_pushdown_stack.gd, hsm_transition_guard.gd (plus hsm_logic_state.gd for leaf behaviors).

Decision Tree — Which Machine?

Need Choose MANDATORY scripts
Few exclusive states, no nesting Flat FSM hsm_logic_state.gd + thin parent
Nested sub-states (Move/Air/Attack children) HSM hsm_hierarchical_base.gd
Interrupt overlays (stun/menu/dialogue) then resume Pushdown hsm_pushdown_stack.gd + hsm_reentry_aware_state.gd
Parallel concerns (locomotion + weapon) Concurrent hsm_concurrent_logic.gd
Pick best action by score each tick Utility cost polling Expert pattern §3 + hsm_transition_guard.gd

NEVER Do (Expert State Rules)

Hierarchy & Delegation

  • NEVER forget to propagate physics/input to children — In an HSM, failing to call child.physics_update() from the parent's _physics_process orphans child logic.
  • NEVER use deep nesting (>3 levels) — Extreme hierarchy creates "State Spaghetti." If logic is that complex, consider a Behavior Tree or Utility AI.

Transitions & Lifecycle

  • NEVER call enter() without a preceding exit() — Skipping exit logic leaves timers, tweens, or audio loops running in the background, causing resource leaks.
  • NEVER modify state during a transition frame — Re-entrant transition_to() calls inside enter() cause recursion crashes. Use call_deferred if immediate sub-transitioning is required.
  • NEVER hardcode state names as strings — Typos like transition_to("Idel") are silent killers. Use class_name based checks OR Constants.

Architecture & Context

  • NEVER use global singletons for state data — Coupling states to GameManager.player_health makes them non-reusable. Pass a Context object.
  • NEVER push states indefinitely — In a Pushdown Automaton, every push_state MUST have a retirement plan (pop_state) to avoid stack overflow.
  • NEVER assume state re-entry is always a fresh start — Resuming from a stack pop should often bypass "Entry SFX/VFX"; use re-entry flags.

Implementation — Scripts Are Source of Truth

Do NOT copy inline HierarchicalState / push_state samples. Prior body double-exit()ed and ignored resume messages.

MANDATORY route:

Pushdown contract (from script — single exit, resume msg):

# See hsm_pushdown_stack.gd — do not reimplement
func push_state(state_path: String, msg: Dictionary = {}) -> void: ...
func pop_state() -> void:
    # old.exit(); stack.back().enter({"is_resume": true})
    pass

Expert State Machine Patterns

1. HSM Visualizer (Debug Tool)

Use a specialized Control node with _draw() to visualize the current state stack/hierarchy in the viewport for immediate debugging [3, 11].

class_name HSMVisualizer extends Contro
Полный SKILL.md на GitHub

Установить godot-state-machine-advanced в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/hsm-implementation-cookbook.mdreferences/migration-notes.mdscripts/hsm_animation_syncer.gdscripts/hsm_concurrent_logic.gdscripts/hsm_hierarchical_base.gdscripts/hsm_logic_state.gdscripts/hsm_pushdown_stack.gdscripts/hsm_reentry_aware_state.gdscripts/hsm_resource_state_loader.gdscripts/hsm_state_context.gdscripts/hsm_state_history_logger.gdscripts/hsm_state_timer_component.gdscripts/hsm_transition_guard.gdscripts/pushdown_automaton.gd

FAQ

Что делает скилл godot-state-machine-advanced?

Expert blueprint for hierarchical finite state machines (HSM) and pushdown automata for complex AI/character behaviors. Covers state stacks, sub-states, transition validation, and state context passing. Use when basic FSMs are insufficient OR implementing layered AI. Keywords state machine, HSM, hierarchical, pushdown automata, state stack, FSM, AI behavior.

Как установить скилл godot-state-machine-advanced?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл godot-state-machine-advanced запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить godot-state-machine-advanced с