Add world portal editing/runtime handling and include tileSheets in WORLD_SPAWN

This commit is contained in:
dingo
2026-02-15 09:00:53 -05:00
parent d6b691e534
commit 69e457d943
4 changed files with 295 additions and 4 deletions
+19 -1
View File
@@ -110,7 +110,7 @@
- `op`:
- `tile_upsert`: `{ x, y, sheetId, frameIndex, isWalkable, isInvisiblePaywall }`
- `tile_remove`: `{ x, y }`
- `object_upsert`: `{ id, x, y, objectDefinitionId, objectName, rotation, metadataJson }`
- `object_upsert`: `{ id, x, y, objectDefinitionId, objectName, interactionType, rotation, metadataJson }`
- `object_remove`: `{ id }`
- `npc_upsert`: `{ id, x, y, npcDefinitionId, npcName, rotation, metadataJson }`
- `npc_remove`: `{ id }`
@@ -168,6 +168,7 @@
- `success`
- `player`: `{ id, name, x, y, regionId, zoneX, zoneY, chunkX, chunkY, isVip }`
- `region`: `{ id, name, zonesX, zonesY, chunksPerZoneX, chunksPerZoneY, chunkWidthTiles, chunkHeightTiles }`
- `tileSheets[]`: `{ id, name, path, tileW, tileH, cols, sheetW, sheetH }`
- `initialChunks[]`: subset of `chunkUpdates` entries where `type = "chunk_full"`:
- `{ type: "chunk_full", chunk, tiles[], objects[], npcs[], mobs[] }`
- `nearbyPlayers[]`: `{ id, name, x, y, facing, speed, isMoving }`
@@ -180,7 +181,11 @@
- `players[]`: `{ id, name, x, y, facing, speed, isMoving, regionId, zoneX, zoneY, chunkX, chunkY }`
- `chunkUpdates[]`:
- `chunk_full`: `{ type, chunk, tiles[], objects[], npcs[], mobs[] }`
- `objects[]` now includes `interactionType` string.
- `chunk_unload`: `{ type, regionId, zoneX, zoneY, chunkX, chunkY }`
- `portalEvent` optional:
- world teleport: `{ type: "world_teleport", sourceObjectId, regionId, zoneX, zoneY, chunkX, chunkY, x, y }`
- dungeon transfer request: `{ type: "dungeon_request", sourceObjectId, portalType, dungeonTemplateId?, randomTier?, levelBracketMin?, levelBracketMax? }`
- `errors[]` optional: e.g. `["blocked_non_walkable"]`, `["blocked_paywall"]`.
- `WORLD_DESPAWN` (`302`) response:
- `{ playerId, reason }`.
@@ -207,6 +212,19 @@
- server blocks movement against `isWalkable == false` tiles.
- server blocks movement against `isInvisiblePaywall == true` when `player.isVip == false`.
### World portal metadata contract (object `metadataJson`)
- Portal objects are world chunk objects whose definition has `interactionType = Teleport` (or metadata includes `portalType`).
- `portalType: "world"`:
- `{ "portalType":"world","targetRegionId":1,"targetZoneX":0,"targetZoneY":0,"targetChunkX":0,"targetChunkY":0,"targetTileX":5,"targetTileY":5 }`
- server teleports immediately on collision.
- `portalType: "dungeon_random"`:
- `{ "portalType":"dungeon_random","randomTier":3,"levelBracketMin":11,"levelBracketMax":20 }`
- server emits `portalEvent.type = "dungeon_request"` for client-driven dungeon entry flow.
- `portalType: "dungeon_specific"`:
- `{ "portalType":"dungeon_specific","dungeonTemplateId":42 }`
- server emits `portalEvent.type = "dungeon_request"` for client-driven dungeon entry flow.
## Dungeon Portals and Ledge-Safe Movement
- Movement collision now uses entity radius checks against tile walkability.