Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / games / kart / AGENTS.md
| 1 | # AGENTS.md — games/kart/ (':games:kart') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `games/kart/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install games/kart (release by default)._ |
| 6 | - Gradle: :games:kart / dir: games/kart/ |
| 7 | - Package roots present: data, domain, platform, ui |
| 8 | - Entry files: MainActivity.kt, Route.kt, Navigation.kt |
| 9 | - Deps: :sdk:controller, :library:e2ee-p2p |
| 10 | - Metadata: metadata_data/games-kart.md (present) |
| 11 | - Rust: yes / screenshotTest: yes |
| 12 | |
| 13 | ## Overview |
| 14 | **Purpose:** 3D kart racer (Sunset Oval) for phones — native Rust engine (Vulkan, with a GLES fallback for devices without Vulkan), kart physics, chase cam, items and AI. Played solo against AI drivers or over LAN: this phone hosts the race and broadcasts it openly on the Wi-Fi, and other phones join as extra drivers from the Games Hub app with no pairing code. |
| 15 | **Game shape:** `Route` (`Lobby` / `Race` / `Results`) → `platform/KartViewModel` → `domain/` race/input rules + `platform/KartHost` (`:sdk:controller` lobby fan-in) → `platform/KartNative` → `src/main/rust/` engine; achievements via :library's AchievementsManager → `:sdk:games` → hub. Local input (touch + gamepad) is recorded by the ViewModel itself and merged over the host fan-in, so solo races drive even when the LAN host is down. |
| 16 | **Entry points:** `Route` → `MainActivity.kt` → `Navigation.kt` → `ui/KartGameScreen.kt` → `platform/KartViewModel.kt` → `platform/KartNative.kt` / `domain/PlaceholderRace.kt`. |
| 17 | **Gotchas:** |
| 18 | - Native Rust: crate `kart_engine` in `src/main/rust/` (engine/physics/track/mesh/items + `vulkan/` and `gles/` renderers, GLSL `kart.vert`/`kart.frag` compiled at runtime by the GLES path). Phone-only: arm64 like every other app; the GLES renderer is the non-Vulkan fallback. |
| 19 | - `platform/KartNative` is the sole `kart_engine` wrapper: every call is gated on `KartNative.isAvailable`; without the `.so` the game runs `domain/PlaceholderRace` — never call native entry points unguarded. |
| 20 | - Controller dep IS present (`:sdk:controller`): `platform/KartHost` broadcasts the open LAN game on `_gamepad._tcp` (a `LanGameBeacon` in the TXT record: host name, game, seated/capacity counts, track, open flag), accepts phones and fans `ControllerInput` into the race loop (`domain/GameInputLoop`); `platform/GamepadDirect` handles a locally attached gamepad in `MainActivity`. PQC identity stays behind lambdas in `KartHost` — this module never touches the `:library:e2ee-p2p` native library directly. LAN joins are open: the inner host runs `openJoin = true`, so any phone that reads the broadcast joins from Games Hub with no pairing code and no approval; the beacon turns closed while racing or full. Solo-vs-bots needs no host at all. |
| 21 | - Listing images are hand-captured — Layoutlib can't render the Vulkan surface; `src/screenshotTest` previews cover only the non-surface UI. |
| 22 | - `KartDataStore` (`data/`) is the sole prefs owner (cup pointer + lifetime counters); countdown is in-screen state of `Route.Race`, not a destination. |
| 23 | |
| 24 | ## Key files |
| 25 | ### Root — entry + navigation |
| 26 | - com/vayunmathur/games/kart/MainActivity.kt |
| 27 | - com/vayunmathur/games/kart/Route.kt |
| 28 | - com/vayunmathur/games/kart/Navigation.kt |
| 29 | ### data/ — progress store + models |
| 30 | - com/vayunmathur/games/kart/data/KartDataStore.kt |
| 31 | - com/vayunmathur/games/kart/data/KartModels.kt |
| 32 | ### domain/ — pure race + input rules |
| 33 | - com/vayunmathur/games/kart/domain/KartRules.kt |
| 34 | - com/vayunmathur/games/kart/domain/LapTracker.kt |
| 35 | - com/vayunmathur/games/kart/domain/GameInputLoop.kt |
| 36 | - com/vayunmathur/games/kart/domain/PlaceholderRace.kt |
| 37 | - com/vayunmathur/games/kart/domain/RumbleDecider.kt |
| 38 | - com/vayunmathur/games/kart/domain/TouchControls.kt — held touch state → `KartControl` / `ControllerInput` encoding |
| 39 | ### platform/ — ViewModel, native wrapper, controller host |
| 40 | - com/vayunmathur/games/kart/platform/KartViewModel.kt |
| 41 | - com/vayunmathur/games/kart/platform/KartNative.kt — sole guarded `kart_engine` wrapper |
| 42 | - com/vayunmathur/games/kart/platform/KartHost.kt — `:sdk:controller` lobby host |
| 43 | - com/vayunmathur/games/kart/platform/KartPairingStore.kt |
| 44 | - com/vayunmathur/games/kart/platform/GamepadDirect.kt |
| 45 | - com/vayunmathur/games/kart/platform/RacePhase.kt |
| 46 | - com/vayunmathur/games/kart/platform/KartUiContract.kt |
| 47 | - com/vayunmathur/games/kart/platform/KartAchievementsManager.kt |
| 48 | - com/vayunmathur/games/kart/platform/AppBackupAgent.kt |
| 49 | ### ui/ — race screens + native surface |
| 50 | - com/vayunmathur/games/kart/ui/KartGameScreen.kt |
| 51 | - com/vayunmathur/games/kart/ui/KartGamePage.kt |
| 52 | - com/vayunmathur/games/kart/ui/KartSurfaceView.kt |
| 53 | ### src/main/rust/ — native engine (kart_engine) |
| 54 | - src/main/rust/src/lib.rs — JNI entry points |
| 55 | - src/main/rust/src/engine.rs |
| 56 | - src/main/rust/src/physics.rs |
| 57 | - src/main/rust/src/track.rs |
| 58 | - src/main/rust/src/race.rs |
| 59 | - src/main/rust/src/items.rs |
| 60 | - src/main/rust/src/mesh.rs |
| 61 | - src/main/rust/src/renderer.rs |
| 62 | - src/main/rust/src/vulkan/mod.rs |
| 63 | - src/main/rust/src/gles/mod.rs |
| 64 | |
| 65 | ## Verify (this module only) |
| 66 | ``` |
| 67 | ./gradlew :games:kart:compileDevKotlin |
| 68 | ./gradlew :games:kart:lint |
| 69 | ./gradlew :games:kart:checkMetadata |
| 70 | ``` |