feat(controllers): #57 foundation — ludic.gameplay package + lever 5 (disable system)
Shared building blocks for the builtin gameplay controllers (#57): the ludic.gameplay source package (Cooldown timer, Stats + timed modifier stack, Faction table, Combat damage pipeline with cancel/mutable hooks), plus the compiler `disable system <esys_fn>` extensibility lever. Deterministic, integer-only; C-free bootstrap fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
764a0296ce
commit
ed385efa7b
11 changed files with 18734 additions and 18157 deletions
|
|
@ -55,6 +55,7 @@ function emit_call_one(d: Node) -> void {
|
|||
# settled when the engine advances animation / accumulates light. Keep the
|
||||
# component list in sync with uses_engine_systems (emit_ecs.ludic).
|
||||
function emit_one_engine_system(comp: pointer, fn: pointer) -> void {
|
||||
if is_system_disabled(fn) { return } # lever 5 (#57): `disable system <fn>` drops the tick
|
||||
if (find_comp(comp) != null) and (find_fn(fn) != null) {
|
||||
emit(" call void @fn_"); emit(fn); emit("()\n")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ function emit_detach(st: Node) -> void {
|
|||
# flag). A bare `<Model>` / `<Handler>` flips a global enabled flag.
|
||||
function emit_toggle(st: Node) -> void {
|
||||
var val = "0"; if st.ival == 1 { val = "1" }
|
||||
if (st.ty != null) and (st.ty == "system") { return } # `disable system <fn>` is compile-time (handled in emit_one_engine_system); no runtime code
|
||||
if (st.ty != null) and (st.ty == "layer") { # enable/disable layer L
|
||||
emit(" store i32 "); emit(val); emit(", ptr @LE_"); emit(st.s); emit("\n")
|
||||
var lev = `layer_{st.s}_hide`; if st.ival == 1 { lev = `layer_{st.s}_show` } # public layer -> event
|
||||
|
|
|
|||
|
|
@ -348,6 +348,7 @@ function stmt_body() -> Node {
|
|||
var en = 0; if (t.text == "enable") { en = 1 }
|
||||
pi = pi + 1; let n = node(S_TOGGLE); n.ival = en
|
||||
if is_id("layer") { pi = pi + 1; n.ty = "layer"; n.s = eat_id(); note_toggled_layer(n.s); return n } # enable/disable layer L
|
||||
if is_id("system") { pi = pi + 1; n.ty = "system"; n.s = eat_id(); if en == 0 { push(g_disabled_sys, n.s) }; return n } # disable system <esys_fn> (lever 5, compile-time)
|
||||
n.s = eat_id() # `enable P on e` / `disable Model` / `disable Handler`
|
||||
if is_id("on") { pi = pi + 1; n.a = expr() } # property on an entity
|
||||
return n
|
||||
|
|
@ -459,6 +460,19 @@ var g_esys_fn: []pointer
|
|||
var g_esys_phase: []pointer
|
||||
var g_namespaces: []pointer
|
||||
|
||||
# lever 5 of the controller extensibility contract (#57): `disable system <fn>`
|
||||
# switches off exactly one engine-owned system (an esys_* registered via
|
||||
# @EngineSystem or the core seed) at compile time, so a game can carry a
|
||||
# well-known component but tick it with its own handler instead. Recorded at
|
||||
# parse time and read by emit_one_engine_system, which then skips that call
|
||||
# (byte-identical for any program that disables nothing).
|
||||
var g_disabled_sys: []pointer
|
||||
function is_system_disabled(fn: pointer) -> bool {
|
||||
var i = 0
|
||||
while i < len(g_disabled_sys) { if (g_disabled_sys[i] == fn) { return true }; i = i + 1 }
|
||||
return false
|
||||
}
|
||||
|
||||
# #62: package namespace registry — a package marks a Foo.* provider with
|
||||
# @Namespace(Foo); emit_ns_call aliases an otherwise-unknown Foo.method to the
|
||||
# bare function foo_method (lowercased namespace + "_" + method).
|
||||
|
|
@ -874,6 +888,7 @@ function parse_program() -> void {
|
|||
# emit order (SpriteAnim, Motion — Update; Light2D — Render), so a core game is
|
||||
# byte-identical; packages append via @EngineSystem.
|
||||
g_esys_comp = new []pointer; g_esys_fn = new []pointer; g_esys_phase = new []pointer
|
||||
g_disabled_sys = new []pointer
|
||||
push(g_esys_comp, "SpriteAnim"); push(g_esys_fn, "esys_spriteanim"); push(g_esys_phase, "Update")
|
||||
push(g_esys_comp, "Motion"); push(g_esys_fn, "esys_motion"); push(g_esys_phase, "Update")
|
||||
push(g_esys_comp, "Body"); push(g_esys_fn, "esys_move"); push(g_esys_phase, "Update")
|
||||
|
|
|
|||
36461
selfhost/ludicc.seed.ll
36461
selfhost/ludicc.seed.ll
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue