Skip to content

A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D

Upgrade to Ritmo 0.9.0

SandroMaglionec801b022d066
diff --git a/package.json b/package.json
index 1125603..962b6b1 100644
--- a/package.json
+++ b/package.json
@@ -32,17 +32,18 @@
"engine:prepare": "node scripts/use-ritmo.ts"
},
"dependencies": {
- "@typeonce/ritmo": "0.8.0",
- "@typeonce/ritmo-browser": "0.8.0",
- "@typeonce/ritmo-math": "0.8.0",
- "@typeonce/ritmo-pixi": "0.8.0",
- "@typeonce/ritmo-render": "0.8.0",
+ "@typeonce/ritmo": "0.9.0",
+ "@typeonce/ritmo-browser": "0.9.0",
+ "@typeonce/ritmo-math": "0.9.0",
+ "@typeonce/ritmo-pixi": "0.9.0",
+ "@typeonce/ritmo-render": "0.9.0",
"effect": "4.0.3",
"pixi.js": "^8.22.0",
"three": "^0.186.1"
},
"devDependencies": {
- "@typeonce/ritmo-devtools": "0.8.0",
+ "@typeonce/oxlint-plugin-ritmo": "0.9.0",
+ "@typeonce/ritmo-devtools": "0.9.0",
"@types/node": "25.5.0",
"@types/three": "^0.186.0",
"oxlint": "1.87.0",
@@ -50,5 +51,5 @@
"typescript": "7.0.2",
"vite": "8.3.1"
},
- "ritmoRelease": "0.8.0"
+ "ritmoRelease": "0.9.0"
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b5d3ccf..a522809 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -9,20 +9,20 @@ importers:
.:
dependencies:
'@typeonce/ritmo':
- specifier: 0.8.0
- version: 0.8.0([email protected])
+ specifier: 0.9.0
+ version: 0.9.0([email protected])
'@typeonce/ritmo-browser':
- specifier: 0.8.0
- version: 0.8.0([email protected])
+ specifier: 0.9.0
+ version: 0.9.0([email protected])
'@typeonce/ritmo-math':
- specifier: 0.8.0
- version: 0.8.0([email protected])
+ specifier: 0.9.0
+ version: 0.9.0([email protected])
'@typeonce/ritmo-pixi':
- specifier: 0.8.0
- version: 0.8.0([email protected])
+ specifier: 0.9.0
+ version: 0.9.0([email protected])
'@typeonce/ritmo-render':
- specifier: 0.8.0
- version: 0.8.0([email protected])
+ specifier: 0.9.0
+ version: 0.9.0([email protected])
effect:
specifier: 4.0.3
version: 4.0.3
@@ -33,9 +33,12 @@ importers:
specifier: ^0.186.1
version: 0.186.1
devDependencies:
+ '@typeonce/oxlint-plugin-ritmo':
+ specifier: 0.9.0
+ version: 0.9.0([email protected])
'@typeonce/ritmo-devtools':
- specifier: 0.8.0
- version: 0.8.0([email protected])
+ specifier: 0.9.0
+ version: 0.9.0([email protected])
'@types/node':
specifier: 25.5.0
version: 25.5.0
@@ -177,6 +180,10 @@ packages:
cpu: [x64]
os: [win32]
+ '@oxlint/[email protected]':
+ resolution: {integrity: sha512-G2xbfWTrbqYRhR/vfeKNMQf/sS3/ti0iKJAAkRxHuXWZH/hne/dyIb9QKk5LuR6cJLARxsL6FMoAYmfspd74MQ==}
+ engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
+
resolution: {integrity: sha512-nezytU2pw587fQstUu1AsJZDVEynjskwOL+kibwcdxsMBFqPsFFNA7xl0ii/gXuDi6M0xj3mfRJj8pBSc2jCfA==}
@@ -276,29 +283,35 @@ packages:
'@tweenjs/[email protected]':
resolution: {integrity: sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==}
- '@typeonce/[email protected]':
- resolution: {integrity: sha512-/NusLAYF/SHjIstJVdW9rnAKtY6+AE7ohy6zvnEiFAfwwY1HjwOfw2YjHB5Ry0eyiWSX/1py/y7C9F7eMFdH2Q==}
+ '@typeonce/[email protected]':
+ resolution: {integrity: sha512-MZf66alkTFUcmQ5X/+5DNXh5TsP9zFqd8m1RG0v5s+JVXp2nr1b00S83vE12/PJGBGqIMjWOJlVX65P6vTA3gg==}
+ engines: {node: '>=20'}
+ peerDependencies:
+ oxlint: '>=1.86.0'
+
+ '@typeonce/[email protected]':
+ resolution: {integrity: sha512-EKALcrcs5QsOoZjO839HDAuOG+QzjNSRush2YOb5NbvB6b6JMyarRFIH4qwJCQRdWBdX+qMYkDOksDu8yCkD5A==}
engines: {node: '>=20'}
- '@typeonce/[email protected]':
- resolution: {integrity: sha512-1+tXZE3kcRwG6rodtvzVYTW0LzSse+ud2YuzPSE/WHx5Mg2sOTQBXpZT03fDGOu9BbA4blt11rOrceA1C18DKQ==}
+ '@typeonce/[email protected]':
+ resolution: {integrity: sha512-9Bj6wN3afeNkaEizHApXrcMODelwYdOUaf/TbMDBkPGkRKu6u8Kytc7rK1r1QxPbMOiilntb4WHOS1/s2E+mLA==}
engines: {node: '>=20'}
hasBin: true
- '@typeonce/[email protected]':
- resolution: {integrity: sha512-EAr6bHDeGhL0vWUii+hrshNbW6jmX1J3P0EwD2+lMN7InAj/LtAfMNSB72/5zNrMtUWgayXKOPWmobGsRsiMkw==}
+ '@typeonce/[email protected]':
+ resolution: {integrity: sha512-JzlKMIQ5tRo875d/RguyJv2ArVCVIQVZL5D8acxFyXGWKKN2/tjp/F7KjQDMCi0bQ/iiM5w3k6+o53kn3S/Bcw==}
engines: {node: '>=20'}
- '@typeonce/[email protected]':
- resolution: {integrity: sha512-jE4CahYLamJ75aTdogJ6mQtCBRB9NXp2GCLhnFu25t399b/RfrVlUMxL9LaSU5emVsTu2w2a/R3hYuOcPc6wHA==}
+ '@typeonce/[email protected]':
+ resolution: {integrity: sha512-a6eg/y8EOQx9h9R/dI//ivvzTMYGYkEFP3HAOoAvP/5pCe9iDwcYKnVIC3WNWEH8pkpatLzmq0vIskiQNKp01w==}
engines: {node: '>=20'}
- '@typeonce/[email protected]':
- resolution: {integrity: sha512-G85irkBDY58xfZg7TSGtipTT1GABoNcSUSGijn5MvirzPw06clRq/dbbs+jW7lQ8l0POMwBrqUemOgBRJCi5eA==}
+ '@typeonce/[email protected]':
+ resolution: {integrity: sha512-E44lPGnD4yNp0aPsuclILVTiAkQI4Dna+J12PDzZMajmyILZRPXarbQvWj/E9GiwaJf7wPxzTFODXGGDGKjK2w==}
engines: {node: '>=20'}
- '@typeonce/[email protected]':
- resolution: {integrity: sha512-0Gfp2LhZyUYAllRb2EQpNhSPeZHQGZ7yD+AWfictdFrv/Eo44p+U63zm1r1VL6yCRCJmyBNF43XarZ6mjMgA2A==}
+ '@typeonce/[email protected]':
+ resolution: {integrity: sha512-OwpqEh2oAbUP+lDigEkNIrT2104mIaInjKdad9eHuy+VA3OjioX71XT8Bw3e37giGwfcCkkFaU4UvZx7sAg4bQ==}
engines: {node: '>=20'}
peerDependencies:
typescript: '>=5.9'
@@ -739,6 +752,8 @@ snapshots:
'@oxlint/[email protected]':
optional: true
+ '@oxlint/[email protected]': {}
+
'@pixi/[email protected]': {}
'@rolldown/[email protected]':
@@ -790,37 +805,42 @@ snapshots:
'@tweenjs/[email protected]': {}
+ dependencies:
+ '@oxlint/plugins': 1.88.0
+ oxlint: 1.87.0
+
dependencies:
- '@typeonce/ritmo': 0.8.0([email protected])
+ '@typeonce/ritmo': 0.9.0([email protected])
transitivePeerDependencies:
- typescript
dependencies:
- '@typeonce/ritmo': 0.8.0([email protected])
+ '@typeonce/ritmo': 0.9.0([email protected])
transitivePeerDependencies:
- typescript
dependencies:
- '@typeonce/ritmo': 0.8.0([email protected])
+ '@typeonce/ritmo': 0.9.0([email protected])
transitivePeerDependencies:
- typescript
dependencies:
- '@typeonce/ritmo-render': 0.8.0([email protected])
+ '@typeonce/ritmo-render': 0.9.0([email protected])
transitivePeerDependencies:
- typescript
dependencies:
- '@typeonce/ritmo': 0.8.0([email protected])
+ '@typeonce/ritmo': 0.9.0([email protected])
transitivePeerDependencies:
- typescript
optionalDependencies:
typescript: 7.0.2
diff --git a/src/main.ts b/src/main.ts
index e068a87..2b779d8 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -4,9 +4,9 @@ import { resolveRules } from "./rules/config.ts"
* bevy-ts ECS with a 3D view. The simulation runs on a fixed step;
* the views follow once a frame.
*/
-import { HostClock, Result } from "@typeonce/ritmo"
+import { FixedLoop, HostClock, Result } from "@typeonce/ritmo"
import { Effect } from "effect"
-import { BrowserHostClock, FixedLoop } from "@typeonce/ritmo-browser"
+import { BrowserHostClock } from "@typeonce/ritmo-browser"
import type { BuildingView, FieldView, HouseView, RockView, RuinView, TreeView, WalkerView } from "./render3d/views.ts"
import { lands, sizes, step } from "./content.ts"
diff --git a/src/sim/hazards.ts b/src/sim/hazards.ts
index 3b30cdd..5135b8f 100644
--- a/src/sim/hazards.ts
+++ b/src/sim/hazards.ts
@@ -115,7 +115,8 @@ export const Hazards = Game.System(
Game.System.spawns(Ruin, Rescue),
Game.System.inserts(Burning, Sick),
Game.System.removes(Sick),
- Game.System.despawns(Tile)
+ Game.System.despawns(Tile),
+ Game.System.relates(WalkerOf)
)
},
({ queries, resources, commands, services }) => {
diff --git a/src/sim/index.ts b/src/sim/index.ts
index a094b95..798ec1d 100644
--- a/src/sim/index.ts
+++ b/src/sim/index.ts
@@ -9,6 +9,7 @@ import { ApplyEdits } from "./edits.ts"
import { Deliver, Dispatch } from "./logistics.ts"
import { Decay } from "./decay.ts"
import { Appraise, Douse, Hazards } from "./hazards.ts"
+import { DropOrphans } from "./orphans.ts"
import { Approve, foundedFate, Judge, Record, Requests, Seasons } from "./term.ts"
import { Collect, Households, TakeCensus } from "./town.ts"
import { SendWalkers, Walk, Wander } from "./walkers.ts"
@@ -41,6 +42,8 @@ export const simulate = Game.Schedule(
Households,
Hazards,
Game.Schedule.applyDeferred(),
+ // Walkers and fields whose building went before they joined it go now.
+ DropOrphans,
Decay,
Game.Schedule.applyDeferred(),
Collect,
diff --git a/src/sim/logistics.ts b/src/sim/logistics.ts
index 550b0e1..a70ac95 100644
--- a/src/sim/logistics.ts
+++ b/src/sim/logistics.ts
@@ -55,7 +55,7 @@ export const Dispatch = Game.System(
},
resources: { grid: Game.System.readResource(Grid), appeal: Game.System.readResource(Appeal), time: Game.System.readResource(Time) },
services: { rules: Game.System.service(Rules) },
- commands: Game.System.commands(Game.System.spawns(Errand))
+ commands: Game.System.commands(Game.System.spawns(Errand), Game.System.relates(WalkerOf))
},
({ queries, resources, commands, services }) => {
const rules = services.rules
diff --git a/src/sim/orphans.ts b/src/sim/orphans.ts
new file mode 100644
index 0000000..5935ba3
--- /dev/null
+++ b/src/sim/orphans.ts
@@ -0,0 +1,34 @@
+/**
+ * A walker or a field is spawned already belonging to the building that sent
+ * or sowed it. When that building went in the same step (burnt down while
+ * sending its firefighters, say), the belonging fails and the newcomer would
+ * stay behind with no home: it goes too, as it would have with its building.
+ */
+import { Field, Game, Route, FieldOf, WalkerOf } from "../schema.ts"
+
+export const DropOrphans = Game.System(
+ "Town/DropOrphans",
+ {
+ queries: {
+ walkers: Game.Query({ selection: { route: Game.Query.read(Route) } }),
+ fields: Game.Query({ selection: { field: Game.Query.read(Field) } })
+ },
+ relationFailures: {
+ walkers: Game.System.readRelationFailures(WalkerOf),
+ fields: Game.System.readRelationFailures(FieldOf)
+ },
+ commands: Game.System.commands(Game.System.despawns(Route, Field))
+ },
+ ({ queries, relationFailures, commands }) => {
+ for (const failure of relationFailures.walkers.all()) {
+ if (failure.operation !== "relate") continue
+ const walker = queries.walkers.get(failure.source)
+ if (walker.ok) commands.despawn(walker.value.entity)
+ }
+ for (const failure of relationFailures.fields.all()) {
+ if (failure.operation !== "relate") continue
+ const field = queries.fields.get(failure.source)
+ if (field.ok) commands.despawn(field.value.entity)
+ }
+ }
+)
diff --git a/src/sim/walkers.ts b/src/sim/walkers.ts
index 898e25f..12c0e27 100644
--- a/src/sim/walkers.ts
+++ b/src/sim/walkers.ts
@@ -94,7 +94,7 @@ export const SendWalkers = Game.System(
},
resources: { grid: Game.System.readResource(Grid), time: Game.System.readResource(Time) },
services: { rules: Game.System.service(Rules) },
- commands: Game.System.commands(Game.System.spawns(Roam), Game.System.inserts(Patrol))
+ commands: Game.System.commands(Game.System.spawns(Roam), Game.System.inserts(Patrol), Game.System.relates(WalkerOf))
},
({ queries, resources, commands, services }) => {
const rules = services.rules
diff --git a/src/sim/work.ts b/src/sim/work.ts
index c9dd39f..ee0db4e 100644
--- a/src/sim/work.ts
+++ b/src/sim/work.ts
@@ -530,7 +530,7 @@ export const Plant = Game.System(
},
resources: { grid: Game.System.readResource(Grid), rng: Game.System.writeResource(Rng), time: Game.System.readResource(Time) },
services: { rules: Game.System.service(Rules) },
- commands: Game.System.commands(Game.System.spawns(Tree, Field))
+ commands: Game.System.commands(Game.System.spawns(Tree, Field), Game.System.relates(FieldOf))
},
({ queries, resources, commands, services }) => {
const rules = services.rules