A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Upgrade Ritmo to 0.23.0
SandroMaglionea24df7525a36
diff --git a/.oxlintrc.json b/.oxlintrc.jsonindex 4521936..81b7735 100644--- a/.oxlintrc.json+++ b/.oxlintrc.json@@ -9,7 +9,8 @@"town/no-cast-escape": "error","ritmo/handle-runtime-result": "error","ritmo/prefix-descriptor-and-system-names": "error",- "ritmo/no-state-spread": "error"+ "ritmo/no-state-spread": "error",+ "ritmo/no-kept-query-values": "error"},"overrides": [{diff --git a/package.json b/package.jsonindex 7887bae..e731081 100644--- a/package.json+++ b/package.json@@ -32,18 +32,18 @@"engine:prepare": "node scripts/use-ritmo.ts"},"dependencies": {- "@typeonce/ritmo": "0.22.0",- "@typeonce/ritmo-browser": "0.22.0",- "@typeonce/ritmo-math": "0.22.0",- "@typeonce/ritmo-pixi": "0.22.0",- "@typeonce/ritmo-render": "0.22.0",+ "@typeonce/ritmo": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-0.23.0.tgz",+ "@typeonce/ritmo-browser": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-browser-0.23.0.tgz",+ "@typeonce/ritmo-math": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-math-0.23.0.tgz",+ "@typeonce/ritmo-pixi": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-pixi-0.23.0.tgz",+ "@typeonce/ritmo-render": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-render-0.23.0.tgz","effect": "4.0.3","pixi.js": "^8.22.0","three": "^0.186.1"},"devDependencies": {- "@typeonce/oxlint-plugin-ritmo": "0.22.0",- "@typeonce/ritmo-devtools": "0.22.0",+ "@typeonce/oxlint-plugin-ritmo": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-oxlint-plugin-ritmo-0.23.0.tgz",+ "@typeonce/ritmo-devtools": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-devtools-0.23.0.tgz","@types/node": "25.5.0","@types/three": "^0.186.0","oxlint": "1.92.0",@@ -51,5 +51,18 @@"typescript": "7.0.2","vite": "8.3.1"},- "ritmoRelease": "0.22.0"+ "ritmoRelease": "0.23.0",+ "pnpm": {+ "overrides": {+ "@typeonce/ritmo": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-0.23.0.tgz",+ "@typeonce/ritmo-browser": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-browser-0.23.0.tgz",+ "@typeonce/ritmo-math": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-math-0.23.0.tgz",+ "@typeonce/ritmo-pixi": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-pixi-0.23.0.tgz",+ "@typeonce/ritmo-render": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-render-0.23.0.tgz",+ "@typeonce/oxlint-plugin-ritmo": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-oxlint-plugin-ritmo-0.23.0.tgz",+ "@typeonce/ritmo-devtools": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-devtools-0.23.0.tgz",+ "@typeonce/ritmo-netcode": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-netcode-0.23.0.tgz",+ "@typeonce/ritmo-tools": "file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-tools-0.23.0.tgz"+ }+ }}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex b87b208..4ef92e2 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -4,25 +4,36 @@ settings:autoInstallPeers: trueexcludeLinksFromLockfile: false+overrides:+ '@typeonce/ritmo': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-0.23.0.tgz+ '@typeonce/ritmo-browser': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-browser-0.23.0.tgz+ '@typeonce/ritmo-math': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-math-0.23.0.tgz+ '@typeonce/ritmo-pixi': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-pixi-0.23.0.tgz+ '@typeonce/ritmo-render': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-render-0.23.0.tgz+ '@typeonce/oxlint-plugin-ritmo': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-oxlint-plugin-ritmo-0.23.0.tgz+ '@typeonce/ritmo-devtools': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-devtools-0.23.0.tgz+ '@typeonce/ritmo-netcode': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-netcode-0.23.0.tgz+ '@typeonce/ritmo-tools': file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-tools-0.23.0.tgz+importers:.:dependencies:'@typeonce/ritmo':- specifier: 0.22.0- version: 0.22.0([email protected])+ specifier: file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-0.23.0.tgz+ version: file:../tarballs/typeonce-ritmo-0.23.0.tgz([email protected])'@typeonce/ritmo-browser':- specifier: 0.22.0- version: 0.22.0([email protected])+ specifier: file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-browser-0.23.0.tgz+ version: file:../tarballs/typeonce-ritmo-browser-0.23.0.tgz([email protected])'@typeonce/ritmo-math':- specifier: 0.22.0- version: 0.22.0([email protected])+ specifier: file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-math-0.23.0.tgz+ version: file:../tarballs/typeonce-ritmo-math-0.23.0.tgz([email protected])'@typeonce/ritmo-pixi':- specifier: 0.22.0- version: 0.22.0([email protected])+ specifier: file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-pixi-0.23.0.tgz+ version: file:../tarballs/typeonce-ritmo-pixi-0.23.0.tgz([email protected])'@typeonce/ritmo-render':- specifier: 0.22.0- version: 0.22.0([email protected])+ specifier: file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-render-0.23.0.tgz+ version: file:../tarballs/typeonce-ritmo-render-0.23.0.tgz([email protected])effect:specifier: 4.0.3version: 4.0.3@@ -34,11 +45,11 @@ importers:version: 0.186.1devDependencies:'@typeonce/oxlint-plugin-ritmo':- specifier: 0.22.0- version: 0.22.0([email protected])+ specifier: file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-oxlint-plugin-ritmo-0.23.0.tgz+ version: file:../tarballs/typeonce-oxlint-plugin-ritmo-0.23.0.tgz([email protected])'@typeonce/ritmo-devtools':- specifier: 0.22.0- version: 0.22.0([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected]))+ specifier: file:/private/tmp/claude-501/-Users-sandromaglione-Development-projects-gamedev-ritmo/27247023-fa92-42d6-9bd8-ecd25bf20b20/scratchpad/tarballs/typeonce-ritmo-devtools-0.23.0.tgz+ version: file:../tarballs/typeonce-ritmo-devtools-0.23.0.tgz([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected]))'@types/node':specifier: 25.5.0version: 25.5.0@@ -283,18 +294,21 @@ packages:'@tweenjs/[email protected]':resolution: {integrity: sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==}- '@typeonce/[email protected]':- resolution: {integrity: sha512-YBEZ61AD51VunLBo9XvJ2Y7wFjgRejNZdKXB1fYr4Elr0xM9x8EfOPKxg+SppC13QrUCZ/NntuZG/13q/VGYIg==}+ '@typeonce/oxlint-plugin-ritmo@file:../tarballs/typeonce-oxlint-plugin-ritmo-0.23.0.tgz':+ resolution: {integrity: sha512-X1pbTstMGYdt+yMVUm2Bl+c0mQYC+Mtk9PQ2Q8vV3n8qXuc9koG5X552Q3kVVsXAuXXFN1xJ5RXWpFpubkWZBQ==, tarball: file:../tarballs/typeonce-oxlint-plugin-ritmo-0.23.0.tgz}+ version: 0.23.0engines: {node: '>=22.12'}peerDependencies:oxlint: '>=1.86.0'- '@typeonce/[email protected]':- resolution: {integrity: sha512-7dJN+Fyt8M+yeItLH3ttdQwzVsmzYrOtO4lShsIzRwzoQQGbfI3P/c3CFiEgHVSgxIwevcD+837tsDV1lWgM3g==}+ '@typeonce/ritmo-browser@file:../tarballs/typeonce-ritmo-browser-0.23.0.tgz':+ resolution: {integrity: sha512-5x38Cq1ewyMpRo0o3fQkjqLLbA9hVBNvMFN66r1WMw2lq7P4u+xDtrmVCZ7mvyjMnPxN0dxf+mLqmXzO5YdrXA==, tarball: file:../tarballs/typeonce-ritmo-browser-0.23.0.tgz}+ version: 0.23.0engines: {node: '>=22'}- '@typeonce/[email protected]':- resolution: {integrity: sha512-gkef7MqAY29Mi2JdlQT8q0Tx7077TGrXBfdqgNXaXwuvNRHh+GMINmAG7Fq6LlkE1HrfI3MAlqs7rj9GhD0pGQ==}+ '@typeonce/ritmo-devtools@file:../tarballs/typeonce-ritmo-devtools-0.23.0.tgz':+ resolution: {integrity: sha512-ZxxZGkPRfcCfUWGsGkK2C/uGvUAR7LJQwP8n/WSwpAul2o79cy+Mywczla3mMQadzYHlPUSz1XLDJPDUH6mfDw==, tarball: file:../tarballs/typeonce-ritmo-devtools-0.23.0.tgz}+ version: 0.23.0engines: {node: '>=22.15'}hasBin: truepeerDependencies:@@ -312,24 +326,29 @@ packages:vite:optional: true- '@typeonce/[email protected]':- resolution: {integrity: sha512-s8cqWlPpbvq8lHGOIkq3iuJ8hHkXUmx6XbnaX7YqFbfs99BJpxi7selmD7kKlM+dd61qFGRdgtDSpoFWxy2ndA==}+ '@typeonce/ritmo-math@file:../tarballs/typeonce-ritmo-math-0.23.0.tgz':+ resolution: {integrity: sha512-ZYOQdPWi5ESmwT2EZx8Q8TjmJaN8+F5CXi/pJw9pJExtrrtNgYsT+FMvspJECqIAi2cnITTUCQcTUiITLvCxRQ==, tarball: file:../tarballs/typeonce-ritmo-math-0.23.0.tgz}+ version: 0.23.0engines: {node: '>=22'}- '@typeonce/[email protected]':- resolution: {integrity: sha512-ZuxJ4QsVGXuiRphmKQq63Dv2p58mww1nAoKPcH99tucO6GIqcFhp7up9OOjEB8eABjG+Xe2k6bIImrSUWaJNbQ==}+ '@typeonce/ritmo-netcode@file:../tarballs/typeonce-ritmo-netcode-0.23.0.tgz':+ resolution: {integrity: sha512-TIll6p8CDdW06jhHYAwz0+2IeUPeB80l8WgmI18J01RkeytyE/A0VVqg2T6kZGkHNFdwP7QBzwD8ABSW1skY+A==, tarball: file:../tarballs/typeonce-ritmo-netcode-0.23.0.tgz}+ version: 0.23.0engines: {node: '>=22'}- '@typeonce/[email protected]':- resolution: {integrity: sha512-TQb3qz95nIviINN0Oz7AVfK5HNlIueeHswi1m3IdizPqA699LicWfB7zqu3Lstjk2jjY90ydkm7Kn/tbCgdx0w==}+ '@typeonce/ritmo-pixi@file:../tarballs/typeonce-ritmo-pixi-0.23.0.tgz':+ resolution: {integrity: sha512-+iSw1GMuGnEnFQ+vAngqvPTVVhMiAxQRRYODWCCcAI4pkxxpJ24lZFIJm2fOUQ66cL/vZ5zeS/yPydvwMmMzFw==, tarball: file:../tarballs/typeonce-ritmo-pixi-0.23.0.tgz}+ version: 0.23.0engines: {node: '>=22'}- '@typeonce/[email protected]':- resolution: {integrity: sha512-T4lmbL4Jmg+A2B4mYACLlQoGHgxrvjKt/fyh4uFT25NjPHi+cvEcpAbhUBDnXl29u5SiI2nxpamTSJhtEJ8TJw==}+ '@typeonce/ritmo-render@file:../tarballs/typeonce-ritmo-render-0.23.0.tgz':+ resolution: {integrity: sha512-bRFYARVHVrIhKVSvi/I0zgWWp/pCnnNsl5kFJfL/oBeYQt2xJj5iPDVmDwPymLI3t1udHtQkOZyLAajxJXtTPA==, tarball: file:../tarballs/typeonce-ritmo-render-0.23.0.tgz}+ version: 0.23.0engines: {node: '>=22'}- '@typeonce/[email protected]':- resolution: {integrity: sha512-D54ym3xSrp1LSM94cRYw87AIqIQT/yte1fidklxD9+We4fF3+rsVeu2z6fozjY81VE4Pml/pmMt1HDz7wQoi3Q==}+ '@typeonce/ritmo@file:../tarballs/typeonce-ritmo-0.23.0.tgz':+ resolution: {integrity: sha512-rD/gzl7HV4c2yBqitjD3Shddk6ZqqXQUeWm8OZINoIEVMhHwx8i3mDYr8PJNVV1pK+1wAtAxEtTwydJuNGAGTw==, tarball: file:../tarballs/typeonce-ritmo-0.23.0.tgz}+ version: 0.23.0engines: {node: '>=22'}peerDependencies:typescript: '>=5.9'@@ -823,21 +842,21 @@ snapshots:'@tweenjs/[email protected]': {}- '@typeonce/[email protected]([email protected])':+ '@typeonce/oxlint-plugin-ritmo@file:../tarballs/typeonce-oxlint-plugin-ritmo-0.23.0.tgz([email protected])':dependencies:'@oxlint/plugins': 1.88.0oxlint: 1.92.0- '@typeonce/[email protected]([email protected])':+ '@typeonce/ritmo-browser@file:../tarballs/typeonce-ritmo-browser-0.23.0.tgz([email protected])':dependencies:- '@typeonce/ritmo': 0.22.0([email protected])+ '@typeonce/ritmo': file:../tarballs/typeonce-ritmo-0.23.0.tgz([email protected])transitivePeerDependencies:- typescript- '@typeonce/[email protected]([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected]))':+ '@typeonce/ritmo-devtools@file:../tarballs/typeonce-ritmo-devtools-0.23.0.tgz([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected]))':dependencies:- '@typeonce/ritmo': 0.22.0([email protected])- '@typeonce/ritmo-netcode': 0.22.0([email protected])+ '@typeonce/ritmo': file:../tarballs/typeonce-ritmo-0.23.0.tgz([email protected])+ '@typeonce/ritmo-netcode': file:../tarballs/typeonce-ritmo-netcode-0.23.0.tgz([email protected])optionalDependencies:oxlint: 1.92.0playwright: 1.64.0@@ -846,31 +865,31 @@ snapshots:transitivePeerDependencies:- typescript- '@typeonce/[email protected]([email protected])':+ '@typeonce/ritmo-math@file:../tarballs/typeonce-ritmo-math-0.23.0.tgz([email protected])':dependencies:- '@typeonce/ritmo': 0.22.0([email protected])+ '@typeonce/ritmo': file:../tarballs/typeonce-ritmo-0.23.0.tgz([email protected])transitivePeerDependencies:- typescript- '@typeonce/[email protected]([email protected])':+ '@typeonce/ritmo-netcode@file:../tarballs/typeonce-ritmo-netcode-0.23.0.tgz([email protected])':dependencies:- '@typeonce/ritmo': 0.22.0([email protected])+ '@typeonce/ritmo': file:../tarballs/typeonce-ritmo-0.23.0.tgz([email protected])transitivePeerDependencies:- typescript- '@typeonce/[email protected]([email protected])':+ '@typeonce/ritmo-pixi@file:../tarballs/typeonce-ritmo-pixi-0.23.0.tgz([email protected])':dependencies:- '@typeonce/ritmo-render': 0.22.0([email protected])+ '@typeonce/ritmo-render': file:../tarballs/typeonce-ritmo-render-0.23.0.tgz([email protected])transitivePeerDependencies:- typescript- '@typeonce/[email protected]([email protected])':+ '@typeonce/ritmo-render@file:../tarballs/typeonce-ritmo-render-0.23.0.tgz([email protected])':dependencies:- '@typeonce/ritmo': 0.22.0([email protected])+ '@typeonce/ritmo': file:../tarballs/typeonce-ritmo-0.23.0.tgz([email protected])transitivePeerDependencies:- typescript- '@typeonce/[email protected]([email protected])':+ '@typeonce/ritmo@file:../tarballs/typeonce-ritmo-0.23.0.tgz([email protected])':optionalDependencies:typescript: 7.0.2diff --git a/src/game/schedule.ts b/src/game/schedule.tsindex bcaa239..42719e6 100644--- a/src/game/schedule.ts+++ b/src/game/schedule.ts@@ -14,13 +14,14 @@ import { DropOrphans } from "./systems/orphans/index.ts"import { Approve, foundedFate, Judge, Record, Requests, Seasons } from "./systems/term/index.ts"import { Collect, Households, TakeCensus } from "./systems/town/index.ts"import { SendWalkers, Walk, Wander } from "./systems/walkers/index.ts"-import { AssignStaff, CountStock, Grow, IndexGrid, Plant, Raise, Spread, Work } from "./systems/work/index.ts"+import { AssignStaff, CountStock, Grow, IndexGrid, Plant, Raise, Spread, SumStock, Work } from "./systems/work/index.ts"export const AdvanceTime = Clock.system(Game, { name: "Town/AdvanceTime", resource: Time })export const simulate = Game.Schedule(AdvanceTime,- // Edits see the stock as the last step left it, and index the grid themselves.+ // Edits see the stock as the last step left it (or a load: see SumStock), and index the grid themselves.+ SumStock,ApplyEdits,Game.Schedule.applyDeferred(),IndexGrid,@@ -61,7 +62,7 @@ export const simulate = Game.Schedule(* while the town waits (paused, founding, or a term over) and must not move it* on, such as the guide's.*/-export const settle = Game.Schedule(ApplyEdits, Game.Schedule.applyDeferred())+export const settle = Game.Schedule(SumStock, ApplyEdits, Game.Schedule.applyDeferred())/** The world's resources before any town is founded (a `newTown` edit fills them in). */export const blankResources = () => ({diff --git a/src/game/systems/edits/apply-edits.ts b/src/game/systems/edits/apply-edits.tsindex a51c843..5a59a36 100644--- a/src/game/systems/edits/apply-edits.ts+++ b/src/game/systems/edits/apply-edits.ts@@ -245,7 +245,7 @@ export const ApplyEdits = Game.System(left.stone = (left.stone ?? 0) - PAVE_COST.stonestone += PAVE_COST.stonepaved.add(road)- commands.insert(road, Game.Command.entry(Paved, {}))+ commands.insert(road, [Paved, {}])}take({ stone })if (short) events.toast.emit(short)@@ -375,7 +375,7 @@ export const ApplyEdits = Game.System(const { data: built } = queries.builtif (!row?.ok || halls.has(owner) || built.site.has(row.value) || built.paused.has(row.value) === edit.on) breakif (!built.building.has(row.value) && !built.house.has(row.value)) break- if (edit.on) commands.insert(row.value, Game.Command.entry(Paused, {}))+ if (edit.on) commands.insert(row.value, [Paused, {}])else commands.remove(row.value, Paused)break}@@ -447,7 +447,7 @@ export const ApplyEdits = Game.System(coins -= up.cost.coinsbegun.add(row.value.id)const owed = amounts(up.cost.materials)- commands.insert(row.value, Game.Command.entry(Works, { owed, total: total(owed), done: 0, level: (level + 1) as 1 | 2 }))+ commands.insert(row.value, [Works, { owed, total: total(owed), done: 0, level: (level + 1) as 1 | 2 }])const was = (upgradeAt(kind, level)?.title ?? kind.title).toLowerCase()write(resources.chronicle, t, `Works begin on the ${was}: it is to be ${anA(up.title.toLowerCase())}.`)events.toast.emit(`${up.title} · −${up.cost.coins} coins · carriers bring ${costText({ coins: 0, materials: up.cost.materials })}`)@@ -481,7 +481,7 @@ export const ApplyEdits = Game.System(const id = commands.spawn(buildingDraft(hall, land.hall))commands.insert(id, ...rolesOf(hall, rules))const stock: Amounts = amounts(richness.stock)- commands.insert(id, Game.Command.entry(TownHall, {}), Game.Command.entry(Status, "idle"), Game.Command.entry(Inventory, { stock, accepts: goodIds, cap: hall.holds?.cap ?? 60 }))+ commands.insert(id, [TownHall, {}], [Status, "idle"], [Inventory, { stock, accepts: goodIds, cap: hall.holds?.cap ?? 60 }])coins = richness.coinsconst founded = resources.time.get().step// The almanac: each year's winter, from the seed (on its own stream, so the land's randomness is untouched).diff --git a/src/game/systems/hazards/hazards.ts b/src/game/systems/hazards/hazards.tsindex b5b0ea2..387b309 100644--- a/src/game/systems/hazards/hazards.ts+++ b/src/game/systems/hazards/hazards.ts@@ -125,13 +125,13 @@ export const Hazards = Game.System(const id = fires.nextfires.next += 1fires.fires.push({ id, x: tile.x, y: tile.y, homes: 0, buildings: 0 })- commands.insert(row, Game.Command.entry(Burning, { left: risk.fire.burns, fire: id }))+ commands.insert(row, [Burning, { left: risk.fire.burns, fire: id }])ignited.set(row.id, id)r.fire = 0news(`Fire on ${where(tile)}!`, tile)}if (h && r.health >= RISK_MAX && !cared.sick.has(row)) {- commands.insert(row, Game.Command.entry(Sick, { left: risk.health.lasts }))+ commands.insert(row, [Sick, { left: risk.health.lasts }])r.health = 0if (sickNow === 0) news(`Sickness on ${where(tile)}: a physician can cure it.`, tile)}@@ -216,7 +216,7 @@ export const Hazards = Game.System(if (!neighbour) continueconst chance = risk.fire.catches + (risk.fire.spread * cared.risk.get(neighbour).fire) / RISK_MAXif (random.next() < chance) {- commands.insert(neighbour, Game.Command.entry(Burning, { left: risk.fire.burns, fire: b.fire }))+ commands.insert(neighbour, [Burning, { left: risk.fire.burns, fire: b.fire }])ignited.set(neighbour.id, b.fire)}}diff --git a/src/game/systems/town/households.ts b/src/game/systems/town/households.tsindex 196dfbf..6b9749c 100644--- a/src/game/systems/town/households.ts+++ b/src/game/systems/town/households.ts@@ -90,7 +90,7 @@ export const Households = Game.System(if (tier <= h.tier || tier <= built) next.tier = tierelse if (pay(home.tiers[tier].rise)) {next.tier = tier- commands.insert(entity, Game.Command.entry(Rebuilt, { tier: tier as 2 | 3 }))+ commands.insert(entity, [Rebuilt, { tier: tier as 2 | 3 }])}const well = connected(grid, tile) ? capacity(next, approval, desirability, rules, rateOf(policy, next.tier)) : 0const cap = data.sick.has(entity) ? Math.floor(well * risk.health.sickly) : welldiff --git a/src/game/systems/walkers/send-walkers.ts b/src/game/systems/walkers/send-walkers.tsindex 9e25e3e..84c0a1a 100644--- a/src/game/systems/walkers/send-walkers.ts+++ b/src/game/systems/walkers/send-walkers.ts@@ -90,7 +90,7 @@ export const SendWalkers = Game.System(const cursor = patrol.ok ? queries.patrols.data.patrol.get(patrol.value).next : 0const tour = plan.tours[cursor % plan.tours.length]!if (patrol.ok) queries.patrols.data.patrol.set(patrol.value, { next: (cursor + 1) % plan.tours.length })- else commands.insert(entity, Game.Command.entry(Patrol, { next: 1 % plan.tours.length }))+ else commands.insert(entity, [Patrol, { next: 1 % plan.tours.length }])const color = categoryColor[kinds[data.building.get(entity).kind].category]const draft = Game.Command.spawn([Figure, { role: "walker", color }],diff --git a/src/game/systems/work/count-stock.ts b/src/game/systems/work/count-stock.tsindex ac471b3..e51fe9a 100644--- a/src/game/systems/work/count-stock.ts+++ b/src/game/systems/work/count-stock.ts@@ -6,6 +6,28 @@ import { each } from "./per-good.ts"const FLOW_SLICE = 10const FLOW_SLICES = 6+/** The goods in every storage, summed. */+const StoresRead = Game.Query({ selection: { inventory: Game.Query.read(Inventory) }, with: [Storage], without: [Site, Rising] })++/**+ * The goods in every storage, summed, before anything reads them in a step.+ * `Stock` is not saved, and a load gives it its empty start (Ritmo 0.23):+ * this fills it from the loaded world, so edits and the seasons see the+ * town's stock in the first step after a load as in any other.+ */+export const SumStock = Game.System(+ "Town/SumStock",+ { queries: { stores: StoresRead }, resources: { stock: Game.System.writeResource(Stock) } },+ ({ queries, resources }) => {+ const sum: Record<string, number> = { ...amounts({}) }+ for (const entity of queries.stores.each()) {+ const s = queries.stores.data.inventory.get(entity).stock+ for (const g of goodIds) sum[g] = (sum[g] ?? 0) + s[g]+ }+ resources.stock.set(sum as Amounts)+ }+)+/*** The goods in every storage, summed; and everything the town holds,* anywhere, for the minute's `Flow`, which closes every minute.@@ -14,7 +36,7 @@ export const CountStock = Game.System("Town/CountStock",{queries: {- stores: Game.Query({ selection: { inventory: Game.Query.read(Inventory) }, with: [Storage], without: [Site, Rising] }),+ stores: StoresRead,shelves: Game.Query({ selection: { inventory: Game.Query.read(Inventory) }, without: [Site, Rising] }),baskets: Game.Query({ selection: { roam: Game.Query.read(Roam) } }),crates: Game.Query({ selection: { errand: Game.Query.read(Errand) } })diff --git a/src/game/systems/work/index.ts b/src/game/systems/work/index.tsindex cceada6..0941305 100644--- a/src/game/systems/work/index.ts+++ b/src/game/systems/work/index.ts@@ -7,7 +7,7 @@export { effort, paced } from "../../rules/production.ts"export { IndexGrid } from "./index-grid.ts"-export { CountStock } from "./count-stock.ts"+export { CountStock, SumStock } from "./count-stock.ts"// ── Going up ──────────────────────────────────────────────────────────────diff --git a/src/game/systems/work/raise.ts b/src/game/systems/work/raise.tsindex a69465d..705318d 100644--- a/src/game/systems/work/raise.ts+++ b/src/game/systems/work/raise.ts@@ -67,13 +67,13 @@ export const Raise = Game.System(if (total(works.owed) > 0 || works.done < needed) continueconst base = rules.kinds[data.building.get(entity).kind], kind = asUpgraded(base, works.level)commands.remove(entity, Works)- commands.insert(entity, Game.Command.entry(Upgraded, { level: works.level }))+ commands.insert(entity, [Upgraded, { level: works.level }])data.staff.set(entity, { ...data.staff.get(entity), needed: kind.workers })const recipe = data.recipe.get(entity), carriers = data.carriers.get(entity), service = data.service.get(entity)- if (recipe && kind.recipe) commands.insert(entity, Game.Command.entry(Recipe, { ...recipe, period: stepsOf(kind.recipe.seconds) }))+ if (recipe && kind.recipe) commands.insert(entity, [Recipe, { ...recipe, period: stepsOf(kind.recipe.seconds) }])if (shelves.ok && kind.holds) stocked.inventory.set(shelves.value, { ...stocked.inventory.get(shelves.value), cap: kind.holds.cap })- if (carriers && kind.carriers) commands.insert(entity, Game.Command.entry(Carriers, { count: kind.carriers }))- if (service && kind.service) commands.insert(entity, Game.Command.entry(Service, { ...service, interval: stepsOf(kind.service.seconds), range: kind.service.range }))+ if (carriers && kind.carriers) commands.insert(entity, [Carriers, { count: kind.carriers }])+ if (service && kind.service) commands.insert(entity, [Service, { ...service, interval: stepsOf(kind.service.seconds), range: kind.service.range }])const was = (upgradeAt(base, works.level - 1)?.title ?? base.title).toLowerCase()write(resources.chronicle, elapsed(resources.time.get(), resources.charter.get()), `The ${was} is now ${anA(upgradeAt(base, works.level)!.title.toLowerCase())}.`, true)}@@ -82,7 +82,7 @@ export const Raise = Game.System(for (const entity of queries.sites.each()) {if (total(sites.site.get(entity).owed) > 0) continuecommands.remove(entity, Site)- commands.insert(entity, Game.Command.entry(Rising, { ticks: Math.round(BUILD_TICKS * SITE_SHARE) }))+ commands.insert(entity, [Rising, { ticks: Math.round(BUILD_TICKS * SITE_SHARE) }])}const rising = queries.rising.datafor (const entity of queries.rising.each()) {@@ -90,7 +90,7 @@ export const Raise = Game.System(if (ticks >= BUILD_TICKS) {commands.remove(entity, Rising)// Up and standing; its work (if it has any) says otherwise from here on.- if (rising.status.has(entity)) commands.insert(entity, Game.Command.entry(Status, "idle"))+ if (rising.status.has(entity)) commands.insert(entity, [Status, "idle"])} else rising.rising.set(entity, { ticks })}}diff --git a/src/game/world/archetypes.ts b/src/game/world/archetypes.tsindex 5a8d20b..f3c8a2a 100644--- a/src/game/world/archetypes.ts+++ b/src/game/world/archetypes.ts@@ -13,7 +13,7 @@ import { stepsOf } from "../content/index.ts"const site = (cost: Kind["cost"]) => {const owed = amounts(cost.materials)- return total(owed) > 0 ? Game.Command.entry(Site, { owed, total: total(owed) }) : Game.Command.entry(Rising, { ticks: 0 })+ return total(owed) > 0 ? [Site, { owed, total: total(owed) }] as const : [Rising, { ticks: 0 }] as const}/** A building of `kind` on `cell`: a site waiting for materials, or (`standing`) already up. */@@ -29,8 +29,8 @@ export const buildingDraft = (kind: Kind, cell: Point) =>export const WearParts = [Risk, Condition] as const/** What every home and every working building carries: its risks, and how well kept it is. */export const wearOf = (rules: Rules = shippedRules) => [- Game.Command.entry(Risk, { fire: 0, health: 0, order: 0, thefts: 0 }),- Game.Command.entry(Condition, { value: rules.conditionMax })+ [Risk, { fire: 0, health: 0, order: 0, thefts: 0 }] as const,+ [Condition, { value: rules.conditionMax }] as const]/** The components `startOf` (and `houseStart`) may insert: owed materials, or rising. */@@ -45,29 +45,29 @@ export const rolesOf = (kind: Kind, rules: Rules = shippedRules) => {const roles = []if (kind.recipe) {const r = kind.recipe- roles.push(Game.Command.entry(Recipe, { input: r.input, inputs: r.inputs, output: r.output, batch: r.batch, period: stepsOf(r.seconds), progress: 0, made: 0 }))+ roles.push([Recipe, { input: r.input, inputs: r.inputs, output: r.output, batch: r.batch, period: stepsOf(r.seconds), progress: 0, made: 0 }] as const)}- if (kind.gathers) roles.push(Game.Command.entry(Gatherer, { source: kind.gathers.source, radius: kind.gathers.radius }))+ if (kind.gathers) roles.push([Gatherer, { source: kind.gathers.source, radius: kind.gathers.radius }] as const)if (kind.plants) {const p = kind.plants- roles.push(Game.Command.entry(Planter, { what: p.what, radius: p.radius, interval: stepsOf(p.seconds), cooldown: 0, max: p.max }))+ roles.push([Planter, { what: p.what, radius: p.radius, interval: stepsOf(p.seconds), cooldown: 0, max: p.max }] as const)}// A workshop that wears out tools keeps a few on its shelf too.const tools = kind.wear ? ["tools" as const] : []if (kind.holds) {const all = kind.holds.accepts === "all"const accepts = all ? goodIds : [...kind.holds.accepts, ...tools.filter((g) => !kind.holds!.accepts.includes(g))]- roles.push(Game.Command.entry(Inventory, { stock: amounts({}), accepts, cap: kind.holds.cap }))+ roles.push([Inventory, { stock: amounts({}), accepts, cap: kind.holds.cap }] as const)// Storage takes in and sends out any good it accepts: everything, or (a granary) food.- if (all || kind.keeps) roles.push(Game.Command.entry(Storage, {}))+ if (all || kind.keeps) roles.push([Storage, {}] as const)} else if (kind.recipe) {// A gatherer keeps what it makes until a carrier takes it.- roles.push(Game.Command.entry(Inventory, { stock: amounts({}), accepts: [kind.recipe.output, ...tools], cap: 8 }))+ roles.push([Inventory, { stock: amounts({}), accepts: [kind.recipe.output, ...tools], cap: 8 }] as const)}- if (kind.carriers) roles.push(Game.Command.entry(Carriers, { count: kind.carriers }))+ if (kind.carriers) roles.push([Carriers, { count: kind.carriers }] as const)if (kind.service) {const s = kind.service- roles.push(Game.Command.entry(Service, { service: s.service, interval: stepsOf(s.seconds), cooldown: 0, range: s.range }))+ roles.push([Service, { service: s.service, interval: stepsOf(s.seconds), cooldown: 0, range: s.range }] as const)}// The town hall neither burns nor wears.if (kind.id !== "townhall") roles.push(...wearOf(rules))diff --git a/src/render/three/sync.ts b/src/render/three/sync.tsindex fc5c30f..741e948 100644--- a/src/render/three/sync.ts+++ b/src/render/three/sync.ts@@ -2,6 +2,11 @@* The world's entities mirrored into the Three.js scene: a view for each* building, home, walker, tree, rock, ruin, and field, made when it appears,* placed on its tile, and removed when it goes (see `@typeonce/ritmo-render`).+ *+ * A node is made again whenever its renderable takes a new value, so homes,+ * trees, rocks, and fields (whose components change as they fill, grow, and+ * are worked) are keyed by their `Tile`, which never changes, and selected+ * by their own component; `Animate` draws what changes on them each frame.*/import { RenderSync } from "@typeonce/ritmo-render"@@ -21,7 +26,8 @@ export const RenderBuildings = RenderSync.system(Game, {export const RenderHouses = RenderSync.system(Game, {name: "Town/RenderHouses",- renderable: House,+ renderable: Tile,+ select: { house: Game.Query.read(House) },transform: Tile,registry: HouseNodes,services: { stage: StageService },@@ -40,7 +46,8 @@ export const RenderWalkers = RenderSync.system(Game, {export const RenderTrees = RenderSync.system(Game, {name: "Town/RenderTrees",- renderable: Tree,+ renderable: Tile,+ select: { tree: Game.Query.read(Tree) },transform: Tile,registry: TreeNodes,services: { stage: StageService },@@ -50,7 +57,8 @@ export const RenderTrees = RenderSync.system(Game, {export const RenderRocks = RenderSync.system(Game, {name: "Town/RenderRocks",- renderable: Rock,+ renderable: Tile,+ select: { rock: Game.Query.read(Rock) },transform: Tile,registry: RockNodes,services: { stage: StageService },@@ -70,7 +78,8 @@ export const RenderRuins = RenderSync.system(Game, {export const RenderFields = RenderSync.system(Game, {name: "Town/RenderFields",- renderable: Field,+ renderable: Tile,+ select: { field: Game.Query.read(Field) },transform: Tile,registry: FieldNodes,services: { stage: StageService },diff --git a/test/save.test.ts b/test/save.test.tsindex ad45e4d..cbb5513 100644--- a/test/save.test.ts+++ b/test/save.test.ts@@ -118,13 +118,18 @@ test("a world that cannot be saved says so, and writes nothing", () => {assert.equal(storage.files.size, 0)})-/** A snapshot's world, keys sorted, without its format and game versions: what plays. */+/**+ * A snapshot's world, keys sorted, without its format and game versions: what plays.+ * Ritmo 0.23 saves the next states queued for the next marker (`nextStates`); with none+ * queued it is `{}`, which the world played on 0.9 had no field for.+ */const fingerprint = (world: object) => {const canonical = (value: unknown): unknown =>Array.isArray(value) ? value.map(canonical): value !== null && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((k) => [k, canonical((value as Record<string, unknown>)[k])])): value- const { version: _, gameVersion: __, ...rest } = world as { version: unknown; gameVersion: unknown }+ const { version: _, gameVersion: __, ...rest } = world as { version: unknown; gameVersion: unknown; nextStates?: object }+ if (rest.nextStates !== undefined && Object.keys(rest.nextStates).length === 0) delete rest.nextStatesreturn createHash("sha1").update(JSON.stringify(canonical(rest))).digest("hex")}