Workers for chunk generation !
This commit is contained in:
@@ -67,8 +67,9 @@ types are the engine's own source, so `check-mods` typechecks against exactly th
|
||||
through: `engine.common.physics.move_body` is how every entity moves, on the server and on clients.
|
||||
- `#private` members can't be hooked. They're kept for things with rules that must hold, like a container's slots.
|
||||
- Hooks reach one JavaScript realm. Chunk workers run their own copy of the engine, so a client hook doesn't change
|
||||
meshing. Worldgen scripts run on the server, next to the server script, so hooking `engine.common.OverworldTerrain`
|
||||
from either changes the terrain.
|
||||
meshing. The server generates chunks in worldgen workers, and each loads the worldgen scripts into its own copy, so
|
||||
hooks on the terrain (`engine.common.OverworldTerrain`) go in the worldgen script. A server script's hooks there only
|
||||
reach the few chunks the game generates itself, so the world would come out different in places.
|
||||
|
||||
## Performance
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ and their builds end up half buried.
|
||||
|
||||
- **Never use `Math.random`, `Date`, `performance.now` or anything else that changes between runs.** Use the chunk's
|
||||
`rng` and noise helpers, which are seeded from the world's seed.
|
||||
- Don't keep state between chunks. Chunks generate in any order.
|
||||
- Don't keep state between chunks. Chunks generate in any order, and in several worldgen workers at once, each with its
|
||||
own copy of the worldgen scripts (and the game generates a few itself).
|
||||
- Adding or removing a mod's features is safe for chunks that haven't been generated yet, but changes existing worlds'
|
||||
untouched terrain the next time it loads.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user