Rust voxel sandbox (wgpu + wasm + axum multiplayer)
state.rs is gone. Its content split by responsibility:
src/bridges.rs (~290 lines)
The only place we own shared mutable state. Holds the four
thread_locals (touch input, game status, network, settings) and
the wasm-bindgen JS interface that mutates them. Exposes a typed
accessor API — current_settings(), snapshot_touch_bridge(),
with_touch_bridge(f), is_touch_mode(), clear_touch_inputs(),
take_respawn_request(), set_status(hp, alive), take_inbox(),
push_outbox(msg), with_net_bridge(f), net_connection_snapshot(),
is_connected(), set_my_id(id), snapshot_remote_players(). Callers
never touch the RefCells; if storage ever moves to a Mutex or
OnceCell, only this file changes.
src/app.rs (~510 lines)
The App + winit ApplicationHandler + tick + drain_net_inbox +
do_respawn + render_frame + FrameClock. Uses the bridges
accessors instead of poking thread_locals directly, so the call
sites read as a pipeline rather than a chain of `.with(|x|
x.borrow_mut())`.
src/lib.rs
Modules now declared in alphabetical order:
app, bridges, camera, mesh, net, proto, render,
shader_source, sim, world.
`run()` constructs `app::App::default()` instead of the old
`state::App`.
src/render/mod.rs
`use crate::bridges::RemotePlayer` (was `crate::state::`).
Net effect of the four phases combined: state.rs at the start of
alpha-0.0.2 was 2500 lines doing everything; today the same logic
spans nine focused modules totalling ~3000 lines (with full doc
comments). 53 tests pass, native + wasm release build green, server
build green.
|
||
|---|---|---|
| server | ||
| src | ||
| web | ||
| .dockerignore | ||
| .gitignore | ||
| build-web.sh | ||
| Caddyfile | ||
| Cargo.lock | ||
| Cargo.toml | ||
| DEPLOY.md | ||
| docker-compose.prod.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| run.sh | ||