Architecture Framework
🧠 Code-First FSM
The Hierarchical State Machine for Clean Game Architecture. Compatible with modern C# engines and Unity®.
Overview
Stop writing boolean flag spaghetti in your frame updates. This strictly typed framework lets you construct complex AI routines, character controllers, and game loops using nested states, event-driven transitions, and declarative conditions.
Key Features
- Hierarchical (HFSM): Nest sub-state machines inside parent states (e.g.
Grounded>Walk,Run,Crouch). - Pure C# Classes: Complete decoupling from engine-specific MonoBehaviour lifecycles for instant unit testability.
- Declarative Transitions: Define clear transition rules in one place without scattering state checks across multiple files.
- Zero Boilerplate: Rapidly prototype behaviors using lambda-based action states.
Code Preview
// 1. Define states in pure C# classes
var groundMachine = new StateMachine();
var jumpState = new HeroJumpState(_blackboard);
// 2. Declarative Transitions: Clean & readable
groundMachine.AddTransition(jumpState, () => Input.GetKeyDown(KeyCode.Space));
groundMachine.AddTransition(idleState, () => _blackboard.Velocity.magnitude < 0.1f);
// 3. Tick state cleanly in your main loop
groundMachine.OnTick(deltaTime);