Repository navigation
fix(script_contract): derive built-ins from scene.builtins; add Emitter (#886) - #909
Conversation
…er (#886) The scripting contract kept its own hand-written list of scene built-ins and forgot `Emitter`, so `labelle_component_set("Emitter", ...)` returned -1 while every other authoring channel accepted it. `builtin_comps` is now derived from `scene.builtins.Builtin` with the enum's `shadowable` rule (Sprite/Shape unconditional; the rest defer to a project-registered component of the same name). Per-built-in behaviour (apply fn, get serialization, typed teardown) moves into exhaustive switches over `Builtin`, so a new tag fails to compile here until handled. Emitter set goes through the scene's `applyEmitter` (drive_particles opt-in) and resyncs a live ParticleSystem; remove releases it. New test/script_contract_builtins_test.zig iterates the enum (drift guard), covers Emitter set/get/remove + side-table resync, and the registered-Emitter shadowing rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Caqyi5Snr6yKssztYFztzZ
|
Warning Review limit reachedNext included review available in 35 minutes. View limit detailsLimit details: You’ve used the included review currently available. Your 101 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Closes #886.
Problem
src/script_contract.zigbuilt its set of scene built-ins from a hand-written list (Sprite, Shape, Tilemap, Camera, Image). It left outEmitter, solabelle_component_set("Emitter", …)fell through to the registry loop and returned-1, even though scenes,.zonand prefab refresh all accept it. This was the third site that listed built-ins by hand. #884 fixed the other two.Fix
builtin_compsis now derived fromscene.builtins.Builtin. It keeps the enum'sshadowablerule:Sprite/Shapeare always built-ins, andTilemap/Camera/Image/Emitterstep aside when the project registers a component with the same name. Each type comes fromBuiltin.Type(G).The code that differs per built-in is now written as exhaustive switches over
Builtin:setBuiltinComponent(which apply fn to call)builtinJsonInto(get serialization and the batch write-back)componentRemoveImplThe old
if (eql(name, "Sprite")) … elsechains are gone, so adding a tag toBuiltinwithout handling it here is a compile error.Emitter:applyEmitter, which also turns ondrive_particles.refreshParticleSystem, so a live pool picks up the new config.contract/labelle_script.hsupport table and the module docs now list Emitter. This is an additive change, so there is no version bump.Tests
New file
test/script_contract_builtins_test.zig, added tobuild.zig:scene.builtins.names. For each built-in it checks that set/get/has/remove work from a script and that the stored component is the engine's built-in type.drive_particlesgets turned on (onlyapplyEmitterdoes that), a get→set round-trip, the preset enum, and that malformed JSON returns -1 and leaves the entity untouched.setTimeScale(0)frees it immediately.Emitter, set/get/remove go to the registry type, the engine type never appears, anddrive_particlesstays off.How the tests were checked locally (Windows, Zig 0.16.0,
zig build test):Fake886toBuiltin. With noFake886Compdecl, the derivation fails to compile (a clear@compileError), and so doesentity_writer's switch. After addingFake886Compon Game, all three script_contract switches failed:switch must handle all possibilitiesat lines 1564 (set), 1589 (get JSON) and 1769 (remove)..Emitterin the derivation to reproduce it. The drift-guard test and both Emitter tests failed.origin/mainon this Windows machine (47 failed + 7 crashed on both, from tests that already fail on Windows: sockets andu64pid types). None of those failures are in the script contract tests.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.