Persist player overworld location and add world mob spawn editing/runtime payloads

This commit is contained in:
dingo
2026-02-15 08:47:09 -05:00
parent 3c03bc40fa
commit d6b691e534
7 changed files with 330 additions and 18 deletions
+10 -3
View File
@@ -114,6 +114,8 @@
- `object_remove`: `{ id }`
- `npc_upsert`: `{ id, x, y, npcDefinitionId, npcName, rotation, metadataJson }`
- `npc_remove`: `{ id }`
- `mob_upsert`: `{ id, x, y, mobDefinitionId, mobName, rotation, spawnCount, respawnSeconds, metadataJson }`
- `mob_remove`: `{ id }`
- `chunk_clear`: `{}`
- `chunk_deleted`: `{}`
@@ -159,13 +161,15 @@
- `WORLD_SPAWN_REQUEST` (`300`) request:
- `{ regionId?, zoneX?, zoneY?, chunkX?, chunkY? }`
- all fields optional; server defaults to the first enabled region at `zone/chunk = 0,0`.
- all fields optional.
- if not provided, server prefers persisted character world location.
- if character has no saved world location, server defaults to first enabled region at `zone/chunk = 0,0`.
- `WORLD_SPAWN` (`301`) response:
- `success`
- `player`: `{ id, name, x, y, regionId, zoneX, zoneY, chunkX, chunkY, isVip }`
- `region`: `{ id, name, zonesX, zonesY, chunksPerZoneX, chunksPerZoneY, chunkWidthTiles, chunkHeightTiles }`
- `initialChunks[]`: subset of `chunkUpdates` entries where `type = "chunk_full"`:
- `{ type: "chunk_full", chunk, tiles[], objects[], npcs[] }`
- `{ type: "chunk_full", chunk, tiles[], objects[], npcs[], mobs[] }`
- `nearbyPlayers[]`: `{ id, name, x, y, facing, speed, isMoving }`
- `WORLD_INPUT` (`310`) request (20hz max):
- `{ seq, moveX, moveY, isRunning, facing }`
@@ -175,7 +179,7 @@
- `self`: `{ x, y, velocityX, velocityY }`
- `players[]`: `{ id, name, x, y, facing, speed, isMoving, regionId, zoneX, zoneY, chunkX, chunkY }`
- `chunkUpdates[]`:
- `chunk_full`: `{ type, chunk, tiles[], objects[], npcs[] }`
- `chunk_full`: `{ type, chunk, tiles[], objects[], npcs[], mobs[] }`
- `chunk_unload`: `{ type, regionId, zoneX, zoneY, chunkX, chunkY }`
- `errors[]` optional: e.g. `["blocked_non_walkable"]`, `["blocked_paywall"]`.
- `WORLD_DESPAWN` (`302`) response:
@@ -188,6 +192,9 @@
- `chunk_unload`:
- remove cache entry and unload chunk visuals/colliders.
- server emits `chunk_full` when entering visibility range or when chunk version changes.
- player world location persistence:
- server saves `{ regionId, zoneX, zoneY, chunkX, chunkY, x, y }` on disconnect.
- next world spawn (without explicit location override) returns player to that saved position.
### Rendering and assets