feat: game/engine split refactor + skybox
This commit is contained in:
parent
581e5892b0
commit
eeedcb8e48
34 changed files with 610 additions and 218 deletions
32
tests/layering.test.ts
Normal file
32
tests/layering.test.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { readdirSync, readFileSync, statSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
|
||||
// The engine is the reusable, content-agnostic layer: it must import nothing from
|
||||
// game (content) or app (browser glue). game -> engine and app -> game -> engine are
|
||||
// fine; the reverse is the violation. This freezes the Stage-3 seam so a stray import
|
||||
// can't quietly re-couple the layers.
|
||||
function tsFiles(dir: string): string[] {
|
||||
const out: string[] = []
|
||||
for (const name of readdirSync(dir)) {
|
||||
const p = join(dir, name)
|
||||
if (statSync(p).isDirectory()) {
|
||||
out.push(...tsFiles(p))
|
||||
} else if (p.endsWith(".ts")) {
|
||||
out.push(p)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
test("engine imports nothing from game or app", () => {
|
||||
const engineDir = new URL("../engine", import.meta.url).pathname
|
||||
const offenders = tsFiles(engineDir).filter((f) => /from\s+["'][^"']*\/(?:game|app)\//.test(readFileSync(f, "utf8")))
|
||||
expect(offenders).toEqual([])
|
||||
})
|
||||
|
||||
test("game imports nothing from app", () => {
|
||||
const gameDir = new URL("../game", import.meta.url).pathname
|
||||
const offenders = tsFiles(gameDir).filter((f) => /from\s+["'][^"']*\/app\//.test(readFileSync(f, "utf8")))
|
||||
expect(offenders).toEqual([])
|
||||
})
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { MOB_KINDS, Mob } from "../engine/scene/Mob"
|
||||
import { MOB_KINDS, Mob } from "../game/actors/Mob"
|
||||
|
||||
// The mob SAB packs a kind as its index in MOB_KINDS; the main thread and every
|
||||
// render worker must agree on that order. Freeze it here: appending a kind is fine,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { Tree, TREE_KINDS } from "../engine/scene/Tree"
|
||||
import { Tree, TREE_KINDS } from "../game/actors/Tree"
|
||||
|
||||
// The chunk baker (level.ts) accumulates geometry into a mesh per material key and
|
||||
// only draws keys listed in MAT_ORDER. A tree species that declares a trunk/foliage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue