- Pinned both wrists to the rifle's real grip surfaces via a shared IK pass in every animation clip; hand bones follow the barrel and Fire recoil pivots the weapon/arms as one assembly. - Nudged the weapon forward so the stock clears the vest; made the generator reproducible (clears stale actions) and regenerated .blend, GLB and renders. - Added standalone level editor with JSON level data, validation and baking, plus editor docs and regression fixtures.
4.3 KiB
FBC: NIGHT SHIFT — Level Editor
The editor authors assets/levels/*.json, the single source of truth for the
playable floor. The game reads a JSON at runtime (cntrl --level <path>) and
falls back to the build-time baked copy (src/game/level_baked.hpp), which is
regenerated by level_tool --bake whenever the JSON changes.
Build and launch
cmake --build build -j6
./build/editor # assets/levels/floor01.json
./build/editor --level my_level.json --game ./build/cntrl
./build/editor --screenshot /tmp/editor.png # headless smoke capture
./build/editor --place plant 12.5 44 # debug: place an asset by name
--game sets the binary launched by Ctrl+P; without it the editor detects
./cntrl, ./build/cntrl or ../cntrl in that order. --place
selects the placed prop so its inspector fields can be inspected in a capture.
Controls
| Input | Action |
|---|---|
| LMB (Select) | Select nearest prop/wall/door/room/ritual/thermo/anchor; drag props |
| LMB (Wall / Door) | First click starts the span, second click finishes it |
| LMB (Decor) | Place the selected asset from the browser |
| LMB drag from browser | Place the selected asset at the drop point |
| RMB or Alt+LMB | Orbit |
| MMB | Pan |
| Wheel | Zoom (scrolls the asset browser over its panel) |
1–4 |
Select / Wall / Door / Decor tools |
Del / Backspace |
Delete the selection (anchors can only be moved) |
Ctrl+Z / Ctrl+Y / Ctrl+Shift+Z |
Undo / redo |
Ctrl+S |
Save to the current level path |
Ctrl+P |
Save if dirty, then launch cntrl --level <path> |
F |
Frame the whole level |
Tab |
Toggle the inspector |
Esc |
Quit |
Inspector field reference
The right-hand dock edits the current selection. Numeric fields are sliders, enums are combo boxes, booleans are check boxes and names/paths are text boxes. Edits share one undo step per interaction (one per drag or text-box focus).
| Selection | Fields |
|---|---|
| none (level) | name, map_width, map_height, scale |
| Prop | kind, pos, w, d, h, y offset, yaw deg, scale, model, room_kind, solid, destructible |
| Wall line | axis, coord, from, to, height, each gap's start/end, DEL GAP, OPEN SEGMENT GAP |
| Door | id, rect (x0/y0/x1/y1), height |
| Room | name, rect, kind, flow, side idx |
| Ritual | type, pos, radius, duration, ring radius, ring count, light radius, light mult, light dur |
| Thermo door | pos, span, yaw deg |
| Spawn / Key / Exit | pos; Key/Exit also their pickup/trigger radius |
Scale convention: scale is the multiplier passed straight to raylib's
DrawModelEx, identical to the game's presenter. w/d/h are metadata used for
selection boxes and (for solid props) collision. Deleting a wall segment
adds a gap to the wall line; gaps are normalized (clamped, sorted, merged) and
can be removed from the inspector to close a passage again.
Validation and baking
The validation readout at the top of the inspector is computed by
level::validate() (the same code level_tool --validate uses):
- gated doors are tested both open and closed; a main room reachable only through a gated door is an error, a gated side room is expected;
- solid props and walls both block the walkable-grid flood fill from spawn;
- spawn/key/exit must lie inside the map and outside walls;
- rooms must be reachable from spawn, key and exit too;
- duplicate door ids, duplicate ritual types, overlapping rooms, malformed gaps, missing/out-of-range numeric fields and missing model files are reported.
./build/level_tool --check assets/levels/floor01.json # round-trip + validation
./build/level_tool --validate assets/levels/floor01.json # validation only
./build/level_tool --bake <level.json> <baked.hpp> # refuses invalid levels
cmake --build build --target check_level
ctest --test-dir build --output-on-failure
Schema is version: 1; from_json accepts unknown optional fields but
rejects out-of-range values. New fields should default safely when absent.
Other tools
tools/blender/import_level.py reads the same JSON into a reviewable Blender
blockout (set CNTRL_LEVEL for a different file, CNTRL_OUT for a different
.blend output). tests/data/ holds a valid fixture and an intentionally
invalid one wired into CTest.