@zaisma/physics 0.0.0-stage → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js ADDED
@@ -0,0 +1,27 @@
1
+ // @zaisma/physics in a player's game: one physics world of bodies and characters, played alone (createPhysics) or
2
+ // shared through a room as a world on the online core (physicsKind), with the same calls either way. The engine
3
+ // under it is Rapier, loaded once with loadPhysics. The reference is index.d.ts. MIT licensed.
4
+ import { charactersKind, defineShape, worldKind } from "../net/index.js";
5
+ import { levelCharactersKindFrom } from "./level-characters.js";
6
+ import { checkId, refuse } from "./declare.js";
7
+ import { alonePhysics, physicsKindFrom } from "./sync.js";
8
+
9
+ export const physicsKind = physicsKindFrom(worldKind);
10
+ export const levelCharactersKind = levelCharactersKindFrom(charactersKind);
11
+ export { definePhysicsWorld } from "./declare.js";
12
+ export { defineCharacterKind, stickVehicleControls, walkStep, walkingCharacters, wishOf } from "./characters.js";
13
+ export { loadPhysics, physicsEngine } from "./engine.js";
14
+ export { loadPhysicsData } from "./data.js";
15
+ export { PieceError } from "../piece/index.js";
16
+
17
+ /**
18
+ * A physics world played alone, with no room: the same calls the kind gives a game online, and update() to call
19
+ * every frame. Throws PieceError "engine_not_loaded" before loadPhysics() has finished.
20
+ */
21
+ export function createPhysics(givenWorld, given = {}) {
22
+ if (given === null || typeof given !== "object" || Object.keys(given).some((key) => !["settings", "hooks", "ticksPerSec", "playerId", "characters"].includes(key))) refuse("unknown_argument", "createPhysics takes a world, then { settings, hooks, ticksPerSec, playerId, characters }.", "given", "Give the world first, then an object with any of those.");
23
+ const { ticksPerSec = 30, playerId = "player" } = given;
24
+ if (!(Number.isInteger(ticksPerSec) && ticksPerSec >= 1 && ticksPerSec <= 60)) refuse("bad_argument", `ticksPerSec is ${JSON.stringify(ticksPerSec)}.`, "ticksPerSec", "Give a whole number from 1 to 60: 30 suits most games.");
25
+ checkId(playerId, "bad_character_id", "playerId");
26
+ return alonePhysics(givenWorld, { settings: given.settings, hooks: given.hooks, ticksPerSec, playerId, characters: given.characters, defineShape });
27
+ }
@@ -0,0 +1,139 @@
1
+ // Characters over a level: a shooter's soldiers, a racer's runners. Each moves on its own every step by its kind's
2
+ // rules against the world's fixed and kinematic bodies (the level), and the online core shares them as characters,
3
+ // not as a world: each player's game predicts only its own character, everyone else is drawn a moment behind, and a
4
+ // hit is judged by what the shooter saw (stateAt and viewTickNumber). Nothing in the level moves, and characters walk
5
+ // through each other: where another player is differs in every game, so it can't be stood against. One copy of the
6
+ // level serves every room a game server runs.
7
+ import { openPiece } from "../piece/index.js";
8
+ import statement from "./piece.json.js";
9
+ import { MAXIMUM_TRIANGLE_GROUP_NUMBER, refuse, worldOf } from "./declare.js";
10
+ import { physicsEngine } from "./engine.js";
11
+ import { defineCharacterKind, walkingCharacters } from "./characters.js";
12
+ import { characterFieldsOf, characterViewOf, levelTuningOf, queriesOver } from "./sync.js";
13
+ import { createSimulation } from "./simulation.js";
14
+
15
+ const GIVEN_KEYS = ["name", "characters", "settings", "playerCharacterMode", "eventNames", "roomFields"];
16
+ /** The fields a character over a level keeps of the piece's own: no seat, nothing to ride. */
17
+ const RIDING_FIELD_NAMES = ["rideBodyNumber", "seatIndex"];
18
+ /** How long a character nobody has stepped stays in the level's memory, in seconds: one that left, or another room's that ended. */
19
+ const FORGOTTEN_AFTER_SEC = 3;
20
+ /** The room's field that says which of the level's triangle groups are off. */
21
+ const GROUPS_FIELD_NAME = "offTriangleGroupMaskNumber";
22
+
23
+ /**
24
+ * Answers levelCharactersKind for one side's online core (its charactersKind, from index.js in a game and server.js
25
+ * on a game server): levelCharactersKind(world, { characters, settings, ... }) is characters that each move on their
26
+ * own over the world's level, a kind of sync for createNet(room).use and defineNetServer's kinds.
27
+ */
28
+ export const levelCharactersKindFrom = (charactersKind) => (givenWorld, given = {}) => {
29
+ if (given === null || typeof given !== "object" || Object.keys(given).some((key) => !GIVEN_KEYS.includes(key))) refuse("unknown_argument", `levelCharactersKind takes a world, then { ${GIVEN_KEYS.join(", ")} }.`, "given", "Give the world first, then an object with any of those.");
30
+ const world = worldOf(givenWorld);
31
+ const kind = given.characters === undefined ? walkingCharacters() : defineCharacterKind(given.characters);
32
+ const { settings } = openPiece(statement, { settings: given.settings });
33
+ // The level: what doesn't move. Bodies that move, and joints, are a world's (physicsKind), never a level's.
34
+ const level = { ...world, bodies: world.bodies.filter((body) => body.motionKind !== "moving"), joints: [] };
35
+ const sharedFields = characterFieldsOf(kind).filter((field) => !RIDING_FIELD_NAMES.includes(field.name));
36
+ // A level whose meshes have triangle groups (doors, bridges) switches them room by room: which are off is the room's own.
37
+ const hasGroups = level.bodies.some((body) => body.shapes.some((shape) => shape.triangleGroupNumbers));
38
+ const roomFields = [...(given.roomFields ?? []), ...(hasGroups ? [{ name: GROUPS_FIELD_NAME, valueKind: "integer", minimumNumber: 0, maximumNumber: 2 ** MAXIMUM_TRIANGLE_GROUP_NUMBER - 1 }] : [])];
39
+ const sharedNames = sharedFields.map((field) => field.name);
40
+ let startCount = 0;
41
+ let simulation = null;
42
+ /** Each room's number, by the core's own part of its state: one level holds every room's characters, apart. */
43
+ const roomNumbers = new WeakMap();
44
+ let nextRoomNumber = 1;
45
+ /** When each character was last stepped, by its key in the level. */
46
+ const steppedAtTickIndex = new Map();
47
+ let lastSweptTickIndex = 0;
48
+
49
+ const simulationFor = (tickDurationSec) => {
50
+ simulation ??= createSimulation(physicsEngine(), level, { tickDurationSec, characterKind: kind, tuning: levelTuningOf(kind, settings), isEachCharacterAlone: true });
51
+ return simulation;
52
+ };
53
+ const roomNumberOf = (roomState) => {
54
+ const holder = roomState?.net;
55
+ if (!holder || typeof holder !== "object") return 0;
56
+ if (!roomNumbers.has(holder)) roomNumbers.set(holder, nextRoomNumber++);
57
+ return roomNumbers.get(holder);
58
+ };
59
+ /** Takes characters nobody has stepped for a while out of the level. */
60
+ function sweep(tickIndex, tickDurationSec) {
61
+ if (tickIndex - lastSweptTickIndex < 1 / tickDurationSec) return;
62
+ lastSweptTickIndex = tickIndex;
63
+ for (const [key, atTickIndex] of steppedAtTickIndex) {
64
+ if (Math.abs(tickIndex - atTickIndex) * tickDurationSec < FORGOTTEN_AFTER_SEC) continue;
65
+ steppedAtTickIndex.delete(key);
66
+ const characterIndex = simulation.characterIndexById.get(key);
67
+ if (characterIndex !== undefined) simulation.removeCharacter(characterIndex);
68
+ }
69
+ }
70
+
71
+ const netKind = charactersKind({
72
+ name: given.name ?? "characters",
73
+ stateFields: sharedFields,
74
+ inputFields: kind.inputFields,
75
+ ...(given.playerCharacterMode === undefined ? {} : { playerCharacterMode: given.playerCharacterMode }),
76
+ ...(given.eventNames === undefined ? {} : { eventNames: given.eventNames }),
77
+ ...(roomFields.length ? { roomFields } : {}),
78
+ // Each new character takes the next of the world's start places, its feet on the ground.
79
+ startState() {
80
+ const feetM = world.startPositionsM[startCount % world.startPositionsM.length];
81
+ startCount += 1;
82
+ return { x: feetM.x, y: feetM.y + world.character.heightM / 2, z: feetM.z, layerNumber: world.collisionLayers.findIndex((layer) => layer.name === "character") };
83
+ },
84
+ step(state, input, stepContext) {
85
+ const level = simulationFor(stepContext.tickDurationSec);
86
+ const key = `${roomNumberOf(stepContext.roomState)}|${stepContext.characterId}`;
87
+ let characterIndex = level.characterIndexById.get(key);
88
+ if (characterIndex === undefined) characterIndex = level.addCharacter(key, { x: state.x, y: state.y - world.character.heightM / 2, z: state.z });
89
+ steppedAtTickIndex.set(key, stepContext.tickIndex);
90
+ if (hasGroups) level.setOffTriangleGroups(stepContext.room?.[GROUPS_FIELD_NAME] ?? 0);
91
+ level.writeCharacter(characterIndex, state);
92
+ level.stepCharacterAlone(characterIndex, input, { ...level.stepTools, ...stepContext });
93
+ const read = level.readCharacter(characterIndex);
94
+ for (const name of sharedNames) state[name] = read[name];
95
+ sweep(stepContext.tickIndex, stepContext.tickDurationSec);
96
+ return state;
97
+ },
98
+ });
99
+
100
+ const viewOf = (fields, characterId) => (fields ? characterViewOf(world, kind, fields, characterId, simulation) : null);
101
+ const clientApi = netKind.clientApi;
102
+ netKind.clientApi = (runtime, kindContext) => {
103
+ const characters = clientApi(runtime, kindContext);
104
+ return Object.assign(characters, {
105
+ world,
106
+ settings,
107
+ /** Where and how to draw a character this frame: its feet, facing, speed, footing and its kind's own fields; null for one not here. */
108
+ drawnCharacter: (characterId) => viewOf(characters.drawn(characterId), characterId),
109
+ /** A character as this game has it now. */
110
+ characterState: (characterId) => viewOf(characters.state(characterId), characterId),
111
+ // The level's queries (rays, casts, overlaps): the same level every side steps against, its groups as this room has them.
112
+ ...queriesOver(() => withRoomGroups(characters)),
113
+ });
114
+ };
115
+ /** The level with a room's triangle groups switched as that room has them, before it's asked anything. */
116
+ const withRoomGroups = (characters) => {
117
+ if (simulation && hasGroups) simulation.setOffTriangleGroups(characters.room()?.[GROUPS_FIELD_NAME] ?? 0);
118
+ simulation?.refreshScene();
119
+ return simulation;
120
+ };
121
+ const onServer = netKind.onServer;
122
+ netKind.onServer = (state, room) => {
123
+ const characters = onServer(state, room);
124
+ return Object.assign(characters, {
125
+ world,
126
+ characterState: (characterId) => viewOf(characters.has(characterId) ? characters.state(characterId) : null, characterId),
127
+ ...queriesOver(() => withRoomGroups(characters)),
128
+ /** Switches one of the level's triangle groups on or off in this room (a door, a bridge), 1 to 31, for every player from the next step. */
129
+ setTriangleGroup(groupNumber, isEnabled) {
130
+ if (!hasGroups) refuse("no_triangle_groups", "This level's meshes have no triangleGroupNumbers.", "groupNumber", "Give a mesh triangleGroupNumbers in the world's declaration, in the game and on its game server.");
131
+ if (!Number.isInteger(groupNumber) || groupNumber < 1 || groupNumber > MAXIMUM_TRIANGLE_GROUP_NUMBER || typeof isEnabled !== "boolean") refuse("bad_argument", `setTriangleGroup was given ${JSON.stringify(groupNumber)}, ${JSON.stringify(isEnabled)}.`, "groupNumber", `Give a group from 1 to ${MAXIMUM_TRIANGLE_GROUP_NUMBER}, then true to have it there or false to take it away.`);
132
+ const maskNumber = characters.room()?.[GROUPS_FIELD_NAME] ?? 0;
133
+ const bitNumber = 1 << (groupNumber - 1);
134
+ return characters.setRoom({ [GROUPS_FIELD_NAME]: isEnabled ? maskNumber & ~bitNumber : maskNumber | bitNumber });
135
+ },
136
+ });
137
+ };
138
+ return Object.assign(netKind, { world, settings, characterKind: kind });
139
+ };
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@zaisma/physics",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.4.0",
4
+ "description": "Physics that works as it's added, alone and online, for every kind of game: one world of bodies (moving, kinematic or fixed), ground for big outdoor maps, joints, wheeled vehicles, seats, collision layers and queries, with characters that move by the game's own rules. Rapier is the engine, shipped inside.",
5
+ "license": "PolyForm-Shield-1.0.0",
6
+ "homepage": "https://zaisma.com",
7
+ "bugs": "https://zaisma.com/forum",
8
+ "keywords": [
9
+ "zaisma",
10
+ "zaisma-piece",
11
+ "games",
12
+ "browser-games",
13
+ "physics",
14
+ "multiplayer",
15
+ "rapier"
16
+ ],
17
+ "type": "module",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./index.d.ts",
21
+ "default": "./index.js"
22
+ },
23
+ "./server": {
24
+ "types": "./server.d.ts",
25
+ "default": "./server.js"
26
+ },
27
+ "./world": {
28
+ "types": "./world.d.ts",
29
+ "default": "./world.js"
30
+ },
31
+ "./piece.json": "./piece.json"
32
+ },
33
+ "files": [
34
+ "LICENSE.txt",
35
+ "README.md",
36
+ "characters.js",
37
+ "data.js",
38
+ "declare.js",
39
+ "engine.js",
40
+ "index.d.ts",
41
+ "index.js",
42
+ "piece.json",
43
+ "piece.json.js",
44
+ "rapier/LICENSE.txt",
45
+ "rapier/rapier.d.ts",
46
+ "rapier/rapier.js",
47
+ "rapier/rapier.wasm",
48
+ "server.d.ts",
49
+ "server.js",
50
+ "simulation.js",
51
+ "sync.js",
52
+ "level-characters.js",
53
+ "world.js",
54
+ "world.d.ts"
55
+ ]
56
+ }
package/piece.json ADDED
@@ -0,0 +1,136 @@
1
+ {
2
+ "statement_version_number": 1,
3
+ "name": "@zaisma/physics",
4
+ "piece_version": "2.4.0",
5
+ "kind": "foundation",
6
+ "standard": "@zaisma/standard",
7
+ "summary": "Physics that works as it's added, alone and online, for every kind of game: one world of bodies (moving, kinematic or fixed), ground for big outdoor maps, joints, wheeled vehicles, seats, collision layers and queries, with characters that move by the game's own rules. Rapier is the engine, shipped inside.",
8
+ "license": "PolyForm-Shield-1.0.0",
9
+ "entry_path": "index.js",
10
+ "server_entry_path": "server.js",
11
+ "file_paths": [
12
+ "index.js",
13
+ "index.d.ts",
14
+ "world.js",
15
+ "world.d.ts",
16
+ "declare.js",
17
+ "engine.js",
18
+ "characters.js",
19
+ "data.js",
20
+ "rapier/rapier.d.ts",
21
+ "simulation.js",
22
+ "sync.js",
23
+ "level-characters.js",
24
+ "piece.json.js",
25
+ "rapier/rapier.js",
26
+ "rapier/rapier.wasm",
27
+ "rapier/LICENSE.txt",
28
+ "README.md",
29
+ "LICENSE.txt"
30
+ ],
31
+ "server_file_paths": [
32
+ "server.js",
33
+ "server.d.ts",
34
+ "index.d.ts",
35
+ "rapier/rapier.d.ts",
36
+ "world.js",
37
+ "world.d.ts",
38
+ "declare.js",
39
+ "engine.js",
40
+ "characters.js",
41
+ "data.js",
42
+ "simulation.js",
43
+ "sync.js",
44
+ "level-characters.js",
45
+ "piece.json.js",
46
+ "rapier/rapier.js",
47
+ "rapier/rapier.wasm",
48
+ "rapier/LICENSE.txt"
49
+ ],
50
+ "needs": [
51
+ {
52
+ "name": "@zaisma/net",
53
+ "version_range": "^2.1.0",
54
+ "kind": "piece"
55
+ },
56
+ {
57
+ "name": "@zaisma/piece",
58
+ "version_range": "^1.0.0",
59
+ "kind": "piece"
60
+ }
61
+ ],
62
+ "settings": [
63
+ {
64
+ "name": "gravity_m_per_sec_per_sec",
65
+ "value_kind": "number",
66
+ "default_value": 9.81,
67
+ "minimum_number": 0,
68
+ "maximum_number": 100,
69
+ "maximum_character_count": null,
70
+ "choices": null,
71
+ "summary": "How fast things fall, in metres a second each second: 9.81 is Earth's. Online, whoever runs the world decides it."
72
+ },
73
+ {
74
+ "name": "bounce_pct",
75
+ "value_kind": "number",
76
+ "default_value": 10,
77
+ "minimum_number": 0,
78
+ "maximum_number": 100,
79
+ "maximum_character_count": null,
80
+ "choices": null,
81
+ "summary": "How much of a hit's speed comes back, for bodies that don't say their own."
82
+ },
83
+ {
84
+ "name": "grip_pct",
85
+ "value_kind": "number",
86
+ "default_value": 70,
87
+ "minimum_number": 0,
88
+ "maximum_number": 300,
89
+ "maximum_character_count": null,
90
+ "choices": null,
91
+ "summary": "How much surfaces hold on (friction), for bodies that don't say their own."
92
+ },
93
+ {
94
+ "name": "walk_speed_m_per_sec",
95
+ "value_kind": "number",
96
+ "default_value": 4.5,
97
+ "minimum_number": 0,
98
+ "maximum_number": 40,
99
+ "maximum_character_count": null,
100
+ "choices": null,
101
+ "summary": "How fast the piece's walking characters walk; running is 1.8 times this. A character kind of the game's own reads it too, as tuning.walkSpeedMPerSec."
102
+ },
103
+ {
104
+ "name": "jump_height_m",
105
+ "value_kind": "number",
106
+ "default_value": 1,
107
+ "minimum_number": 0,
108
+ "maximum_number": 20,
109
+ "maximum_character_count": null,
110
+ "choices": null,
111
+ "summary": "How high the piece's walking characters jump, whatever the gravity."
112
+ },
113
+ {
114
+ "name": "character_mass_kg",
115
+ "value_kind": "number",
116
+ "default_value": 70,
117
+ "minimum_number": 1,
118
+ "maximum_number": 1000,
119
+ "maximum_character_count": null,
120
+ "choices": null,
121
+ "summary": "How heavy a character is beside what it walks into and pushes."
122
+ }
123
+ ],
124
+ "hooks": [
125
+ {
126
+ "name": "before_put_back",
127
+ "hook_kind": "decision",
128
+ "summary": "Where the world is run, asked before something that fell out of the world is put back, with the place it started ({ id, isCharacter, roomState }); answer another place as { x, y, z } to put it there."
129
+ },
130
+ {
131
+ "name": "body_hit",
132
+ "hook_kind": "event",
133
+ "summary": "Told when a moving body hits something hard enough to hear, with { bodyId, otherBodyId, otherCharacterId, speedMPerSec }: for a thud, dust or a rumble."
134
+ }
135
+ ]
136
+ }
package/piece.json.js ADDED
@@ -0,0 +1,137 @@
1
+ // This piece's statement, piece.json, as a module for its own code to read. "zaisma pieces check --fix" writes it: never edit it.
2
+ export default {
3
+ "statement_version_number": 1,
4
+ "name": "@zaisma/physics",
5
+ "piece_version": "2.4.0",
6
+ "kind": "foundation",
7
+ "standard": "@zaisma/standard",
8
+ "summary": "Physics that works as it's added, alone and online, for every kind of game: one world of bodies (moving, kinematic or fixed), ground for big outdoor maps, joints, wheeled vehicles, seats, collision layers and queries, with characters that move by the game's own rules. Rapier is the engine, shipped inside.",
9
+ "license": "PolyForm-Shield-1.0.0",
10
+ "entry_path": "index.js",
11
+ "server_entry_path": "server.js",
12
+ "file_paths": [
13
+ "index.js",
14
+ "index.d.ts",
15
+ "world.js",
16
+ "world.d.ts",
17
+ "declare.js",
18
+ "engine.js",
19
+ "characters.js",
20
+ "data.js",
21
+ "rapier/rapier.d.ts",
22
+ "simulation.js",
23
+ "sync.js",
24
+ "level-characters.js",
25
+ "piece.json.js",
26
+ "rapier/rapier.js",
27
+ "rapier/rapier.wasm",
28
+ "rapier/LICENSE.txt",
29
+ "README.md",
30
+ "LICENSE.txt"
31
+ ],
32
+ "server_file_paths": [
33
+ "server.js",
34
+ "server.d.ts",
35
+ "index.d.ts",
36
+ "rapier/rapier.d.ts",
37
+ "world.js",
38
+ "world.d.ts",
39
+ "declare.js",
40
+ "engine.js",
41
+ "characters.js",
42
+ "data.js",
43
+ "simulation.js",
44
+ "sync.js",
45
+ "level-characters.js",
46
+ "piece.json.js",
47
+ "rapier/rapier.js",
48
+ "rapier/rapier.wasm",
49
+ "rapier/LICENSE.txt"
50
+ ],
51
+ "needs": [
52
+ {
53
+ "name": "@zaisma/net",
54
+ "version_range": "^2.1.0",
55
+ "kind": "piece"
56
+ },
57
+ {
58
+ "name": "@zaisma/piece",
59
+ "version_range": "^1.0.0",
60
+ "kind": "piece"
61
+ }
62
+ ],
63
+ "settings": [
64
+ {
65
+ "name": "gravity_m_per_sec_per_sec",
66
+ "value_kind": "number",
67
+ "default_value": 9.81,
68
+ "minimum_number": 0,
69
+ "maximum_number": 100,
70
+ "maximum_character_count": null,
71
+ "choices": null,
72
+ "summary": "How fast things fall, in metres a second each second: 9.81 is Earth's. Online, whoever runs the world decides it."
73
+ },
74
+ {
75
+ "name": "bounce_pct",
76
+ "value_kind": "number",
77
+ "default_value": 10,
78
+ "minimum_number": 0,
79
+ "maximum_number": 100,
80
+ "maximum_character_count": null,
81
+ "choices": null,
82
+ "summary": "How much of a hit's speed comes back, for bodies that don't say their own."
83
+ },
84
+ {
85
+ "name": "grip_pct",
86
+ "value_kind": "number",
87
+ "default_value": 70,
88
+ "minimum_number": 0,
89
+ "maximum_number": 300,
90
+ "maximum_character_count": null,
91
+ "choices": null,
92
+ "summary": "How much surfaces hold on (friction), for bodies that don't say their own."
93
+ },
94
+ {
95
+ "name": "walk_speed_m_per_sec",
96
+ "value_kind": "number",
97
+ "default_value": 4.5,
98
+ "minimum_number": 0,
99
+ "maximum_number": 40,
100
+ "maximum_character_count": null,
101
+ "choices": null,
102
+ "summary": "How fast the piece's walking characters walk; running is 1.8 times this. A character kind of the game's own reads it too, as tuning.walkSpeedMPerSec."
103
+ },
104
+ {
105
+ "name": "jump_height_m",
106
+ "value_kind": "number",
107
+ "default_value": 1,
108
+ "minimum_number": 0,
109
+ "maximum_number": 20,
110
+ "maximum_character_count": null,
111
+ "choices": null,
112
+ "summary": "How high the piece's walking characters jump, whatever the gravity."
113
+ },
114
+ {
115
+ "name": "character_mass_kg",
116
+ "value_kind": "number",
117
+ "default_value": 70,
118
+ "minimum_number": 1,
119
+ "maximum_number": 1000,
120
+ "maximum_character_count": null,
121
+ "choices": null,
122
+ "summary": "How heavy a character is beside what it walks into and pushes."
123
+ }
124
+ ],
125
+ "hooks": [
126
+ {
127
+ "name": "before_put_back",
128
+ "hook_kind": "decision",
129
+ "summary": "Where the world is run, asked before something that fell out of the world is put back, with the place it started ({ id, isCharacter, roomState }); answer another place as { x, y, z } to put it there."
130
+ },
131
+ {
132
+ "name": "body_hit",
133
+ "hook_kind": "event",
134
+ "summary": "Told when a moving body hits something hard enough to hear, with { bodyId, otherBodyId, otherCharacterId, speedMPerSec }: for a thud, dust or a rumble."
135
+ }
136
+ ]
137
+ };