feat(ecs): engine-owned systems auto-tick user components (#43)
Adds the ECS hook issues #43 and #47 named as their real dependency: a system the *engine* owns, inserted into the frame loop over a component a game merely declares and carries — no `handler` wired. - runtime/native/systems.ludic: esys_spriteanim (SpriteAnim frame advance: loop/once/pingpong) and esys_motion (Motion value tween: linear/in/out/ in-out), both on the by-name reflection ABI, integer + deterministic. - backend: emit_engine_systems_for_phase inserts the calls after every user handler in a phase (auto-loop and the drivable tick helpers alike); uses_engine_systems() drives the systems.ludic splice, the world-table force-emit, and makes a component-only game count as a systems game. - A game that declares neither component is byte-for-byte unchanged. Worked example + regression: examples/library/anim_ecs.ludic. Full suite 73 passed, self-host C-free bootstrap fixpoint intact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
9452557f3c
commit
b0143337d9
10 changed files with 15109 additions and 14658 deletions
|
|
@ -8,6 +8,10 @@ const MAX_ENT: int = 1024
|
|||
function has_systems() -> bool {
|
||||
var i = 0
|
||||
while i < len(prog) { if prog[i].kind == N_SYS { return true }; i = i + 1 }
|
||||
# a game with no hand-written handler but a well-known engine component still
|
||||
# runs a frame loop — the engine owns the system that ticks that component
|
||||
# (#43/#47). Treat it as a systems game so the loop / tick helpers are emitted.
|
||||
if uses_engine_systems() { return true }
|
||||
return false
|
||||
}
|
||||
function has_models() -> bool {
|
||||
|
|
@ -15,6 +19,19 @@ function has_models() -> bool {
|
|||
while i < len(prog) { if prog[i].kind == N_ARCH { return true }; i = i + 1 }
|
||||
return false
|
||||
}
|
||||
# does the program declare a well-known engine component? Each one is auto-ticked
|
||||
# by an engine-owned system (systems.ludic, wired in emit_engine_systems_for_
|
||||
# phase). Answering this drives the systems.ludic splice (parse.ludic) and the
|
||||
# reflection-ABI force-emit (emit_decl) — a game with none is byte-for-byte the
|
||||
# same as before the feature existed. Keep this list in sync with the phase table
|
||||
# in emit_engine_systems_for_phase.
|
||||
function uses_engine_systems() -> bool {
|
||||
if find_comp("SpriteAnim") != null { return true }
|
||||
if find_comp("Motion") != null { return true }
|
||||
if find_comp("Light2D") != null { return true }
|
||||
if find_comp("Occluder") != null { return true }
|
||||
return false
|
||||
}
|
||||
# N5: does the program have an `entry` block? A game with both handlers and an
|
||||
# `entry` drives its own loop (calling tick_fixed/tick_render), instead of the
|
||||
# compiler's auto frame loop. A game with handlers and no entry uses the auto-loop.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue