-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
The defining constraint: @chemicalluck/engine is game-agnostic and never imports game code.
A game plugs in entirely at build time, through generated Vite virtual modules. This is
what lets one engine power many games and keeps games upgradable.
The sim CLI runs two Vite plugins from the engine:
Scans the engine's features/ and your src/game/extensions/ by filename convention and
generates virtual modules:
-
virtual:game-extensions— aggregatesslice.ts,effects.ts,post-effects.ts,effect-hydrators.ts,initializer.ts,views.tsx, and (game-only)actions.tsintoslices,effectHandlers,postEffectHandlers,views,storeInitializers,actionGroupProviders. -
virtual:game-setup— generates theloadContent(...)call that wires eachdata/*.jsoninto the engine, driven by every feature'sfeature.jsonmanifest (content,contextSlots,contentExtensions,setup,contentSetup). -
virtual:conditions— merges each feature'sconditions.ts(evaluators, parsers, serializers) — the condition DSL vocabulary. -
virtual:references— merges each feature'sreferences.ts(id sources, reference providers, rewriters) — powerssim checkand the editor's integrity tools.
Generates virtual:editor-extensions from effect-editor.* / editor.* files and serves
the Content Editor SPA plus its file-backed data API.
Because discovery is convention-based, adding a feature or a data/*.json file participates
automatically — no central registry to edit.
main.tsx renders <GameEngine />, which:
- imports
virtual:game-extensionsand side-effect-importsvirtual:game-setup; - registers effect handlers, builds the Redux store from the collected slices, runs store initializers;
- merges views and picks the sidebar;
- renders the view manager.
Each engine feature under @chemicalluck/engine/features/<name>/ follows the same layout as an
Extensions: slice.ts, selectors.ts, effects.ts, types.ts,
components/, lib/, and a feature.json manifest declaring its content wiring. Features
and extensions are discovered by the same machinery — an extension is just a game-side
feature.
Three engine subsystems are open and grow by contribution rather than a fixed list:
-
Effects —
EffectMapis an open interface; a feature/extension augments it and registers a handler ineffects.ts. -
Conditions —
ConditionMap/ expression kinds; contributed viaconditions.ts. -
References — id sources and reference providers contributed via
references.ts, so validation and cascade-rename cover new content automatically.
@chemicalluck/engine ships as TypeScript source — your game's Vite process (via the CLI)
transpiles it. The engine's Node-side tooling (the two plugins) is compiled to JS so the
CLI can import it. The CLI aliases @chemicalluck/engine to the engine source directory so deep
imports and directory indexes resolve and the source is transformed normally.
Built with the sim framework · Edit these docs in docs/wiki/ and run docs/sync-wiki.sh.
sim
Building a game
Reference