Skip to content

five-on-it / apps/server/src/nav-cache

apps/server/src/nav-cache ​

The levels' navigation, built off the game loop: a room's AI needs its level's navigation (@foi/ai's buildAiStatic: seconds on a big level, eleven on Riverbend), which built in the loop would stall every room of the process meanwhile. prepareNavigation builds it in a worker thread, once per level object (rooms on the same level share it), and the room opens when it is ready (RoomHost.openWhenReady).

The worker runs this very module (import.meta.url: this file, or the server's bundle, whose own code runs on the main thread only, index.ts): started with the job's mark (foi-navigation), it builds, answers under the same mark and is done. Its other messages are not the answer: under node --watch (npm run dev) a worker reports the modules it loads to its parent first, and that report taken for the navigation failed every level's room.

Functions ​