Wire overworld runtime handler and implement WORLD spawn/input/state flow
This commit is contained in:
+31
-31
@@ -128,23 +128,18 @@
|
||||
- `POST /admin/worldeditor?handler=DeleteChunk`
|
||||
- Tile paint now respects tile definition walkability when a definition exists for selected `sheetId + frameIndex`.
|
||||
|
||||
## Overworld Runtime Client Support (Still Needed)
|
||||
## Overworld Runtime Client Support
|
||||
|
||||
- Browser world editor APIs are in place, but in-game overworld runtime streaming is still pending.
|
||||
- Client still needs final runtime contract and handlers for:
|
||||
- loading world region/zone/chunk state at player spawn
|
||||
- receiving nearby chunk deltas from server during movement
|
||||
- enforcing `isWalkable` and VIP paywall collision in live world movement
|
||||
- Runtime world opcodes are now server-wired through `WorldHandler`.
|
||||
- Browser world editor APIs still exist separately for admin live-editing.
|
||||
|
||||
### Runtime status and wiring note
|
||||
### Runtime opcodes
|
||||
|
||||
- `WORLD_*` opcodes already reserved in `Networking/Messages/OpCodes.cs`:
|
||||
- `WORLD_SPAWN_REQUEST` (`300`)
|
||||
- `WORLD_SPAWN` (`301`)
|
||||
- `WORLD_DESPAWN` (`302`)
|
||||
- `WORLD_INPUT` (`310`)
|
||||
- `WORLD_STATE` (`311`)
|
||||
- Current server handler routing is still dungeon-only, so client should keep this behind a feature flag until runtime handlers are enabled.
|
||||
- `WORLD_SPAWN_REQUEST` (`300`)
|
||||
- `WORLD_SPAWN` (`301`)
|
||||
- `WORLD_DESPAWN` (`302`)
|
||||
- `WORLD_INPUT` (`310`)
|
||||
- `WORLD_STATE` (`311`)
|
||||
|
||||
### Client world navigation requirements
|
||||
|
||||
@@ -160,37 +155,39 @@
|
||||
- Block movement if target tile has `isWalkable == false`.
|
||||
- Block movement if target tile has `isInvisiblePaywall == true` and player is not VIP.
|
||||
|
||||
### Draft runtime packet contract for client implementation
|
||||
### Implemented runtime packet contract
|
||||
|
||||
- `WORLD_SPAWN_REQUEST` (`300`) request:
|
||||
- `{ characterId? }` (or empty object if selected character is already server session state).
|
||||
- `{ regionId?, zoneX?, zoneY?, chunkX?, chunkY? }`
|
||||
- all fields optional; server defaults to the first enabled region at `zone/chunk = 0,0`.
|
||||
- `WORLD_SPAWN` (`301`) response:
|
||||
- `success`
|
||||
- `player`: `{ id, x, y, regionId, zoneX, zoneY, chunkX, chunkY }`
|
||||
- `player`: `{ id, name, x, y, regionId, zoneX, zoneY, chunkX, chunkY, isVip }`
|
||||
- `region`: `{ id, name, zonesX, zonesY, chunksPerZoneX, chunksPerZoneY, chunkWidthTiles, chunkHeightTiles }`
|
||||
- `initialChunks[]`: same shape as world-editor `OnGetChunk` payload (`chunk`, `tiles[]`, `objects[]`, `npcs[]`)
|
||||
- `nearbyPlayers[]` minimal shape: `{ id, name, x, y, direction, speed }`
|
||||
- `initialChunks[]`: subset of `chunkUpdates` entries where `type = "chunk_full"`:
|
||||
- `{ type: "chunk_full", chunk, tiles[], objects[], npcs[] }`
|
||||
- `nearbyPlayers[]`: `{ id, name, x, y, facing, speed, isMoving }`
|
||||
- `WORLD_INPUT` (`310`) request (20hz max):
|
||||
- `{ seq, moveX, moveY, isRunning, facing, x?, y? }`
|
||||
- `{ seq, moveX, moveY, isRunning, facing }`
|
||||
- `WORLD_STATE` (`311`) response (10-20hz):
|
||||
- `tick`
|
||||
- `ackSeq`
|
||||
- `self`: `{ x, y, velocityX, velocityY }`
|
||||
- `players[]`: `{ id, x, y, facing, speed, isMoving }`
|
||||
- `chunkDeltas[]`: list of delta payloads matching `kind: "chunk_delta"` operations used by world editor stream.
|
||||
- `players[]`: `{ id, name, x, y, facing, speed, isMoving, regionId, zoneX, zoneY, chunkX, chunkY }`
|
||||
- `chunkUpdates[]`:
|
||||
- `chunk_full`: `{ type, chunk, tiles[], objects[], npcs[] }`
|
||||
- `chunk_unload`: `{ type, regionId, zoneX, zoneY, chunkX, chunkY }`
|
||||
- `errors[]` optional: e.g. `["blocked_non_walkable"]`, `["blocked_paywall"]`.
|
||||
- `WORLD_DESPAWN` (`302`) response:
|
||||
- `{ playerId, reason }`.
|
||||
|
||||
### Chunk delta handling rules in client
|
||||
### Chunk update handling rules in client
|
||||
|
||||
- Apply delta only if `fromVersion == cachedVersion`.
|
||||
- If mismatch or cache missing:
|
||||
- Mark chunk `dirty`.
|
||||
- Request full chunk refresh from runtime endpoint (or reconnect world session if no runtime chunk endpoint exists yet).
|
||||
- `chunk_clear`:
|
||||
- Remove all cached tiles/objects/npcs for that chunk.
|
||||
- `chunk_deleted`:
|
||||
- Remove chunk cache entry entirely and unload visuals/colliders.
|
||||
- `chunk_full`:
|
||||
- replace/refresh cache entry for `regionId+zoneX+zoneY+chunkX+chunkY` using `chunk.version`.
|
||||
- `chunk_unload`:
|
||||
- remove cache entry and unload chunk visuals/colliders.
|
||||
- server emits `chunk_full` when entering visibility range or when chunk version changes.
|
||||
|
||||
### Rendering and assets
|
||||
|
||||
@@ -199,6 +196,9 @@
|
||||
- Keep non-smoothed nearest-neighbor rendering for pixel art.
|
||||
- Render paywall tile overlay only in editor/debug mode; keep invisible in normal gameplay while still colliding.
|
||||
- Render object and NPC world instances from their definition IDs, reusing existing sprite/animation systems.
|
||||
- Movement authority:
|
||||
- server blocks movement against `isWalkable == false` tiles.
|
||||
- server blocks movement against `isInvisiblePaywall == true` when `player.isVip == false`.
|
||||
|
||||
## Dungeon Portals and Ledge-Safe Movement
|
||||
|
||||
|
||||
Reference in New Issue
Block a user