From 2759f14c2c102e55fb0e7cfbfe29fb64ca299369 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sun, 26 Jul 2026 16:21:51 +0100 Subject: [PATCH] =?UTF-8?q?feat(demo):=20Wave=205=20Lua=20demo=20game=20?= =?UTF-8?q?=E2=80=94=20scripted=204D=20gallery=20+=20trigger=20+=20HUD=20+?= =?UTF-8?q?=20audio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ship games/demo/: a real game directory the engine loads with no compiled game code, exercising the full Wave 5 scripting surface. Scene (games/demo/scenes/demo.ron): floor + six gallery primitives in a ring (tesseract, pentachoron, hexadecachoron, icositetrachoron, spherinder, duocylinder), each named + tagged ["gallery"], plus a central semi-transparent "trigger_zone" hypersphere and a player_spawn facing the ring. Lua scripts: - main.lua: on_init finds entities by name and builds rotators + the trigger zone + loads audio cues; on_update drives rotation, the pulse, the HUD, and the W-slide input indicator; on_fixed_update runs the trigger AABB tick; on_shutdown logs. Exposes gallery_count/trigger_enters/trigger_exits globals. - scripts/rotator.lua: per-entity 4D spin in W-involving bivector planes (XW/YW/ZW) so the 3D slice morphs, written back via entity:set("transform"). - scripts/trigger_zone.lua: 4D AABB enter/exit state machine + manual sine scale-pulse (TweenManager is not Lua-bound). - scripts/hud.lua: per-frame readout via hud.text/progress_bar/flash/screen_size. Audio: two tiny synthesized WAV cues (assets/blip.wav 15 KB, assets/tone.wav 20 KB) generated by assets/generate_cues.py (stdlib only). Played spatially at the zone; degrades to silent + logged when no audio device is available. Headless smoke (examples/demo_smoke.rs): loads the real scene + scripts and drives the Lua lifecycle against the live hecs::World, asserting 6 rotators are created, geometry is marked dirty, the tesseract rotation advances, and the trigger fires. Passes. Docs: games/demo/README.md (run + feature matrix + engine limitations), CHANGELOG Wave 5 entries, developer-guide demo run command fix, README quickstart demo command. Run: R4D_SCENE__PATH=games/demo/scenes/demo.ron cargo run -- --game games/demo Smoke: cargo run --example demo_smoke Quality gate: cargo test --workspace (slice_invariant 6/6, lua_ecs_bridge 4/4, 0 failures), clippy --workspace --all-targets -D warnings clean, fmt clean, demo_smoke PASS. Engine limitations worked around (documented in the report + demo README): no player-position binding (uses audio.get_listener_position as proxy), HUD bindings are render-stubs, TweenManager not Lua-bound, no slice-offset binding, scene path independent of --game. --- CHANGELOG.md | 3 + README.md | 6 + docs/developer-guide.md | 13 ++- examples/demo_smoke.rs | 171 ++++++++++++++++++++++++++++ games/demo/README.md | 140 +++++++++++++++++++++++ games/demo/assets/blip.wav | Bin 0 -> 15478 bytes games/demo/assets/generate_cues.py | 78 +++++++++++++ games/demo/assets/tone.wav | Bin 0 -> 19888 bytes games/demo/config.toml | 32 ++++++ games/demo/main.lua | 146 ++++++++++++++++++++++++ games/demo/scenes/demo.ron | 124 ++++++++++++++++++++ games/demo/scripts/hud.lua | 65 +++++++++++ games/demo/scripts/rotator.lua | 56 +++++++++ games/demo/scripts/trigger_zone.lua | 96 ++++++++++++++++ 14 files changed, 928 insertions(+), 2 deletions(-) create mode 100644 examples/demo_smoke.rs create mode 100644 games/demo/README.md create mode 100644 games/demo/assets/blip.wav create mode 100644 games/demo/assets/generate_cues.py create mode 100644 games/demo/assets/tone.wav create mode 100644 games/demo/config.toml create mode 100644 games/demo/main.lua create mode 100644 games/demo/scenes/demo.ron create mode 100644 games/demo/scripts/hud.lua create mode 100644 games/demo/scripts/rotator.lua create mode 100644 games/demo/scripts/trigger_zone.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d39dc8..ec377ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,9 @@ Conventional Commits. - Project skills for 4D geometry, headless visual verification, and production readiness. - Shape catalog documentation (`docs/shapes.md`). +- **Wave 5 — scripting + audio integration:** `ScriptSystem` (`src/systems/script.rs`) owns a `ScriptEngine` and an optional `AudioEngine4D`, drives `on_init` / `on_update` / `on_fixed_update` / `on_shutdown` from the app loop, and runs a fixed-step accumulator. `update` runs before `SimulationSystem` so scripts set velocities/transforms before physics. `AppConfig` gains `GameConfig` + `AudioConfig`; `--game ` overrides the game directory. Audio and scripting both degrade gracefully (silent / disabled) when no device / no game dir is configured. +- **Wave 5 — real Lua ECS bridge:** `world.spawn` / `query` / `find_by_name` / `get` / `set` / `despawn` / `entity_count` operate on the live `hecs::World` via a per-call `WorldRef` registered into `app_data` for the duration of each callback. Component access dispatches through an explicit name registry (`name` / `tags` / `transform` / `material` / `dirty` / `shape` / `physics_body` / `parent` / `children`). Input bindings read a per-frame `InputSnapshot`; audio bindings call the live `AudioEngine4D` via an `AudioRef`. `tests/lua_ecs_bridge.rs` guards the bridge. +- **Wave 5 — Lua demo game (`games/demo/`):** a shipped game directory with no compiled game code, exercising the full scripting surface — scripted 4D rotation in W-involving planes, a 4D-AABB trigger zone with a spatial audio cue + HUD flash + manual sine scale-pulse, a HUD readout, and synthesized WAV cues. Run with `R4D_SCENE__PATH=games/demo/scenes/demo.ron cargo run -- --game games/demo`; headless smoke via `cargo run --example demo_smoke`. ### Changed diff --git a/README.md b/README.md index 2efba70..8ef5279 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,12 @@ cargo run --release # Or try an example cargo run --example 01_hello_tesseract + +# Run the Lua demo game (Wave 5): a scripted 4D gallery with a trigger zone, +# HUD, spatial audio cue, and tweens — no compiled game code. +R4D_SCENE__PATH=games/demo/scenes/demo.ron cargo run -- --game games/demo +# Headless smoke for the demo (no window/GPU/audio): +cargo run --example demo_smoke ``` On NixOS (or with Nix installed), use the dev shell — it provides the Rust diff --git a/docs/developer-guide.md b/docs/developer-guide.md index f03d0c8..8b1c8b6 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -598,12 +598,21 @@ operate on the real `hecs::World` via an explicit component-name registry ```bash cargo run -- --game games/trivial # lifecycle smoke test -cargo run -- --game games/demo # full demo (Wave 5 Phase 3) +# Full demo (Wave 5 Phase 3) — the demo ships its own scene, so point the +# scene path at it via env (the scene path is independent of --game): +R4D_SCENE__PATH=games/demo/scenes/demo.ron cargo run -- --game games/demo +# Headless smoke (no window/GPU/audio) drives the real Lua lifecycle: +cargo run --example demo_smoke ``` `--game ` overrides `[game].game_dir` in `config/default.toml`. The engine loads `/main.lua`; `require()` resolves modules relative to -the game directory. +the game directory. The scene is loaded from `[scene].path` (default +`scenes/default.ron`), which is independent of `--game`, so a game that ships +its own scene points the path at it via `R4D_SCENE__PATH` (or `config/user.toml`). +See `games/demo/README.md` for the full feature matrix and engine limitations +the demo works around (no player-position binding, HUD render-stubs, +TweenManager not Lua-bound). ### Marching Tetrahedra diff --git a/examples/demo_smoke.rs b/examples/demo_smoke.rs new file mode 100644 index 0000000..0d645e4 --- /dev/null +++ b/examples/demo_smoke.rs @@ -0,0 +1,171 @@ +//! Headless smoke test for the Wave 5 Lua demo game (`games/demo`). +//! +//! Loads the real demo scene + scripts and drives the Lua lifecycle +//! (`on_init` / `on_update` / `on_fixed_update`) against the live `hecs::World` +//! the same way `ScriptSystem` does — but without a window, GPU, or audio +//! device. This proves the demo's Lua loads, the scene entities are found by +//! name, the gallery rotators mutate transforms (geometry dirty), and the +//! trigger zone fires on enter. +//! +//! Run with: +//! cargo run --example demo_smoke +//! cargo run --example demo_smoke -- --frames 600 +//! +//! Audio is unavailable headless, so `audio.get_listener_position()` reads as +//! the zero vector — the player is therefore "inside" the central zone (which +//! is centered on the origin), and the trigger-enter path fires on the first +//! fixed update. That is the expected headless behaviour; see the demo-game +//! report's "Engine limitations" section. + +use std::env; + +use rust4d_core::{ActiveScene, Scene, Transform4D}; +use rust4d_scripting::{InputSnapshot, ScriptConfig, ScriptEngine}; + +/// Fixed timestep used by `ScriptSystem` (1/60 s). +const FIXED_DT: f32 = 1.0 / 60.0; + +fn main() { + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")) + .format_timestamp(None) + .init(); + + let args: Vec = env::args().collect(); + let frames: u32 = args + .iter() + .position(|a| a == "--frames") + .and_then(|idx| args.get(idx + 1)) + .and_then(|v| v.parse::().ok()) + .unwrap_or(240); + + // --- Load the demo scene into a live World (no physics player body; the + // app creates that separately and the demo scripts don't need it). --- + let scene = Scene::load("games/demo/scenes/demo.ron") + .expect("failed to load games/demo/scenes/demo.ron — run from the repo root"); + let active = ActiveScene::from_template(&scene, None); + let entity_count = active.world.entity_count(); + let scene_name = active.name.clone(); + let mut world = active.world; // take ownership; World is not Clone + log::info!( + "[smoke] demo scene '{}' loaded with {} entities", + scene_name, + entity_count + ); + + // --- Load the demo game scripts. --- + let config = ScriptConfig { + scripts_dir: "games/demo".to_string(), + hot_reload: false, + ..Default::default() + }; + let mut engine = ScriptEngine::new(config).expect("ScriptEngine init failed"); + engine.load_game().expect("demo load_game failed"); + + // --- on_init --- + engine.set_world(&mut world); + engine.call_init().expect("demo on_init errored"); + let init_dirty = engine.clear_world(); + log::info!("[smoke] on_init geometry_dirty={}", init_dirty); + + // Sanity: the scripts should have found the gallery + trigger entities. + let rotator_count: i64 = engine + .lua() + .load("return gallery_count") + .eval() + .expect("read gallery_count"); + assert!( + rotator_count == 6, + "expected 6 gallery rotators, got {}", + rotator_count + ); + log::info!("[smoke] rotators created: {}", rotator_count); + + // --- Drive the loop: update + fixed-update per frame. --- + let input = InputSnapshot::new(); + let mut any_dirty = false; + for f in 0..frames { + engine.set_world(&mut world); + engine.set_input(&input); + + engine + .call_update(FIXED_DT) + .expect("demo on_update errored"); + engine + .call_fixed_update(FIXED_DT) + .expect("demo on_fixed_update errored"); + + let dirty = engine.clear_world(); + engine.clear_input(); + any_dirty = any_dirty || dirty; + + // Log a heartbeat every ~2 seconds of simulated time. + if f > 0 && f % 120 == 0 { + let enters: i64 = engine + .lua() + .load("return trigger_enters") + .eval() + .expect("read trigger_enters"); + log::info!( + "[smoke] frame {} entity_count={} trigger_enters={}", + f, + world.entity_count(), + enters + ); + } + } + + // --- Assertions: the demo actually did something. --- + let enters: i64 = engine + .lua() + .load("return trigger_enters") + .eval() + .expect("read trigger_enters"); + assert!( + enters >= 1, + "trigger should have entered at least once headless (listener at origin = inside zone); got {}", + enters + ); + + assert!( + any_dirty, + "scripts should have flagged geometry_dirty by setting transforms" + ); + + // A gallery entity's rotation should have advanced away from identity. + let tesseract = world + .get_by_name("tesseract") + .expect("tesseract entity should exist"); + let tx = *world + .ecs() + .get::<&Transform4D>(tesseract) + .expect("tesseract should have a transform"); + let rotor = tx.rotation; + let identity = rotor.s == 1.0 + && rotor.b_xw == 0.0 + && rotor.b_xy == 0.0 + && rotor.b_xz == 0.0 + && rotor.b_yz == 0.0 + && rotor.b_yw == 0.0 + && rotor.b_zw == 0.0 + && rotor.p == 0.0; + assert!( + !identity, + "tesseract rotation should have advanced past identity after {} frames", + frames + ); + log::info!( + "[smoke] tesseract rotor after run: s={:.4} b_xw={:.4}", + rotor.s, + rotor.b_xw + ); + + // --- on_shutdown --- + engine.call_shutdown().expect("demo on_shutdown errored"); + + log::info!( + "[smoke] PASS: {} frames, trigger_enters={}, geometry_dirty={}, rotation advanced", + frames, + enters, + any_dirty + ); +} diff --git a/games/demo/README.md b/games/demo/README.md new file mode 100644 index 0000000..8d7831d --- /dev/null +++ b/games/demo/README.md @@ -0,0 +1,140 @@ +# Rust4D — Lua Demo Game (Wave 5, Phase 3) + +A scripted 4D demo shipped as a **pure game directory** — no compiled game +code. The engine binary loads `games/demo/` via `--game`, runs `main.lua`, and +the demo drives the scene with the Lua scripting surface Wave 5 integrated into +the app loop. + +It is a *vertical slice* proving the engine/game split: scripting, ECS bridge, +4D math, input, audio, HUD, trigger zones, and tweens — all from Lua, on top of +a polished renderer (fragment-space checkerboard floor, wgpu 25). + +## Run + +From the repo root: + +```sh +R4D_SCENE__PATH=games/demo/scenes/demo.ron \ + nix develop --command cargo run -- --game games/demo +``` + +* `--game games/demo` points the engine at this game directory (sets + `GameConfig.game_dir`; scripts resolve from `games/demo/`). +* `R4D_SCENE__PATH` selects the demo scene. The engine loads the scene from + `[scene].path` (default `scenes/default.ron`), which is independent of + `--game`, so the demo ships its scene at `games/demo/scenes/demo.ron` and + points the scene path at it via the env var. `config/default.toml` is left + unchanged so `cargo run` still boots the default scene. + +### Headless smoke test (no window/GPU/audio) + +```sh +nix develop --command cargo run --example demo_smoke +nix develop --command cargo run --example demo_smoke -- --frames 600 +``` + +This loads the real scene + scripts, drives `on_init` / `on_update` / +`on_fixed_update` against the live `hecs::World`, and asserts the gallery +rotators advance, geometry is marked dirty, and the trigger zone fires. Audio is +unavailable headless, so the audio listener reads as the origin (inside the +central zone) and the trigger-enter path fires on the first fixed update — the +expected headless behaviour. + +## What it demonstrates + +A floor, six 4D primitives in a ring, and a central **trigger zone**: + +* **Scripted 4D rotation** — each gallery primitive is found by name and rotated + every frame in a W-involving bivector plane (`XW` / `YW` / `ZW`) via + `Rotor4.from_plane`, so the 3D slice morphs as the shape spins. Rotation is + written back with `entity:set("transform", …)`; `geometry_dirty` propagates + so the render cache rebuilds and motion is visible. +* **Trigger zone** — `on_fixed_update` runs a 4D AABB containment check + (player vs the zone center). On **enter** it fires a spatial audio cue, a HUD + flash, and a scale pulse on the zone entity; on **exit** it plays a low tone + and resets the scale. +* **HUD** — `on_update` draws a readout: player 4D position, W-slide indicator, + entity count, trigger state + status bar, and controls. (See *Limitations* + below re. on-screen rendering.) +* **Audio** — two tiny synthesized WAV cues (`assets/blip.wav`, + `assets/tone.wav`) played spatially at the zone position. Synthesized from + pure math with the Python stdlib — see `assets/generate_cues.py`. Degrades to + silent + logged when no audio device is available. +* **Tween** — the zone's enter pulse is a manual sine + (`scale = base * (1 + 0.3*sin(t))`). The engine's `TweenManager` is not + exposed to Lua, so the pulse is implemented by hand in + `scripts/trigger_zone.lua`. +* **Input** — `input.is_key_pressed("Q"/"E")` drives the W-slide HUD indicator, + showing the live input binding works end-to-end. + +## Controls + +| Input | Action | +|-------|--------| +| `W` `A` `S` `D` | Move (3D, handled by the engine) | +| `Q` / `E` | Slide along the W axis | +| Mouse | Look (capture toggles on click) | +| Scroll | Adjust the slice hyperplane offset | +| `Esc` | Release / recapture cursor | +| `R` | Reset camera | +| Walk to the ring center | Trigger the zone | + +## Files + +``` +games/demo/ +├── main.lua # entry point: on_init/update/fixed_update/shutdown +├── scripts/ +│ ├── rotator.lua # per-entity 4D spin (W-involving planes) +│ ├── trigger_zone.lua # 4D AABB detection + scale pulse +│ └── hud.lua # per-frame HUD readout +├── scenes/ +│ └── demo.ron # floor + 6-primitive ring + central trigger zone +├── assets/ +│ ├── blip.wav # synthesized enter cue (880 Hz, 0.35 s, 15 KB) +│ ├── tone.wav # synthesized exit cue (220 Hz, 0.45 s, 20 KB) +│ └── generate_cues.py # regenerates the WAVs (stdlib only) +├── config.toml # reference config (see header comment) +└── README.md # this file +``` + +## Engine features exercised + +| Feature | Binding used | Where | +|--------|--------------|-------| +| ECS bridge | `world.find_by_name`, `entity:get/set("transform")`, `world.entity_count` | `main.lua`, `rotator.lua`, `trigger_zone.lua` | +| 4D math | `Rotor4.from_plane`, `Rotor4.identity` | `rotator.lua`, `trigger_zone.lua` | +| Input | `input.is_key_pressed` | `main.lua` | +| Audio | `audio.load_sound`, `audio.play_oneshot_spatial`, `audio.get_listener_position` | `main.lua` | +| HUD | `hud.text`, `hud.progress_bar`, `hud.flash`, `hud.screen_size` | `hud.lua` | +| Logging | `log.info` | all scripts | + +## Engine limitations hit (documented, not worked around) + +1. **No player/camera-position binding.** Lua has no direct way to read the + camera or player body position. The demo uses `audio.get_listener_position()` + as the player-position proxy — `ScriptSystem` updates the audio listener to + the camera position each frame. It is one frame stale, which is negligible + for a trigger. When audio is unavailable (headless), the listener reads as + the zero vector. +2. **HUD bindings are render-stubs.** `hud.*` calls are API-complete but only + log at `trace` level; they are not wired into the render `HudContext`, so the + HUD is not visibly drawn yet. The calls exercise the full API so a future + wave that plugs a `HudContext` into `ScriptSystem::update` makes them visible + with no script changes. +3. **`TweenManager` is not Lua-bound.** The pulse is a manual sine. +4. **No slice-offset binding.** The camera's slice offset (`get_slice_w()`) is + not exposed to Lua, so the HUD shows the player W-position instead. +5. **Spawn-from-Lua does not support `shape` components.** Visible geometry is + placed in the RON scene; Lua only rotates/recolors it. (Per the Wave 5 + engine-integration report.) +6. **Physics raycast/query bindings are stubs.** Trigger detection uses + `world.query`-style AABB math in Lua instead. (Per the report.) + +See `scratchpad/reports/2026-07-26-wave-5-demo-game.md` for the full report. + +## Related + +* Wave 5 plan: `scratchpad/plans/2026-07-26-wave-5-polish-demos.md` (Phase 3) +* Engine integration report: `scratchpad/reports/2026-07-26-wave-5-engine-integration.md` +* Render polish report: `scratchpad/reports/2026-07-26-wave-5-render-polish.md` \ No newline at end of file diff --git a/games/demo/assets/blip.wav b/games/demo/assets/blip.wav new file mode 100644 index 0000000000000000000000000000000000000000..4d0bdc0d645bac110dc5cd4528b4b251888a5484 GIT binary patch literal 15478 zcmWFXbaTtIVPFV%40BD(Em06)U|?WmU}R7VV_v!@$76z$5%b zCDUYy!zGVGA9wEzR}*VL-DxrsTz|inJz0Hu<NzLruHoZacl?ydJuQSxe~sl4aoW{>kz@;F`^e<$JBR$86QuQMCWasf?RNuP*&b z;Qy*nX7JW#lIv~HHqYrU3DzZgOXS}0Wc_k^G4FcQ$&35Uc1UiUvt#Q1$)}#*So!ko zZv(!y^4j{Ft!rKWc)a%Ta!Iv5t>-R(k+=DG!^;;pj-C3o-)QH}ZNfWu@6R}uedF1S z^S{`5v*aG@R$FB_%Xs*D{B%yWmeqeEzmaeHpKY)7Zn2+HKB&KI*7n|=&-Oc>`gUFO z#kHRgxwU2I>$qBmI9a=|bzkC~Xq~BFqtMO2?C;Chg}2?#dL7c)9lL{bm*@fcQ?1tv zpFjF>fa`;FthRuKgJYx{x4XA=wiAA%bhQr;`y|8il+QI&lgc1_&9`@r>+ zq1UpXYJ96@kC0fUUT4B?x7JzARnJMuI?Z6I(jKAJj4dC+A81^J zom_HN_etTGOjZstXH|8hC)N)g_dCZszOp)QFjLt?q@Q`)r_GPLu1KAfImoxyaBt(m zohO5@PJcY_b2`g&5mA+Y23M?pI|w*`b~s`6!GK%kg-8|4iO+W)Z@X%7O7h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y{ zmp@bg#{RSWugxIF_?~eElLhl+=B>A#(#c>Zw%)cJD4PyE14HE_cOaNA7zqc@?p$kX#T(W-_5^D(WUgjodJLcm|%1p70O$_t@ANu$6Z{Xj{e>(q^ z{h9OU$Dh`}mj5{azx;oaVIE@y(_5w>=4R$NF|!5p2__w;JjNLeyZ=A@C;2b`@B2Rs z{&WELXW5_Me;WSk{QLIr;{UY_^^BHG=b0>+^O$p(O_)zG88DSHE@n9K|NTFWfAxR= z{#o;9;-58t{{E@^tN!opzoY->GZZjtG96&jW=>{KWj0_w!DPZz%eao=>i>WL%>VWM z<^H?l&#XV2{`~(_^H=fTlYcw^Ph?1Blw#V%B*z@d9Luc3e1ge>sfBR|!=wK^|K0!1 z{VVzR$e+c3cKl)dTlH7w-|c^E|2H!PF>*64W)fufV-921U_QZQ&D70!h~eFT>HlH> zR{vH1d*RQTKYRZ$|E>Hh{_pa?MgPkfoEiTxPGw?Yc4qctR$)HQWXCj#@eISS|C;|( Z{_Xl}`uEPCt$&XEVf$P0SLomAe*pcXPL==w literal 0 HcmV?d00001 diff --git a/games/demo/assets/generate_cues.py b/games/demo/assets/generate_cues.py new file mode 100644 index 0000000..4e7487b --- /dev/null +++ b/games/demo/assets/generate_cues.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +"""Generate the two tiny CC0 WAV cues for the Rust4D Lua demo. + +Run once to (re)create the committed assets: + + python3 games/demo/assets/generate_cues.py + +Produces: + * blip.wav — a short 880 Hz sine "enter" cue with a fast exponential decay + * tone.wav — a low 220 Hz sine "exit" cue with a soft envelope + +Both are 22050 Hz mono, ~0.4 s, well under 50 KB, public-domain (synthesized +from a pure math function — no third-party audio). Uses only the Python stdlib +(`wave`, `struct`, `math`) so it runs anywhere Python 3 does. +""" + +import math +import struct +import wave +from pathlib import Path + +RATE = 22050 # Hz, mono +AMPLITUDE = 0.6 # 0..1 + +def write_wav(path: Path, samples: list[float]) -> None: + with wave.open(str(path), "w") as w: + w.setnchannels(1) + w.setsampwidth(2) # 16-bit + w.setframerate(RATE) + frames = b"".join( + struct.pack(" list[float]: + """880 Hz sine, 0.35 s, fast exponential decay (bright 'enter' ping).""" + dur = 0.35 + n = int(RATE * dur) + freq = 880.0 + out = [] + for i in range(n): + t = i / RATE + env = math.exp(-t * 9.0) # quick decay + out.append(AMPLITUDE * env * math.sin(2.0 * math.pi * freq * t)) + return out + +def tone() -> list[float]: + """220 Hz sine, 0.45 s, soft attack + release (mellow 'exit' tone).""" + dur = 0.45 + n = int(RATE * dur) + freq = 220.0 + attack = 0.02 + release = 0.18 + out = [] + for i in range(n): + t = i / RATE + if t < attack: + env = t / attack + elif t > dur - release: + env = max(0.0, (dur - t) / release) + else: + env = 1.0 + # Slight decay through the sustain for warmth. + env *= math.exp(-t * 2.5) + out.append(AMPLITUDE * 0.8 * env * math.sin(2.0 * math.pi * freq * t)) + return out + +def main() -> None: + out_dir = Path(__file__).resolve().parent + out_dir.mkdir(parents=True, exist_ok=True) + write_wav(out_dir / "blip.wav", blip()) + write_wav(out_dir / "tone.wav", tone()) + for name in ("blip.wav", "tone.wav"): + p = out_dir / name + print(f"wrote {p} ({p.stat().st_size} bytes)") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/games/demo/assets/tone.wav b/games/demo/assets/tone.wav new file mode 100644 index 0000000000000000000000000000000000000000..22b366d3013a81fe6d3eb81395253be0d39b1247 GIT binary patch literal 19888 zcmWFXbaPwb%fJxs80MOmTcRMqz`(%Bz{sE!#=zjRhJk^JL4YA8u_Up@mw^Gq<6sbG zP-ZY=@MFki=ww*UaDm|`g9>8+V?E<~#s`doOioNCOiP$9Gcho0GY2zQGS6b(!F-AN zIrDdBCKh%UHkSX)ADQnmA7Wm}T*2(gEX;h3X%dq=(|5)NjLwV?7%CZf80P#}|G(~^ z@xQHqP5*BGWB6zNZ@u5^ei{7Q^3&$$@gEUC-hS`=uKoS$x3+H%-(_#> zX{K z2?hyT3knHd6X+1o5ZKCZz(0%c6R#z20nc>q^;|nRw{R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y}026EhF9Fta$bII}1-KQlY?Z>G0Qx0#MJZD5+lRK*m-WX&YO z^qKK2<5I?I#sEfT#%~NK7-lkLF<3KjGu-{Z?tjDop#Q4>fBrlFZ|T3uSQ!7&&Q!7&=Qx#JoQz}z9lRJ|slL8YL(?`bZ zjJp`;GS)H1GFmfAFn(dUz_5y;l_8$Nft6)llsU0@B7~ufA9Rg^!N1Nqkj+mJ^1&~-(!Ez{Jrw`-rrY$fBfbAC;dOa;@{JMEdN#hyZlf6-~NB)|I`29{O4uRX9!>@WSGdXk>NbUTLw-> z6-GP8aK=2w7RDKjs~C4No@Bhr_<->x;|IpCj6WEEGJa?L!uX!?1>*z8tBfZYcQLMF zoXOb6Si~5^=*peXf{kQqw!haM0HUBIBm-8>_U-ZAwe*ype{`vm%`xp2x^k4M9>EEk=PyXHicl+Osf7kzA`*;1{&3||PJ^1(Z-Vz|L@m*D}!V}_>;&lsLFJY#sm@QC3a!!3rZ z4Cfh6FdSsq$*_T8Im29r$qXF~wG4#}sSJ?}z6=fwCJgEfQVe_yj11rYzxsdg|KHo_A^Z!r#-}k@mfBpZ8|Hc1v|7ZSB{htKb|M>s0|6{-~_J7>}g#XF^)Bb1u z&;MWYzw&?m|JMIK|0n;S{eRK_RsT2r-}V3S|I`1k{J-=6>Hl~Czy1IBpOt}^L6kw3 zL4`q^!H~g%!Ir_9!GpnAA(kP5A(0`8AsGyl7!ny07~&XW7@`=$8A2EW z8GIQ$8C)408EhFW7)%)S8MGMG7!(;~7{nQb8Tc5u7+4t?8UFqM_5a)d&;LLCfBXN{ z|L6ao{(t=c;s5*p@BP2~|IYtA|8GO#o&R_L-~E5@|AYSz|3CWw games/demo/scenes/demo.ron +# [game] game_dir -> games/demo +# `--game games/demo` sets game_dir on the CLI; the scene path is set via env: +# +# R4D_SCENE__PATH=games/demo/scenes/demo.ron cargo run -- --game games/demo +# +# (Keeping `config/default.toml` unchanged so `cargo run` still boots the +# default scene; see games/demo/README.md.) + +[scene] +path = "games/demo/scenes/demo.ron" +player_radius = 0.5 + +[game] +game_dir = "games/demo" +scripts_dir = "" # main.lua lives at the game_dir root +hot_reload = false # flip to true for live Lua editing during dev +audio_enabled = true + +[audio] +master_volume = 1.0 +sfx_volume = 1.0 +music_volume = 0.0 # demo has no music bus +ambient_volume = 0.0 \ No newline at end of file diff --git a/games/demo/main.lua b/games/demo/main.lua new file mode 100644 index 0000000..7d028e0 --- /dev/null +++ b/games/demo/main.lua @@ -0,0 +1,146 @@ +-- games/demo/main.lua +-- +-- Rust4D Wave 5 — Lua demo game entry point. +-- +-- Run with: +-- R4D_SCENE__PATH=games/demo/scenes/demo.ron cargo run -- --game games/demo +-- +-- This script drives a curated scene (games/demo/scenes/demo.ron) of six 4D +-- primitives in a ring around a central trigger zone. It exercises the full +-- Wave 5 scripting surface: +-- * ECS bridge — world.find_by_name / entity:get / entity:set("transform") +-- * Math — Rotor4.from_plane (W-involving planes morph the slice) +-- * Input — input.is_key_pressed (W-slide indicator) +-- * Audio — audio.load_sound / play_oneshot_spatial (spatial cue) +-- * HUD — hud.text / progress_bar / flash / screen_size +-- * Triggers — 4D AABB detection in on_fixed_update +-- * Tweens — manual sine scale-pulse (TweenManager is not Lua-bound) +-- +-- See games/demo/README.md for the feature matrix and controls. + +local Rotator = require("scripts.rotator") +local TriggerZone = require("scripts.trigger_zone") +local Hud = require("scripts.hud") + +-- Per-primitive spin config: plane (a W-involving bivector) + speed (rad/s). +-- Distinct planes make each primitive's 3D slice morph differently. +local GALLERY_SPIN = { + tesseract = { plane = "XW", speed = 0.60 }, + pentachoron = { plane = "YW", speed = 0.70 }, + hexadecachoron = { plane = "ZW", speed = 0.50 }, + icositetrachoron = { plane = "XW", speed = -0.45 }, + spherinder = { plane = "YW", speed = 0.55 }, + duocylinder = { plane = "ZW", speed = 0.65 }, +} + +local rotators = {} +local trigger = nil +local blip = nil -- SoundHandle for trigger-enter, or nil if audio unavailable +local tone = nil -- SoundHandle for trigger-exit, or nil +local frame = 0 +-- Observable counts (globals so the headless smoke example + tooling can read +-- them back through engine.lua()). +gallery_count = 0 +trigger_enters = 0 +trigger_exits = 0 + +-- Look up a scene entity by name, failing loudly if it is missing. +local function must_find(name) + local e = world.find_by_name(name) + if e == nil then + log.error(("[demo] missing scene entity: %s"):format(name)) + end + return e +end + +function on_init() + log.info("[demo] on_init: building gallery rotators") + + for name, cfg in pairs(GALLERY_SPIN) do + local e = must_find(name) + if e then + local t = e:get("transform") + rotators[name] = Rotator.new(e, cfg.plane, cfg.speed, t.position, t.scale) + gallery_count = gallery_count + 1 + end + end + + -- Trigger zone at the ring center. + local zone = must_find("trigger_zone") + if zone then + trigger = TriggerZone.new(zone, 1.5, on_trigger_enter, on_trigger_exit) + end + + -- Audio cues. load_sound returns nil when audio is unavailable (headless / + -- no device); the demo degrades gracefully — cues are skipped, the trigger + -- still flashes + pulses. + blip = audio.load_sound("games/demo/assets/blip.wav") + tone = audio.load_sound("games/demo/assets/tone.wav") + if blip then + log.info("[demo] audio cues loaded (blip + tone)") + else + log.info("[demo] audio unavailable — cues will be skipped") + end + + log.info(("[demo] on_init done: %d rotators, entity_count=%d") + :format(gallery_count, world.entity_count())) +end + +-- Trigger enter: spatial blip + HUD flash + (pulse handled in update). +function on_trigger_enter(self) + trigger_enters = trigger_enters + 1 + log.info("[demo] trigger ENTER") + if blip then + audio.play_oneshot_spatial(blip, self.base_pos, 1.0, 25.0, "sfx") + end + hud.flash({0.30, 1.0, 0.85, 0.25}) +end + +-- Trigger exit: low tone + reset (pulse reset handled in update). +function on_trigger_exit(self) + trigger_exits = trigger_exits + 1 + log.info("[demo] trigger EXIT") + if tone then + audio.play_oneshot_spatial(tone, self.base_pos, 1.0, 25.0, "sfx") + end +end + +function on_update(dt) + frame = frame + 1 + + -- Drive the gallery rotation. Each set("transform") marks geometry dirty so + -- the render cache rebuilds and the motion is visible. + for _, r in pairs(rotators) do + r:update(dt) + end + + -- Trigger pulse / reset visual. + if trigger then + trigger:update(dt) + end + + -- W-slide input for the HUD indicator (demonstrates the input binding). + local w_sliding = input.is_key_pressed("Q") or input.is_key_pressed("E") + + -- HUD readout. Player position comes from the audio listener, which the + -- engine updates to the camera/player position each frame. + local player_pos = audio.get_listener_position() + Hud.draw({ + player_pos = player_pos, + entity_count = world.entity_count(), + trigger_inside = trigger and trigger.inside or false, + w_sliding = w_sliding, + }) +end + +function on_fixed_update(dt) + -- Trigger-zone AABB check runs on the fixed timestep for stable detection. + if trigger then + local player_pos = audio.get_listener_position() + trigger:tick(player_pos) + end +end + +function on_shutdown() + log.info(("[demo] on_shutdown after %d frames"):format(frame)) +end \ No newline at end of file diff --git a/games/demo/scenes/demo.ron b/games/demo/scenes/demo.ron new file mode 100644 index 0000000..ba7d194 --- /dev/null +++ b/games/demo/scenes/demo.ron @@ -0,0 +1,124 @@ +// Rust4D Wave 5 — Lua Demo Game scene. +// +// A curated gallery: a floor, six 4D primitives arranged in a ring around the +// origin, and a small "trigger zone" hypersphere at the center. Lua scripts +// (see games/demo/main.lua) rotate each gallery primitive in a W-involving +// plane so the 3D slice morphs over time, detect when the player walks into the +// central zone, and drive a HUD + audio cue + scale pulse on trigger. +// +// Load with: +// R4D_SCENE__PATH=games/demo/scenes/demo.ron cargo run -- --game games/demo +Scene( + name: "Lua Demo Gallery", + entities: [ + // --- Floor --- + EntityTemplate( + name: Some("floor"), + tags: ["static"], + transform: Transform4D( + position: Vec4(x: 0.0, y: -2.0, z: 0.0, w: 0.0), + rotation: (s: 1.0, b_xy: 0.0, b_xz: 0.0, b_xw: 0.0, b_yz: 0.0, b_yw: 0.0, b_zw: 0.0, p: 0.0), + scale: 1.0, + ), + shape: ShapeTemplate( + type: "Hyperplane", + y: -2.0, + size: 24.0, + subdivisions: 24, + cell_size: 8.0, + thickness: 0.001, + ), + material: Material(base_color: (0.36, 0.36, 0.40, 1.0)), + ), + + // --- Gallery ring (6 primitives, radius 6 in the XZ plane) --- + // Each is tagged ["gallery", ""] so world.query("tags") and + // world.find_by_name both locate them. Lua rotates each in a distinct + // W-involving plane so the 3D slice morphs as it spins. + + EntityTemplate( + name: Some("tesseract"), + tags: ["static", "gallery"], + transform: Transform4D( + position: Vec4(x: 6.0, y: 0.0, z: 0.0, w: 0.0), + rotation: (s: 1.0, b_xy: 0.0, b_xz: 0.0, b_xw: 0.0, b_yz: 0.0, b_yw: 0.0, b_zw: 0.0, p: 0.0), + scale: 1.0, + ), + shape: ShapeTemplate(type: "Tesseract", size: 2.0), + material: Material(base_color: (1.0, 0.82, 0.32, 1.0)), + ), + EntityTemplate( + name: Some("pentachoron"), + tags: ["static", "gallery"], + transform: Transform4D( + position: Vec4(x: 3.0, y: 0.0, z: 5.196, w: 0.0), + rotation: (s: 1.0, b_xy: 0.0, b_xz: 0.0, b_xw: 0.0, b_yz: 0.0, b_yw: 0.0, b_zw: 0.0, p: 0.0), + scale: 1.2, + ), + shape: ShapeTemplate(type: "Pentachoron", circumradius: 1.3), + material: Material(base_color: (1.0, 0.38, 0.34, 1.0)), + ), + EntityTemplate( + name: Some("hexadecachoron"), + tags: ["static", "gallery"], + transform: Transform4D( + position: Vec4(x: -3.0, y: 0.0, z: 5.196, w: 0.0), + rotation: (s: 1.0, b_xy: 0.0, b_xz: 0.0, b_xw: 0.0, b_yz: 0.0, b_yw: 0.0, b_zw: 0.0, p: 0.0), + scale: 1.2, + ), + shape: ShapeTemplate(type: "Hexadecachoron", circumradius: 1.35), + material: Material(base_color: (0.55, 1.0, 0.48, 1.0)), + ), + EntityTemplate( + name: Some("icositetrachoron"), + tags: ["static", "gallery"], + transform: Transform4D( + position: Vec4(x: -6.0, y: 0.0, z: 0.0, w: 0.0), + rotation: (s: 1.0, b_xy: 0.0, b_xz: 0.0, b_xw: 0.0, b_yz: 0.0, b_yw: 0.0, b_zw: 0.0, p: 0.0), + scale: 1.1, + ), + shape: ShapeTemplate(type: "Icositetrachoron", circumradius: 1.5), + material: Material(base_color: (0.72, 0.45, 1.0, 1.0)), + ), + EntityTemplate( + name: Some("spherinder"), + tags: ["static", "gallery"], + transform: Transform4D( + position: Vec4(x: -3.0, y: 0.0, z: -5.196, w: 0.0), + rotation: (s: 1.0, b_xy: 0.0, b_xz: 0.0, b_xw: 0.0, b_yz: 0.0, b_yw: 0.0, b_zw: 0.0, p: 0.0), + scale: 1.0, + ), + shape: ShapeTemplate(type: "Spherinder", radius: 1.05, half_height: 1.25, subdivisions: 2), + material: Material(base_color: (0.28, 0.95, 0.88, 1.0)), + ), + EntityTemplate( + name: Some("duocylinder"), + tags: ["static", "gallery"], + transform: Transform4D( + position: Vec4(x: 3.0, y: 0.0, z: -5.196, w: 0.0), + rotation: (s: 1.0, b_xy: 0.0, b_xz: 0.0, b_xw: 0.0, b_yz: 0.0, b_yw: 0.0, b_zw: 0.0, p: 0.0), + scale: 1.0, + ), + shape: ShapeTemplate(type: "Duocylinder", radius_xy: 1.0, radius_zw: 1.0, segments: 32), + material: Material(base_color: (0.40, 0.65, 1.0, 1.0)), + ), + + // --- Trigger zone (small hypersphere at the ring center) --- + // Lua detects the player entering a 4D AABB around this point and + // fires an audio cue + HUD flash + scale pulse. Semi-transparent so the + // gallery ring is still visible through it. + EntityTemplate( + name: Some("trigger_zone"), + tags: ["static", "trigger"], + transform: Transform4D( + position: Vec4(x: 0.0, y: 0.0, z: 0.0, w: 0.0), + rotation: (s: 1.0, b_xy: 0.0, b_xz: 0.0, b_xw: 0.0, b_yz: 0.0, b_yw: 0.0, b_zw: 0.0, p: 0.0), + scale: 1.0, + ), + shape: ShapeTemplate(type: "Hypersphere", radius: 0.6, subdivisions: 2), + material: Material(base_color: (0.30, 1.0, 0.85, 0.55)), + ), + ], + gravity: Some(-20.0), + player_spawn: Some((0.0, 1.5, 14.0, 0.0)), +) \ No newline at end of file diff --git a/games/demo/scripts/hud.lua b/games/demo/scripts/hud.lua new file mode 100644 index 0000000..6b5060e --- /dev/null +++ b/games/demo/scripts/hud.lua @@ -0,0 +1,65 @@ +-- scripts/hud.lua +-- +-- Per-frame HUD readout for the demo. Calls the engine's `hud.*` bindings to +-- draw the player's 4D position, entity count, trigger state, and controls. +-- +-- NOTE: as of Wave 5 the `hud.*` bindings are API-complete but render to the +-- log only (they are not yet wired into the render HudContext). The calls are +-- valid and exercise the full HUD API surface; a future wave that plugs a +-- HudContext into ScriptSystem::update will make them visible on screen with +-- no script changes. See the demo-game report's "Engine limitations" section. + +local Hud = {} + +-- Draw the HUD for one frame. +-- state = { +-- player_pos = Vec4, -- from audio.get_listener_position() +-- entity_count = number, +-- trigger_inside = bool, +-- w_sliding = bool, -- whether Q/E is held this frame +-- } +function Hud.draw(state) + local sw, sh = hud.screen_size() + + -- Title + hud.text(16, 16, "Rust4D — Lua Demo Gallery", 22, {1.0, 1.0, 1.0, 1.0}) + + -- Player 4D position + local p = state.player_pos + hud.text( + 16, 48, + string.format("player pos x=%.2f y=%.2f z=%.2f w=%.2f", + p.x, p.y, p.z, p.w), + 16, {0.6, 0.9, 1.0, 1.0}) + + -- W-slide indicator (demonstrates the input binding) + local w_txt = state.w_sliding and "W-slide: active" or "W-slide: idle" + local w_col = state.w_sliding and {0.4, 1.0, 0.7, 1.0} or {0.5, 0.5, 0.55, 1.0} + hud.text(16, 70, w_txt, 16, w_col) + + -- Entity count + hud.text( + 16, 92, + string.format("entities: %d", state.entity_count), + 16, {0.75, 0.75, 0.78, 1.0}) + + -- Trigger state + local trig_txt = state.trigger_inside and "TRIGGER: ACTIVE" or "trigger: idle" + local trig_col = state.trigger_inside + and {1.0, 0.85, 0.20, 1.0} + or {0.55, 0.55, 0.55, 1.0} + hud.text(16, 114, trig_txt, 16, trig_col) + + -- Trigger status bar (demonstrates hud.progress_bar) + local prog = state.trigger_inside and 1.0 or 0.0 + hud.progress_bar(16, 138, 220, 14, prog, + {0.18, 0.18, 0.20, 0.9}, {1.0, 0.85, 0.20, 1.0}) + + -- Controls hint along the bottom + hud.text( + 16, sh - 28, + "WASD move · Q/E slide W · scroll = slice offset · walk to the center to trigger", + 14, {0.5, 0.5, 0.55, 1.0}) +end + +return Hud \ No newline at end of file diff --git a/games/demo/scripts/rotator.lua b/games/demo/scripts/rotator.lua new file mode 100644 index 0000000..e2db267 --- /dev/null +++ b/games/demo/scripts/rotator.lua @@ -0,0 +1,56 @@ +-- scripts/rotator.lua +-- +-- Per-entity 4D spin logic for the demo gallery. Each Rotator advances an +-- angle and writes a fresh Transform4D to its entity every frame, rotating in +-- a single bivector plane. Rotating in a W-involving plane (XW, YW, ZW) makes +-- the 3D slice morph over time as the slice hyperplane cuts different +-- orientations of the 4D shape — the signature visual of this demo. +-- +-- Usage (from main.lua): +-- local Rotator = require("scripts.rotator") +-- local r = Rotator.new(entity, "XW", 0.6, base_pos, base_scale) +-- r:update(dt) +-- +-- The transform table form {x=,y=,z=,w=,scale=,rotation=} is accepted by the +-- ECS bridge's transform setter; rotation must be a Rotor4 userdata. + +local Rotator = {} +Rotator.__index = Rotator + +-- Create a rotator bound to an entity. +-- entity — LuaEntity from world.find_by_name +-- plane — one of "XY","XZ","XW","YZ","YW","ZW" +-- speed — radians per second +-- base_pos — Vec4 userdata (the entity's authored position) +-- base_scale — number (the entity's authored scale) +function Rotator.new(entity, plane, speed, base_pos, base_scale) + local self = setmetatable({}, Rotator) + self.entity = entity + self.plane = plane + self.speed = speed + self.angle = 0.0 + self.base_pos = base_pos + self.base_scale = base_scale + return self +end + +-- Advance the rotation and write the transform. Returns the new angle. +function Rotator:update(dt) + self.angle = self.angle + self.speed * dt + -- Keep the angle bounded to avoid float drift over long runs. + if self.angle > math.pi * 2.0 then + self.angle = self.angle - math.pi * 2.0 + end + local rotor = Rotor4.from_plane(self.plane, self.angle) + self.entity:set("transform", { + x = self.base_pos.x, + y = self.base_pos.y, + z = self.base_pos.z, + w = self.base_pos.w, + scale = self.base_scale, + rotation = rotor, + }) + return self.angle +end + +return Rotator \ No newline at end of file diff --git a/games/demo/scripts/trigger_zone.lua b/games/demo/scripts/trigger_zone.lua new file mode 100644 index 0000000..5ef529d --- /dev/null +++ b/games/demo/scripts/trigger_zone.lua @@ -0,0 +1,96 @@ +-- scripts/trigger_zone.lua +-- +-- Trigger-zone logic for the demo. Detects the player entering/exiting a 4D +-- axis-aligned bounding box centered on the zone entity, and on enter fires an +-- audio cue + HUD flash + a scale pulse on the zone entity itself; on exit it +-- resets the scale and plays a low tone. +-- +-- Player position source: `audio.get_listener_position()`. The engine updates +-- the audio listener to the camera/player position each frame (see +-- ScriptSystem::update), so this is the live player position — one frame stale, +-- which is negligible for a trigger. When audio is unavailable (headless / no +-- device) the listener position reads as the zero vector; see the report's +-- "Engine limitations" section for why that is an acceptable degradation. +-- +-- The scale pulse is a manual sine tween (`scale = base * (1 + 0.3*sin(t))`). +-- The engine's TweenManager is not exposed to Lua (no binding), so the pulse is +-- implemented by hand here. + +local TriggerZone = {} +TriggerZone.__index = TriggerZone + +-- Create a trigger zone. +-- entity — LuaEntity for the zone (find_by_name("trigger_zone")) +-- half — half-extent of the 4D AABB around the zone center +-- on_enter — optional callback(self) fired on a fresh enter +-- on_exit — optional callback(self) fired on a fresh exit +function TriggerZone.new(entity, half, on_enter, on_exit) + local self = setmetatable({}, TriggerZone) + self.entity = entity + self.half = half + self.on_enter = on_enter + self.on_exit = on_exit + self.inside = false + self.t = 0.0 -- pulse accumulator (seconds since enter) + + -- Cache the authored transform so we can pulse scale without drift. + local base = entity:get("transform") + self.base_pos = base.position -- Vec4 userdata + self.base_scale = base.scale -- number + return self +end + +-- AABB containment test against a player position (Vec4 userdata). +-- Returns true if the player is within the 4D box. +function TriggerZone:contains(player_pos) + local h = self.half + local p = self.base_pos + return math.abs(player_pos.x - p.x) <= h + and math.abs(player_pos.y - p.y) <= h + and math.abs(player_pos.z - p.z) <= h + and math.abs(player_pos.w - p.w) <= h +end + +-- Run the enter/exit state machine. Call from on_fixed_update. +-- Returns "enter", "exit", or nil for this tick. +function TriggerZone:tick(player_pos) + local within = self:contains(player_pos) + if within and not self.inside then + self.inside = true + self.t = 0.0 + if self.on_enter then self.on_enter(self) end + return "enter" + elseif not within and self.inside then + self.inside = false + if self.on_exit then self.on_exit(self) end + return "exit" + end + return nil +end + +-- Per-frame visual update. Pulses scale while the player is inside; otherwise +-- restores the base scale. Call from on_update. +function TriggerZone:update(dt) + if self.inside then + self.t = self.t + dt + local s = self.base_scale * (1.0 + 0.3 * math.sin(self.t * 6.0)) + self:_write_scale(s) + else + self:_write_scale(self.base_scale) + end +end + +-- Write a transform that preserves the authored position and rotation but +-- swaps in a new scale. +function TriggerZone:_write_scale(scale) + self.entity:set("transform", { + x = self.base_pos.x, + y = self.base_pos.y, + z = self.base_pos.z, + w = self.base_pos.w, + scale = scale, + rotation = Rotor4.identity(), + }) +end + +return TriggerZone \ No newline at end of file -- knotmirror 0.0.1