castle-web-cli 0.4.238 → 0.4.240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/dist/agent.js +5 -1
  2. package/dist/api.d.ts +20 -0
  3. package/dist/api.js +57 -0
  4. package/dist/bundle.d.ts +38 -1
  5. package/dist/bundle.js +309 -13
  6. package/dist/castle-host/host.js +218 -11
  7. package/dist/castleJson.d.ts +10 -0
  8. package/dist/castleJson.js +46 -2
  9. package/dist/check.js +5 -2
  10. package/dist/devSessionServer.js +4 -1
  11. package/dist/devSessionStorage.d.ts +1 -0
  12. package/dist/devSessionStorage.js +32 -7
  13. package/dist/importOrder.d.ts +2 -0
  14. package/dist/importOrder.js +29 -0
  15. package/dist/index.js +22 -3
  16. package/dist/init.js +24 -2
  17. package/dist/multiplayerDoc.d.ts +1 -1
  18. package/dist/multiplayerDoc.js +9 -0
  19. package/dist/platformDoc.js +4 -2
  20. package/dist/playPagePolicy.d.ts +1 -0
  21. package/dist/playPagePolicy.js +12 -3
  22. package/dist/resetLeaderboards.d.ts +8 -1
  23. package/dist/resetLeaderboards.js +43 -8
  24. package/dist/roomLogs.d.ts +39 -0
  25. package/dist/roomLogs.js +166 -0
  26. package/dist/save-deck.d.ts +32 -2
  27. package/dist/save-deck.js +240 -39
  28. package/kits/base/CLAUDE.md +2 -1
  29. package/kits/base/castle.json +1 -1
  30. package/kits/base/sdk/README.md +240 -8
  31. package/kits/base/sdk/analytics.d.ts +8 -0
  32. package/kits/base/sdk/analytics.js +92 -0
  33. package/kits/base/sdk/castle.d.ts +8 -2
  34. package/kits/base/sdk/castle.js +3 -0
  35. package/kits/base/sdk/commands.d.ts +79 -0
  36. package/kits/base/sdk/commands.js +1 -0
  37. package/kits/base/sdk/debugConsole.d.ts +17 -0
  38. package/kits/base/sdk/debugConsole.js +154 -0
  39. package/kits/base/sdk/experiments.js +24 -1
  40. package/kits/base/sdk/hostRetry.d.ts +7 -0
  41. package/kits/base/sdk/hostRetry.js +57 -0
  42. package/kits/base/sdk/hub.d.ts +20 -2
  43. package/kits/base/sdk/hub.js +99 -13
  44. package/kits/base/sdk/multiplayer.d.ts +2 -0
  45. package/kits/base/sdk/multiplayer.js +198 -26
  46. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  47. package/kits/base/sdk/reconnectBudget.js +41 -1
  48. package/kits/base/sdk/rooms.d.ts +11 -0
  49. package/kits/base/sdk/rooms.js +22 -0
  50. package/kits/base/sdk/runtime.js +36 -19
  51. package/kits/base/sdk/server/hub.d.ts +19 -0
  52. package/kits/base/sdk/server/hub.js +12 -0
  53. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  54. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  55. package/kits/base/sdk/server/wrapper.js +26 -1
  56. package/kits/base/sdk/store.d.ts +8 -2
  57. package/kits/base/sdk/store.js +5 -1
  58. package/kits/base/sdk/transport.d.ts +2 -1
  59. package/kits/base/sdk/transport.js +35 -0
  60. package/kits/hub-game/CLAUDE.md +66 -19
  61. package/kits/hub-game/castle.json +4 -4
  62. package/kits/hub-game/code/client/act.js +9 -6
  63. package/kits/hub-game/code/client/actCore.js +26 -6
  64. package/kits/hub-game/code/client/actGateLog.js +36 -0
  65. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  66. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  67. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  68. package/kits/hub-game/code/client/askSurface.js +85 -0
  69. package/kits/hub-game/code/client/askTree.js +51 -0
  70. package/kits/hub-game/code/client/attention.js +31 -6
  71. package/kits/hub-game/code/client/ballot.js +42 -5
  72. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  73. package/kits/hub-game/code/client/ballotTree.js +180 -0
  74. package/kits/hub-game/code/client/catchingUp.js +19 -0
  75. package/kits/hub-game/code/client/celebrate.js +66 -0
  76. package/kits/hub-game/code/client/chrome.js +474 -53
  77. package/kits/hub-game/code/client/companion.js +93 -23
  78. package/kits/hub-game/code/client/companionDress.js +1 -1
  79. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  80. package/kits/hub-game/code/client/cornerTree.js +83 -0
  81. package/kits/hub-game/code/client/decor.js +20 -11
  82. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  83. package/kits/hub-game/code/client/disguise.js +23 -0
  84. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  85. package/kits/hub-game/code/client/dockSurface.js +206 -0
  86. package/kits/hub-game/code/client/dockTree.js +232 -0
  87. package/kits/hub-game/code/client/earned.js +29 -0
  88. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  89. package/kits/hub-game/code/client/emoteTree.js +264 -0
  90. package/kits/hub-game/code/client/farAvatars.js +4 -3
  91. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  92. package/kits/hub-game/code/client/grab.js +121 -50
  93. package/kits/hub-game/code/client/holdShow.js +19 -0
  94. package/kits/hub-game/code/client/hookLayer.js +96 -12
  95. package/kits/hub-game/code/client/hubControls.js +7 -1
  96. package/kits/hub-game/code/client/hudSurface.js +11 -3
  97. package/kits/hub-game/code/client/hudTree.js +7 -4
  98. package/kits/hub-game/code/client/idle.js +21 -3
  99. package/kits/hub-game/code/client/invites.js +24 -3
  100. package/kits/hub-game/code/client/keys.js +15 -0
  101. package/kits/hub-game/code/client/labelsNear.js +8 -1
  102. package/kits/hub-game/code/client/layoutCache.js +57 -8
  103. package/kits/hub-game/code/client/loadingCover.js +53 -4
  104. package/kits/hub-game/code/client/menuIcons.js +15 -0
  105. package/kits/hub-game/code/client/menuRows.js +8 -2
  106. package/kits/hub-game/code/client/menuSurface.js +102 -0
  107. package/kits/hub-game/code/client/menuTree.js +135 -0
  108. package/kits/hub-game/code/client/modelLook.js +41 -0
  109. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  110. package/kits/hub-game/code/client/pickerTree.js +163 -0
  111. package/kits/hub-game/code/client/pushVisit.js +4 -2
  112. package/kits/hub-game/code/client/quality.js +188 -29
  113. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  114. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  115. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  116. package/kits/hub-game/code/client/rehello.js +75 -0
  117. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  118. package/kits/hub-game/code/client/replay.js +118 -0
  119. package/kits/hub-game/code/client/role.js +3 -0
  120. package/kits/hub-game/code/client/safeLayout.js +441 -56
  121. package/kits/hub-game/code/client/safeStyle.js +13 -10
  122. package/kits/hub-game/code/client/say.js +2 -0
  123. package/kits/hub-game/code/client/soundSurface.js +77 -0
  124. package/kits/hub-game/code/client/soundTree.js +74 -0
  125. package/kits/hub-game/code/client/soundscape.js +12 -9
  126. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  127. package/kits/hub-game/code/client/state.js +67 -1
  128. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  129. package/kits/hub-game/code/client/stuckTree.js +67 -0
  130. package/kits/hub-game/code/client/talk.js +42 -12
  131. package/kits/hub-game/code/client/talkTree.js +4 -2
  132. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  133. package/kits/hub-game/code/client/textAskTree.js +67 -0
  134. package/kits/hub-game/code/client/tiers.js +252 -27
  135. package/kits/hub-game/code/client/together.js +4 -1
  136. package/kits/hub-game/code/client/uiDom.js +86 -8
  137. package/kits/hub-game/code/client/uiTree.js +33 -4
  138. package/kits/hub-game/code/client/vehicle.js +75 -52
  139. package/kits/hub-game/code/client/weakestTier.js +75 -31
  140. package/kits/hub-game/code/client/wear.js +159 -5
  141. package/kits/hub-game/code/client/worldLabels.js +215 -26
  142. package/kits/hub-game/code/companionSpec.js +4 -2
  143. package/kits/hub-game/code/server/act.js +3 -0
  144. package/kits/hub-game/code/server/actGate.js +83 -0
  145. package/kits/hub-game/code/server/actions.js +71 -15
  146. package/kits/hub-game/code/server/actors.js +20 -5
  147. package/kits/hub-game/code/server/analytics.js +40 -15
  148. package/kits/hub-game/code/server/ask.js +39 -3
  149. package/kits/hub-game/code/server/ballot.js +167 -4
  150. package/kits/hub-game/code/server/celebrate.js +64 -0
  151. package/kits/hub-game/code/server/companion.js +17 -2
  152. package/kits/hub-game/code/server/decor.js +11 -2
  153. package/kits/hub-game/code/server/disguise.js +63 -0
  154. package/kits/hub-game/code/server/doorAnalytics.js +2 -5
  155. package/kits/hub-game/code/server/earned.js +6 -2
  156. package/kits/hub-game/code/server/friendBests.js +13 -4
  157. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  158. package/kits/hub-game/code/server/grab.js +12 -2
  159. package/kits/hub-game/code/server/heldOffers.js +142 -0
  160. package/kits/hub-game/code/server/holdShow.js +98 -0
  161. package/kits/hub-game/code/server/hub.js +854 -45
  162. package/kits/hub-game/code/server/idle.js +110 -9
  163. package/kits/hub-game/code/server/index.js +9 -0
  164. package/kits/hub-game/code/server/labels.js +13 -3
  165. package/kits/hub-game/code/server/loadAbandon.js +2 -5
  166. package/kits/hub-game/code/server/manifest.js +94 -6
  167. package/kits/hub-game/code/server/menu.js +26 -3
  168. package/kits/hub-game/code/server/npcs.js +55 -9
  169. package/kits/hub-game/code/server/observe.js +67 -6
  170. package/kits/hub-game/code/server/players.js +8 -1
  171. package/kits/hub-game/code/server/replay.js +135 -0
  172. package/kits/hub-game/code/server/storageLimit.js +4 -1
  173. package/kits/hub-game/code/server/townDay.js +74 -0
  174. package/kits/hub-game/code/server/trackQueue.js +29 -0
  175. package/kits/hub-game/code/server/vehicle.js +3 -0
  176. package/kits/hub-game/code/server/vis.js +26 -4
  177. package/kits/hub-game/code/server/wallet.js +677 -0
  178. package/kits/hub-game/code/server/wear.js +13 -3
  179. package/kits/hub-game/code/server/writerLease.js +191 -0
  180. package/kits/hub-game/code/shared/act.js +1 -1
  181. package/kits/hub-game/code/shared/expression.js +6 -0
  182. package/kits/hub-game/code/shared/replay.js +37 -0
  183. package/kits/hub-game/code/systems/hub.js +437 -57
  184. package/kits/hub-game/docs/analytics.md +20 -3
  185. package/kits/hub-game/docs/contract.md +942 -99
  186. package/kits/hub-game/docs/home-pieces.md +5 -6
  187. package/kits/hub-game/docs/observed-progress.md +49 -1
  188. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  189. package/kits/hub-game/index.html +1 -0
  190. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  200. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  201. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  202. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  203. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  204. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  205. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  206. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  207. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  208. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  209. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  210. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  211. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  212. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  213. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  214. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  215. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  216. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  217. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  218. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  219. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  220. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  221. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  222. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  223. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  224. package/kits/hub-game/package-lock.json +3 -3
  225. package/kits/hub-game/package.json +4 -3
  226. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  227. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  228. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  229. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  230. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  231. package/kits/hub-game/scripts/pack.mjs +89 -23
  232. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  233. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  234. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  235. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  236. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  237. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  238. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  239. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  240. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  241. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  242. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  243. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  244. package/kits/hub-game/scripts/test-analytics.mjs +80 -1
  245. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  246. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  247. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  248. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  249. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  250. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  251. package/kits/hub-game/scripts/test-ballot.mjs +420 -3
  252. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  253. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  254. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  255. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  256. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  257. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  258. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  259. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  260. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  261. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  262. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  263. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  264. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  265. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  266. package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
  267. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  268. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  269. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  270. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  271. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  272. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  273. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  274. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  275. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  276. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  277. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  278. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  279. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  280. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  281. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  282. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  283. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  284. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  285. package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
  286. package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
  287. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  288. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  289. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  290. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  291. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  292. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  293. package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
  294. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  295. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  296. package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
  297. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  298. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  299. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  300. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  301. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  302. package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
  303. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  304. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  305. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  306. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  307. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  308. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  309. package/kits/hub-game/scripts/test-rehello.mjs +237 -0
  310. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  311. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  312. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  313. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  314. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  315. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  316. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  317. package/kits/hub-game/scripts/test-resync.mjs +13 -0
  318. package/kits/hub-game/scripts/test-role-client.mjs +10 -3
  319. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  320. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  321. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  322. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  323. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  324. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  325. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  326. package/kits/hub-game/scripts/test-stuck.mjs +31 -0
  327. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  328. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  329. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  330. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  331. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  332. package/kits/hub-game/scripts/test-together.mjs +11 -0
  333. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  334. package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
  335. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  336. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  337. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  338. package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
  339. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  340. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  341. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  342. package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
  343. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  344. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  345. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  346. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  347. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  348. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
  349. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
  350. package/kits/multiplayer-3d/castle.json +5 -5
  351. package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
  352. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  353. package/kits/multiplayer-3d/code/server/world.js +19 -4
  354. package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
  355. package/kits/multiplayer-3d/package-lock.json +1 -1
  356. package/kits/multiplayer-3d/package.json +2 -1
  357. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  358. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  359. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  360. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
  361. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  362. package/kits/physics-2d/castle.json +2 -2
  363. package/kits/physics-2d/engine/scene.js +10 -2
  364. package/kits/physics-3d/CLAUDE.md +14 -0
  365. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  366. package/kits/physics-3d/castle.json +3 -3
  367. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  368. package/kits/physics-3d/docs/engine-player.md +76 -0
  369. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  370. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  371. package/kits/physics-3d/engine3d/gait.js +16 -8
  372. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  373. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  374. package/kits/physics-3d/engine3d/look.js +110 -17
  375. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  376. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  377. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  378. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  379. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  380. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  381. package/kits/physics-3d/engine3d/optimize.js +20 -9
  382. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  383. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  384. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  385. package/kits/physics-3d/engine3d/world3d.js +211 -17
  386. package/kits/physics-3d/package-lock.json +1 -1
  387. package/kits/physics-3d/package.json +2 -1
  388. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  389. package/kits/physics-3d/scripts/render.mjs +56 -8
  390. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  391. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  392. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  393. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  394. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  395. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  396. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  397. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  398. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  399. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  400. package/kits/physics-3d/systems/physics3d.js +51 -2
  401. package/kits/real-time/castle.json +2 -2
  402. package/kits/real-time/code/client/connection.js +3 -0
  403. package/package.json +2 -2
  404. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -1,9 +1,8 @@
1
1
  import { showBuildStamp } from '../client/build.js';
2
- import { landscapeViewport } from '../client/landscapeLayout.js';
3
2
  import { loadingCover } from '../client/loadingCover.js';
4
3
  import { joinErrorText } from '../client/joinError.js';
5
4
  import { kitBackNeeded } from '../client/backVisibility.js';
6
- import { faceArrivalCamera } from '../client/arrivalCamera.js';
5
+ import { cancelArrivalShot, faceArrivalCamera } from '../client/arrivalCamera.js';
7
6
  import { makeDoorErrors } from '../client/doorErrors.js';
8
7
  import { makeVisibility } from '../client/visibility.js';
9
8
  import { makeInvites } from '../client/invites.js';
@@ -13,7 +12,7 @@ import { makeNoTrips } from '../client/noTrips.js';
13
12
  import { makeSignIn } from '../client/signIn.js';
14
13
  import { makeWeakestTier, readDistricts } from '../client/weakestTier.js';
15
14
  import { makeHudRate } from '../client/hudRate.js';
16
- import { allActors, capWorldLabels, lowQuality, noteQualityInteraction, qualityFor, qualityPlayers, qualitySpawnIds, restoreDecor } from '../client/quality.js';
15
+ import { allActors, capWorldLabels, cullAfterTier, cullBeforeLabels, lowQuality, noteQualityInteraction, qualityFor, qualitySpawnIds, qualityTags, lowerLate, restoreDecor, spawnLowQuality, splitTags, withDecorTemplates } from '../client/quality.js';
17
16
  import { makeActorBudget } from '../client/actorBudget.js';
18
17
  // The hub system: the door, and everything a place draws that a game cannot.
19
18
  // It runs after the engine's behaviors every frame and owns the trip between
@@ -41,7 +40,7 @@ import { makeActorBudget } from '../client/actorBudget.js';
41
40
  // same place in another session, which leaves the way back as it was.
42
41
 
43
42
  import * as castleSdk from 'castle-web-sdk';
44
- import { attend, fadeNames, makeAttention } from '../client/attention.js';
43
+ import { attend, behind, fadeNames, makeAttention } from '../client/attention.js';
45
44
  import { chromeItem, goalAt, labelBox, near, nearCandidates, nearFor } from '../client/labelsNear.js';
46
45
  import { mapWorldPoint, offsetWorldPoint, relevantLabels, worldLabelFocus } from '../client/worldLabels.js';
47
46
  import { bodyBox, occupancyText, placeLabels } from '../client/padOccupancy.js';
@@ -51,6 +50,7 @@ import { makePadReadability } from '../client/padReadability.js';
51
50
  import { crowdNamesFor, layoutCrowdNames, readableSpriteBox, spriteBox } from '../client/crowdNames.js';
52
51
  import { doorPoint } from '../client/doorFrame.js';
53
52
  import * as Avatar from '../client/avatar.js';
53
+ import * as Celebrate from '../client/celebrate.js';
54
54
  import { pongJoin } from '../client/firstJoin.js';
55
55
  import * as Rehello from '../client/rehello.js';
56
56
  import * as AvatarCap from '../client/avatarCap.js';
@@ -68,6 +68,8 @@ import * as Packs from '../client/pack.js';
68
68
  import * as Hub from '../client/state.js';
69
69
  import { clearShot } from '../client/shot.js';
70
70
  import { makeAct } from '../client/act.js';
71
+ import { catchingDim, catchingLine } from '../client/catchingUp.js';
72
+ import { blockedReasons, makeActGateLog } from '../client/actGateLog.js';
71
73
  import { backControl, backPress, backRoute, personAction, reportPerson } from '../client/hubControls.js';
72
74
  import { makeGrab } from '../client/grab.js';
73
75
  import { makeIdle } from '../client/idle.js';
@@ -87,9 +89,13 @@ import { LOAD_STAGES } from '../shared/loadStages.js';
87
89
  import { encodeDeviceClass } from '../shared/deviceClass.js';
88
90
  import { makeTiers } from '../client/tiers.js';
89
91
  import { goalPointers, goalText, makeTogether, pointerAt } from '../client/together.js';
92
+ import { replays } from '../client/replay.js';
90
93
  import { makeVehicle } from '../client/vehicle.js';
94
+ import { makeDisguise } from '../client/disguiseDraw.js';
95
+ import { disguiseTags } from '../client/disguise.js';
91
96
  import { carInput } from '../client/car.js';
92
- import { makeEarned, makeRole, makeWear } from '../client/wear.js';
97
+ import { makeEarned, makeHoldShow, makeRole, makeWear } from '../client/wear.js';
98
+ import { holdShowEarned, holdShowVisible } from '../client/holdShow.js';
93
99
  import { roleEarned, roleItems, roleWearing } from '../client/role.js';
94
100
  import { makeCompanion } from '../client/companion.js';
95
101
  import { makeDefaultEnvironment } from '../client/defaultEnvironment.js';
@@ -119,6 +125,10 @@ const GOAL_NEAR_M = 6;
119
125
  // A way back the host refused as unavailable is asked again once, this long
120
126
  // after, before the door stays shut.
121
127
  const BACK_RETRY_MS = 1500;
128
+ // A door whose destination the proxy could not route yet (4404 before hello)
129
+ // is acquired again when the join failed within this long of the handoff. The
130
+ // SDK has already tried the same nonce for a few seconds by then.
131
+ const DOOR_RETRY_WINDOW_MS = 10000;
122
132
  // How many times one way somewhere recovers from a hub join lost before the
123
133
  // session placed the player (`lostJoin`) before it gives up and uncovers.
124
134
  const LOST_TRIES_MAX = 2;
@@ -251,6 +261,14 @@ class HubSystem {
251
261
  this.pendingEnd = null;
252
262
  this.endSession = null;
253
263
  this.endLeaving = null;
264
+ // v1.169: the door an end in force was the player's own (`hub-end`'s
265
+ // `door`), whether the connection was away while it was in force, and
266
+ // the word owed to a place whose end or door was cancelled (`stayDue`).
267
+ this.endDoor = null;
268
+ this.endNumber = null;
269
+ this.endAway = false;
270
+ this.endTripN = null;
271
+ this.stayDue = null;
254
272
  this.helloNet = null;
255
273
  this.helloAvatar = null;
256
274
  this.signIn = makeSignIn({ api: castleSdk.Hub, signedIn: () => { this.helloNet = null; } });
@@ -266,8 +284,10 @@ class HubSystem {
266
284
  this.spin = null;
267
285
  this.wear = makeWear();
268
286
  this.vehicle = makeVehicle();
287
+ this.disguise = makeDisguise();
269
288
  this.earned = makeEarned();
270
289
  this.roles = makeRole();
290
+ this.holdShows = makeHoldShow();
271
291
  this.toast = { text: '', until: 0 };
272
292
  this.leavingToast = null;
273
293
  this.stats = statsWanted();
@@ -528,7 +548,7 @@ class HubSystem {
528
548
  this.endLayoutFrame();
529
549
  });
530
550
  }
531
- loadingCover?.sync(scene);
551
+ loadingCover?.sync(scene, { arriving: this.coverArriving(scene.multiplayer) });
532
552
  const mp = scene.multiplayer;
533
553
  if (!mp) {
534
554
  this.endLayoutFrame();
@@ -578,8 +598,8 @@ class HubSystem {
578
598
  }
579
599
  this.chrome.safeSurface?.('invite-dialog', this.invites?.surface?.());
580
600
  Avatar.load(scene);
581
- this.talk ??= makeTalk(this.chrome);
582
- this.grab ??= makeGrab(this.chrome);
601
+ this.talk ??= makeTalk(this.chrome, () => this.refuseCatching());
602
+ this.grab ??= makeGrab(this.chrome, () => this.refuseCatching());
583
603
  this.idle ??= makeIdle(this.chrome);
584
604
  this.sound ??= makeSound();
585
605
  if (Hub.deck.soundscape && !this.soundscape) {
@@ -622,7 +642,7 @@ class HubSystem {
622
642
  this.watchSession(scene, mp);
623
643
  this.sayHello(scene, mp);
624
644
  if (Hub.hub.place?.push?.version === 1 && Hub.hub.arrivedFacing !== null && mp.net) {
625
- this.pushVisit = reportPushVisit(mp.net, Hub.hub.place, Rehello.mark(mp, mp.net), this.pushVisit);
645
+ this.pushVisit = reportPushVisit(mp.net, Hub.hub.place, Rehello.mark(mp, mp.net), this.pushVisit, undefined, undefined, Hub.hub.catching != null);
626
646
  }
627
647
  if (Hub.hub.place?.visibility === true || this.visibility) {
628
648
  this.visibility ??= makeVisibility();
@@ -667,11 +687,12 @@ class HubSystem {
667
687
  this.decor = null;
668
688
  }
669
689
  if (Hub.hub.place?.decor && !this.decor) {
670
- this.decor = makeDecor(this.chrome);
690
+ this.decor = makeDecor(this.chrome, { refuse: () => this.refuseCatching() });
671
691
  }
672
692
  this.decor?.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && this.chrome.pickerSheetOpen?.() !== true);
673
693
  const decorating = this.decor?.opened() === true;
674
694
  this.stepEnd(scene, mp, now);
695
+ this.sendStay(scene, mp);
675
696
  // v1.68, rule B (`client/ballot.js`): the choice card runs only while
676
697
  // its one gate holds a card (`ballotHeld`), which a place without
677
698
  // `ballot` never does; when it lets go (another connection), the sheet
@@ -685,6 +706,7 @@ class HubSystem {
685
706
  this.ballot ??= makeBallot({
686
707
  ...((Hub.deck.safeInsets === true || Hub.deck.act === true) ? { safeInsets: true } : {}),
687
708
  send: (ids) => this.scene?.multiplayer?.net?.send({ k: 'hub-ballot', ...ids }),
709
+ refuse: () => this.refuseCatching(),
688
710
  ...(Hub.deck.soundscape?.ui === true ? { onChip: () => this.soundscape?.cue('tap', performance.now()) } : {}),
689
711
  });
690
712
  this.carded = card !== null && !this.trip;
@@ -712,12 +734,23 @@ class HubSystem {
712
734
  this.chrome.cancelActionOverflow();
713
735
  }
714
736
  this.talk.frame(scene, mp, !this.trip && this.pendingEnd === null);
737
+ // v1.204: while the server reads this player's progress, what it would
738
+ // refuse is refused here with a line, and its controls dim.
739
+ const catching = catchingDim(Hub.hub.catching, now);
740
+ if (catching !== Boolean(this.catchingShown)) {
741
+ this.catchingShown = catching;
742
+ this.chrome.setCatching?.(catching);
743
+ }
715
744
  if (Hub.hub.place?.ask === true) {
716
745
  this.askDrawn = true;
717
746
  Hub.hub.askClose ??= () => this.clearTextAsk();
718
747
  const canAsk = !this.trip && this.pendingEnd === null && !decorating && card === null && !this.talk.talking();
719
748
  this.chrome.setTextAsk(canAsk ? Hub.hub.ask : null,
720
- (id, n, text) => mp.net?.send({ k: 'hub-answer', id, n, text }),
749
+ (id, n, text) => {
750
+ if (this.refuseCatching()) {return false;}
751
+ mp.net?.send({ k: 'hub-answer', id, n, text });
752
+ return true;
753
+ },
721
754
  (open) => {
722
755
  if (open) {
723
756
  this.askInput = holdAskInput(scene);
@@ -734,7 +767,7 @@ class HubSystem {
734
767
  Hub.hub.menuClose ??= () => this.clearMenu();
735
768
  const canMenu = !this.trip && this.pendingEnd === null && !decorating && card === null && !this.talk.talking() && !this.askInput;
736
769
  this.chrome.setMenu(canMenu ? Hub.hub.menu : null,
737
- (id, n) => mp.net?.send({ k: 'hub-menu-pick', id, n }),
770
+ (id, n) => {if (!this.refuseCatching()) {mp.net?.send({ k: 'hub-menu-pick', id, n });}},
738
771
  (open) => {
739
772
  if (open) {
740
773
  this.menuInput = holdAskInput(scene);
@@ -784,8 +817,16 @@ class HubSystem {
784
817
  this.chrome.hornPrompt?.(() => mp.net?.send({ k: 'hub-horn' }));
785
818
  }
786
819
  if (Hub.deck.act === true) {
787
- this.act ??= makeAct(this.chrome, this.grab, this.talk);
788
- this.act.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput && !this.askInput && !this.menuInput && !this.carded);
820
+ this.act ??= makeAct(this.chrome, this.grab, this.talk, () => this.refuseCatching());
821
+ const talking = this.talk.talking();
822
+ const can = !this.trip && this.pendingEnd === null && !talking && !decorating && !this.actionInput && !this.askInput && !this.menuInput && !this.carded;
823
+ this.act.frame(scene, mp, local, can, can ? undefined : blockedReasons({ trip: this.trip, pendingEnd: this.pendingEnd !== null, talking, decorating,
824
+ actionInput: this.actionInput, askInput: this.askInput, menuInput: this.menuInput, carded: this.carded }));
825
+ // v1.203: an opted-in place hears each change of the pair's gate.
826
+ if (Hub.hub.place?.actGateLog === true) {
827
+ this.actGateLog ??= makeActGateLog();
828
+ this.actGateLog.frame(mp.net ?? null, this.act.gate(), Hub.hub.place);
829
+ }
789
830
  }
790
831
  this.noteArrival(mp, now);
791
832
  if (this.trip) {
@@ -799,14 +840,16 @@ class HubSystem {
799
840
  const cam = scene.three?.camera;
800
841
  const view = { w: window.innerWidth, h: window.innerHeight };
801
842
  const framing = cam ? {
802
- camera: { position: cam.position, forward: cam.getWorldDirection(cam.position.clone()) },
843
+ // The chat flight sizes Chirp by depth, so it needs the zoomed lens.
844
+ camera: { position: cam.position, forward: cam.getWorldDirection(cam.position.clone()), fov: 2 * Math.atan(Math.tan(cam.fov * Math.PI / 360) / (cam.zoom ?? 1)) * 180 / Math.PI, near: cam.near },
803
845
  panel: this.chrome.talkRect?.(), view,
804
846
  project: (at) => project(cam, at.x, at.y, at.z, view),
805
847
  } : null;
806
848
  const chat = Hub.hub.place?.companionChat && this.talk.talkingToCompanion?.() ? framing ?? {} : null;
807
849
  const activity = { ...framing, chatting: this.talk.talking() };
808
850
  const busy = Boolean(this.talk.talkingWith()?.startsWith('companion:') || now < (this.companionTappedUntil ?? -Infinity));
809
- this.companion.frame(scene, local, Hub.hub, dt, now, !this.trip && this.pendingEnd === null, chat, busy, activity);
851
+ this.companion.frame(scene, local, Hub.hub, dt, now, !this.trip && this.pendingEnd === null, chat, busy, activity,
852
+ this.lowTier === true);
810
853
  } else if (this.companion) {
811
854
  this.companion.dispose();
812
855
  delete this.companion;
@@ -819,12 +862,13 @@ class HubSystem {
819
862
  const inviting = () => Hub.hub.place?.invite === true && this.invites?.canInvite(mp.net, castleSdk.User) === true;
820
863
  const offered = Hub.hub.actions?.items ?? null, invites = offered?.some((item) => INVITE_ACTIONS.has(item?.id)) ? inviting() : true;
821
864
  const items = this.signIn.items(Hub.hub.place, hud, invites ? offered : offered.filter((item) => !INVITE_ACTIONS.has(item?.id)));
865
+ // v1.187: every place draws its offers on the overflow rail, landscape included.
822
866
  this.chrome.setActions(items, (id, n) => {
823
867
  if (id === 'signin' && Hub.hub.place?.anonymousEntry === true) {void this.signIn.press(hud?.text ?? 'Keep your progress');}
824
868
  else if (INVITE_ACTIONS.has(id) && !inviting()) {return;}
825
- else {mp.net?.send({ k: 'hub-action', id, n });}
869
+ else if (!this.refuseCatching()) {mp.net?.send({ k: 'hub-action', id, n });}
826
870
  }, !this.signIn.pending() && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput,
827
- Hub.hub.actions?.n, scene.data?.engine?.hubActionOverflow === true || !landscapeViewport(), (open) => {
871
+ Hub.hub.actions?.n, true, (open) => {
828
872
  if (open) {
829
873
  this.actionInput = holdAskInput(scene);
830
874
  } else if (this.actionInput) {
@@ -896,12 +940,22 @@ class HubSystem {
896
940
  onLayout: (node) => this.chrome?.safeSurface?.('cells-debug', node, 'text') });
897
941
  const pick = (mode) => {
898
942
  this.tiers.set(mode);
943
+ this.graphicsShown = this.tiers.mode;
899
944
  this.chrome?.setGraphics?.(this.tiers.mode, pick, Hub.deck.weakestTier === true);
900
945
  };
946
+ this.graphicsPick = pick;
947
+ this.graphicsShown = this.tiers.mode;
901
948
  this.chrome?.setGraphics?.(this.tiers.mode, pick, Hub.deck.weakestTier === true);
949
+ } else if (this.tiers.mode !== this.graphicsShown) {
950
+ // The stored pick arrived after the row was drawn (a frame without
951
+ // localStorage: `client/deviceStorage.js`).
952
+ this.graphicsShown = this.tiers.mode;
953
+ this.chrome?.setGraphics?.(this.tiers.mode, this.graphicsPick, Hub.deck.weakestTier === true);
902
954
  }
903
955
  const counts = !this.trip && this.pendingEnd === null && mp?.placed?.() === true;
904
956
  this.tiers.frame(scene, counts, now);
957
+ // v1.181: others' shown Chirps fall back to a tinted glow on Low.
958
+ this.lowTier = !scene.content && this.tiers.current?.() === 'low';
905
959
  const profile = Hub.deck.weakestTier === true
906
960
  ? (this.tiers.weakest() ? 'weakest' : this.tiers.middle?.() ? 'middle' : null)
907
961
  : null;
@@ -918,7 +972,7 @@ class HubSystem {
918
972
  ...Object.keys(Hub.hub.labelsMe ?? {}),
919
973
  ]);
920
974
  this.weakestTier.frame(scene, true, now, Hub.deck.weakestLookBake === true, pointerTargets);
921
- } else if (this.weakestTier?.active) {
975
+ } else if (this.weakestTier?.active || this.weakestTier?.capped) {
922
976
  this.weakestTier.restore();
923
977
  }
924
978
  const weakestActive = this.weakestTier?.active && this.weakestTier.profile === 'weakest';
@@ -935,12 +989,16 @@ class HubSystem {
935
989
  if (Hub.hub.place?.interest === 'cells') {
936
990
  this.interestTier = this.tiers.current();
937
991
  }
938
- if (fpsTelemetryFor(mp?.net)) {this.fpsTier = this.tiers.weakest() ? 3 : this.tiers.current() === 'low' ? 1 : 2;}
992
+ if (fpsTelemetryFor(mp?.net)) {
993
+ this.fpsTier = this.tiers.weakest() ? 3 : this.tiers.current() === 'low' ? 1 : 2;
994
+ this.fpsQuality = lowQuality(scene)?.decor;
995
+ }
939
996
  if (Hub.deck.quality || Hub.deck.highOnly) {
940
997
  const quality = qualityFor(scene);
941
998
  if (quality) {
999
+ lowerLate(scene, quality);
942
1000
  restoreDecor(scene, quality, quality.build);
943
- if (Hub.deck.quality) {qualityPlayers(scene, quality, now);}
1001
+ if (Hub.deck.quality) {cullAfterTier(scene, quality, now);}
944
1002
  }
945
1003
  }
946
1004
  globalThis.__hub.tier = this.tiers.handle;
@@ -973,7 +1031,9 @@ class HubSystem {
973
1031
  // The systems that run after every other one, registered once per runtime.
974
1032
  // Cars (v1.160) after the multiplayer kit has placed every avatar: each
975
1033
  // look under its driver's node, riders on their seats, a rider's camera.
1034
+ applyDisguise(s) {this.disguise.draw(s, s.actorWith('Player'));}
976
1035
  applyCars(s) {
1036
+ replays.frame(s);
977
1037
  this.vehicle.draw(s, s.actorWith('Player'), Hub.hub.cars);
978
1038
  if (Object.keys(Hub.hub.cars).length) {
979
1039
  this.vehicle.camera(s, s.actorWith('Player'), Hub.hub.cars);
@@ -989,6 +1049,7 @@ class HubSystem {
989
1049
  this.applyWear(s);
990
1050
  this.applyCars(s);
991
1051
  this.fadeNames(s);
1052
+ this.applyDisguise(s);
992
1053
  },
993
1054
  });
994
1055
  // Device tiers run as a system of their own, registered only in a deck
@@ -1086,14 +1147,18 @@ class HubSystem {
1086
1147
  this.scenePath = scene.currentScenePath;
1087
1148
  this.sceneKey = sceneKeyOf(scene);
1088
1149
  this.doorBase.clear();
1089
- this.stash.clear();
1150
+ this.clearStash();
1090
1151
  this.tinted.clear();
1091
1152
  this.spawnedHere.clear();
1092
1153
  this.companion?.clear();
1093
1154
  this.vehicle.clear();
1155
+ this.disguise.clear();
1156
+ replays.clear();
1157
+ Celebrate.clear();
1094
1158
  this.wear.clear(scene);
1095
1159
  this.earned.clear();
1096
1160
  this.roles.clear();
1161
+ this.holdShows.clear();
1097
1162
  this.idle?.release();
1098
1163
  if (this.decor) {
1099
1164
  this.decor.dispose();
@@ -1134,18 +1199,23 @@ class HubSystem {
1134
1199
  this.decor.dispose();
1135
1200
  this.decor = null;
1136
1201
  }
1137
- this.stash.clear();
1202
+ this.clearStash();
1138
1203
  this.tinted.clear();
1139
1204
  this.spawnedHere.clear();
1140
1205
  this.vehicle.clear();
1206
+ this.disguise.clear();
1207
+ replays.clear();
1208
+ Celebrate.clear();
1141
1209
  if (scene) {
1142
1210
  this.wear.clear(scene);
1143
1211
  this.earned.clear();
1144
1212
  this.roles.clear();
1213
+ this.holdShows.clear();
1145
1214
  } else {
1146
1215
  this.wear.forget();
1147
1216
  this.earned.forget();
1148
1217
  this.roles.forget();
1218
+ this.holdShows.forget();
1149
1219
  }
1150
1220
  }
1151
1221
 
@@ -1179,13 +1249,23 @@ class HubSystem {
1179
1249
  return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
1180
1250
  });
1181
1251
  }
1252
+ const shows = Hub.hub.holdShows;
1253
+ if (shows.size > 0 || this.holdShows?.size > 0) {
1254
+ this.holdShows.frame(scene, local ?? scene.actorWith('Player'),
1255
+ holdShowVisible(shows, Hub.hub.roles, self, this.grab?.holding?.()), (id) => {
1256
+ const index = indexOf(id);
1257
+ return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
1258
+ });
1259
+ }
1182
1260
  // Earned items (v1.53): no work at all while nobody shows one and
1183
1261
  // nothing is drawn.
1184
1262
  if (Hub.hub.earned.size > 0 || this.earned.size > 0) {
1185
- this.earned.frame(scene, local ?? scene.actorWith('Player'), roleEarned(Hub.hub.earned, Hub.hub.roles), (playerId) => {
1263
+ // Low draws no arrival sparkle.
1264
+ const view = { low: this.lowTier === true };
1265
+ this.earned.frame(scene, local ?? scene.actorWith('Player'), roleEarned(holdShowEarned(Hub.hub.earned, shows), Hub.hub.roles), (playerId) => {
1186
1266
  const index = indexOf(playerId);
1187
1267
  return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
1188
- });
1268
+ }, view);
1189
1269
  }
1190
1270
  }
1191
1271
 
@@ -1262,6 +1342,9 @@ class HubSystem {
1262
1342
  if (say !== 'none') {
1263
1343
  console.log(`[hub] the connection came back (${back}): saying a ${say} hello`);
1264
1344
  this.sendHello(scene, mp, net, avatar, say === 'resume' ? { resume: true } : { solo: true });
1345
+ if (say === 'resume') {
1346
+ this.resendStay(scene, net);
1347
+ }
1265
1348
  this.noTripsAfterHello(net);
1266
1349
  if (back === 'world') {
1267
1350
  this.talk?.resume();
@@ -1303,9 +1386,23 @@ class HubSystem {
1303
1386
  // as on any switch of session, along with what this client kept of it.
1304
1387
  newIdentity() {
1305
1388
  this.pushVisit = null;
1389
+ // Another player id is another session: nothing owed goes to it.
1390
+ this.stayDue = null;
1306
1391
  this.admitEpoch = (this.admitEpoch ?? 0) + 1;
1307
1392
  console.log('[hub] the connection has a new player id: a new session');
1308
1393
  this.identityPlace = Hub.hub.place ?? this.identityPlace;
1394
+ // The loading cover waits for this session's arrival (`coverArriving`).
1395
+ this.rejoinNet = this.helloNet ?? null;
1396
+ // The same page coming back to the same place: the camera keeps the way
1397
+ // the player had it turned rather than the new session's arrival facing
1398
+ // (`faceArrival`). Only after an arrival this page has faced, outside a
1399
+ // trip: a page that never arrived has no yaw of the player's to keep.
1400
+ this.keepYawNet = Hub.hub.faced && !this.trip ? this.helloNet ?? null : null;
1401
+ // The new session's shot may come before its arrival: an earlier
1402
+ // arrival's wait for its shot must not take it and turn the camera.
1403
+ if (this.keepYawNet && this.scene) {
1404
+ cancelArrivalShot(this.scene);
1405
+ }
1309
1406
  Hub.clear();
1310
1407
  // The server forgets invitations with an old player identity. Hub.clear
1311
1408
  // resets that occurrence, while the shared slot retains other expired
@@ -1320,6 +1417,19 @@ class HubSystem {
1320
1417
  this.startNear = null;
1321
1418
  }
1322
1419
 
1420
+ // Whether the loading cover still waits for a fresh player id's arrival on
1421
+ // the net that was greeted: the new session placed the body at its spawn,
1422
+ // and the place's arrival (a resumePose restore, its first HUD) follows as
1423
+ // hub-arrived and then the clamped row that latches `arrivalPlaced`.
1424
+ coverArriving(mp) {
1425
+ if (!this.rejoinNet) {return false;}
1426
+ if (this.rejoinNet !== mp?.net || Hub.hub.arrivalPlaced) {
1427
+ this.rejoinNet = null;
1428
+ return false;
1429
+ }
1430
+ return true;
1431
+ }
1432
+
1323
1433
  // What this client keeps of one session, cleared when it joins another.
1324
1434
  freshSession(scene, { keepAskSlot = false } = {}) {
1325
1435
  // A player who walks in (no door, no jump to a friend) starts beside a
@@ -1364,7 +1474,15 @@ class HubSystem {
1364
1474
 
1365
1475
  // `solo`: a party of one carrying nothing and naming no friend, as `resume`
1366
1476
  // is, without saying it resumes (a game's new session, `helloAfter`).
1477
+ clearReplays() {
1478
+ replays.clear();
1479
+ Celebrate.clear();
1480
+ }
1481
+
1367
1482
  sendHello(scene, mp, net, avatar, { again = false, resume = false, solo = resume, inviteNear = null } = {}) {
1483
+ // v1.163: a fresh hello starts with no ghosts (a method, so tests that
1484
+ // run this method alone need not load the replay module).
1485
+ if (!again) {this.clearReplays?.();}
1368
1486
  if (resume && (this.menuDrawn || Object.hasOwn(Hub.hub, 'menu'))) {
1369
1487
  this.clearMenu();
1370
1488
  delete Hub.hub.menu;
@@ -1411,6 +1529,17 @@ class HubSystem {
1411
1529
  });
1412
1530
  }
1413
1531
 
1532
+ // A scene change forgets what was hidden; what a solid hide turned off is
1533
+ // turned on again first, since a parked node can be reused.
1534
+ clearStash() {
1535
+ for (const kept of this.stash.values()) {
1536
+ for (const child of kept === true ? [] : kept.off) {
1537
+ child.visible = true;
1538
+ }
1539
+ }
1540
+ this.stash.clear();
1541
+ }
1542
+
1414
1543
  // Hide what the place hid, and put back what it showed again (contract §10).
1415
1544
  // A hidden actor is dropped far below the ground, collider and all, rather
1416
1545
  // than despawned: the multiplayer kit reports a despawned scene actor to the
@@ -1420,23 +1549,64 @@ class HubSystem {
1420
1549
  // shown again by lifting it from wherever it is.
1421
1550
  // The engine is told before each write (`scene.touch`): a scene may hold
1422
1551
  // the actor still (physics-3d `"engine": { "staticActors": true }`).
1552
+ // v1.184: an actor this viewer's private hide named `solid` keeps its pose,
1553
+ // and so its collider; only what its node draws is hidden. That is the
1554
+ // node's children, never the node itself: the tier and quality levers save
1555
+ // and restore the node's own `visible`, and must not capture this hide's
1556
+ // (nor this hide theirs). Shared model instances read every ancestor of
1557
+ // their rig, the rig included. The stash entry holds the node and the
1558
+ // children this hide turned off, turned on again when it ends.
1423
1559
  applyVisibility(scene) {
1424
- for (const id of Hub.hub.hidden) {
1560
+ const hidden = Hub.hub.hidden;
1561
+ const solid = Hub.hub.hiddenSolid;
1562
+ for (const [id, kept] of this.stash) {
1563
+ if (kept === true ? hidden.has(id) && !solid.has(id) : solid.has(id)) {
1564
+ continue;
1565
+ }
1566
+ this.stash.delete(id);
1567
+ if (kept !== true) {
1568
+ for (const child of kept.off) {
1569
+ child.visible = true;
1570
+ }
1571
+ continue;
1572
+ }
1425
1573
  const t = scene.getActor(id)?.components.Transform;
1426
- if (t && t.y > -HIDE_DROP_M / 2) {
1427
- this.stash.set(id, true);
1574
+ if (t && t.y < -HIDE_DROP_M / 2) {
1428
1575
  scene.touch?.(id);
1429
- t.y -= HIDE_DROP_M;
1576
+ t.y += HIDE_DROP_M;
1430
1577
  }
1431
1578
  }
1432
- for (const id of this.stash.keys()) {
1433
- if (!Hub.hub.hidden.has(id)) {
1434
- this.stash.delete(id);
1435
- const t = scene.getActor(id)?.components.Transform;
1436
- if (t && t.y < -HIDE_DROP_M / 2) {
1437
- scene.touch?.(id);
1438
- t.y += HIDE_DROP_M;
1579
+ for (const id of hidden) {
1580
+ if (solid.has(id)) {
1581
+ const node = scene.three?.nodes?.get(id)?.node;
1582
+ let kept = this.stash.get(id);
1583
+ if (kept && kept.node !== node) {
1584
+ // Rebuilt: the old node's children are turned on again.
1585
+ for (const child of kept.off) {
1586
+ child.visible = true;
1587
+ }
1588
+ this.stash.delete(id);
1589
+ kept = undefined;
1590
+ }
1591
+ if (node && !kept) {
1592
+ kept = { node, off: new Set() };
1593
+ this.stash.set(id, kept);
1439
1594
  }
1595
+ // Only a child drawn now is turned off, and so later back on: one
1596
+ // already off is left as it is.
1597
+ for (const child of node?.children ?? []) {
1598
+ if (child.visible) {
1599
+ child.visible = false;
1600
+ kept.off.add(child);
1601
+ }
1602
+ }
1603
+ continue;
1604
+ }
1605
+ const t = scene.getActor(id)?.components.Transform;
1606
+ if (t && t.y > -HIDE_DROP_M / 2) {
1607
+ this.stash.set(id, true);
1608
+ scene.touch?.(id);
1609
+ t.y -= HIDE_DROP_M;
1440
1610
  }
1441
1611
  }
1442
1612
  }
@@ -1451,11 +1621,12 @@ class HubSystem {
1451
1621
  applySpawns(scene) {
1452
1622
  const want = Hub.hub.spawned;
1453
1623
  const mp = scene.multiplayer;
1454
- const quality = Hub.deck.quality ? lowQuality(scene) : null;
1455
- const allowed = quality ? qualitySpawnIds(want, Hub.hub.spawnTemplates, scene.actorWith('Player')?.components.Transform, quality.spawned) : null;
1624
+ const quality = Hub.deck.quality ? spawnLowQuality(scene) : null;
1625
+ const decorOf = quality ? withDecorTemplates(Hub.hub.spawnTemplates, Hub.hub.decorTemplates) : null;
1626
+ const allowed = quality ? qualitySpawnIds(want, decorOf, scene.actorWith('Player')?.components.Transform, quality.spawned) : null;
1456
1627
  if (allowed) {
1457
1628
  for (const id of this.spawnedHere) {
1458
- if (Object.hasOwn(want, id) && !allowed.has(id) && Hub.hub.spawnTemplates[want[id].from]?.decor === true) {
1629
+ if (Object.hasOwn(want, id) && !allowed.has(id) && decorOf[want[id].from]?.decor === true) {
1459
1630
  this.spawnedHere.delete(id);
1460
1631
  this.stash.delete(id); this.tinted.delete(id);
1461
1632
  mp?.avatars?.retired?.add(id);
@@ -1608,6 +1779,10 @@ class HubSystem {
1608
1779
  } else if (msg.k === 'hub-go' && msg.classic) {
1609
1780
  // A cabinet: the host plays a classic deck; this place waits (v1.7).
1610
1781
  this.goClassic(scene, msg);
1782
+ } else if (msg.k === 'hub-go' && !msg.key && this.offlineDoor(scene, msg)) {
1783
+ // v1.169: a pad that fired while this client was away stays shut.
1784
+ console.warn(`[hub-door] the door ${msg.door} fired while offline: staying`);
1785
+ this.stayDue = { msg: { k: 'hub-shut', door: msg.door }, session: sessionKey(scene) };
1611
1786
  } else if (msg.k === 'hub-go' && !msg.key) {
1612
1787
  // A pad ghost fired: the host acquires the trip (Hub.go).
1613
1788
  this.goHub(scene, msg);
@@ -1615,6 +1790,14 @@ class HubSystem {
1615
1790
  this.go(scene, msg);
1616
1791
  } else if (msg.k === 'hub-result') {
1617
1792
  scene.persistent.hubResult = { ...msg.result, at: Date.now() };
1793
+ } else if (msg.k === 'hub-stayed') {
1794
+ // v1.169: the place un-ended the end this client stayed: owed no more.
1795
+ if (this.stayDue?.end !== undefined && this.stayDue.end === msg.end) {
1796
+ this.stayDue = null;
1797
+ }
1798
+ } else if (msg.k === 'hub-end' && this.offlineEnd(scene, msg)) {
1799
+ // v1.169: the player's own door end, taken while away: cancelled.
1800
+ this.cancelEnd(scene, msg.door, msg.end);
1618
1801
  } else if (msg.k === 'hub-end' && Rehello.takesEnd(msg, this.pendingEnd, this.endSession, sessionKey(scene))) {
1619
1802
  // An end that meets a player coming back from away (a game that ran
1620
1803
  // out meanwhile, a fresh admission it ends at once) is not paused on:
@@ -1623,6 +1806,12 @@ class HubSystem {
1623
1806
  this.pendingEnd = this.endCovered ? now : now + END_PAUSE_MS;
1624
1807
  this.endSession = sessionKey(scene);
1625
1808
  this.endLeaving = null;
1809
+ // A later end: nothing owed for an earlier one goes any more.
1810
+ this.stayDue = null;
1811
+ this.endDoor = Rehello.ownDoor(msg, Hub.hub.place);
1812
+ this.endNumber = this.endDoor !== null && Number.isSafeInteger(msg.end) ? msg.end : null;
1813
+ this.endAway = false;
1814
+ this.endTripN = null;
1626
1815
  // Only a game is over: a place without a result that sends a player
1627
1816
  // back (the House's front door, the first room's way to the Town)
1628
1817
  // says what it says in its own HUD.
@@ -1674,7 +1863,7 @@ class HubSystem {
1674
1863
  });
1675
1864
  if (msg) {
1676
1865
  console.log(`[hub-host-go] ${JSON.stringify({ door: msg.door, party: msg.party, owner: Boolean(msg.owner) })}`);
1677
- this.goHub(scene, msg);
1866
+ this.goHub(scene, { ...msg, host: true });
1678
1867
  }
1679
1868
  }
1680
1869
 
@@ -1782,8 +1971,13 @@ class HubSystem {
1782
1971
  scene: null,
1783
1972
  content: undefined,
1784
1973
  deck: msg.title ?? msg.door,
1785
- retryDoor: msg.door,
1974
+ // A host's Go rides an acquisition the host made from its own session:
1975
+ // asked again from this one, whose player never stood on the pad, ghost
1976
+ // refuses it, so a host's trip has no door retry.
1977
+ retryDoor: msg.host ? null : msg.door,
1786
1978
  retryOwner: msg.owner ?? null,
1979
+ // v1.171: the host is told should this trip fail (`hostGoFailed`).
1980
+ hostGo: msg.host ? { doorId: msg.door, owner: msg.owner ?? null } : null,
1787
1981
  pending: this.resolveHub(scene, () => hubGo(msg.door, msg.owner)),
1788
1982
  join: null,
1789
1983
  title: msg.title,
@@ -2248,12 +2442,15 @@ class HubSystem {
2248
2442
  // (`hub.stuck`): without it this is never called and nothing of it is made.
2249
2443
  // A chip is offered to a player who has walked for a few seconds and got
2250
2444
  // nowhere; nothing moves them but their own tap. Only in a town that says
2251
- // it takes it (`hubStuck`), and never to a player the place holds.
2445
+ // it takes it (`hubStuck`), never to a player the place holds, and never
2446
+ // while a sheet is open (a talk panel, a card, an ask or a menu): its
2447
+ // keys and the chip's are not a walk that got nowhere.
2252
2448
  offerUnstick(scene, local, town, now) {
2253
2449
  const offer = town ? Hub.hub.stuck : null;
2254
2450
  const t = local?.components.Transform;
2255
2451
  const selfId = scene.multiplayer?.net?.selfId?.();
2256
- if (!offer || !t || Hub.hub.held.has(selfId)) {
2452
+ const sheet = Boolean(this.talk?.talking()) || this.carded || Boolean(this.askInput || this.menuInput);
2453
+ if (!offer || !t || Hub.hub.held.has(selfId) || sheet) {
2257
2454
  if (this.stuck) {
2258
2455
  resetStuck(this.stuck);
2259
2456
  this.stuckShown = false;
@@ -2692,6 +2889,12 @@ class HubSystem {
2692
2889
  return;
2693
2890
  }
2694
2891
  if (press === 'quit') {scene.multiplayer?.net?.send({ k: 'hub-door-quit' });}
2892
+ // v1.173: the player's own Back out of a place without `result` arms the
2893
+ // server, so the drop that follows ends the visit there and their next
2894
+ // entry is a fresh arrival rather than a resume of this one. Said only here, before `back` asks the host: automatic
2895
+ // backs (a game's end, a place that ended, a failed door) never say it,
2896
+ // and a trip under way ignores the press.
2897
+ if (press === 'back' && Hub.hub.place && !this.trip) {scene.multiplayer?.net?.send({ k: 'hub-back' });}
2695
2898
  this.back(scene);
2696
2899
  }
2697
2900
 
@@ -2806,6 +3009,8 @@ class HubSystem {
2806
3009
  if (this.trip) {
2807
3010
  return;
2808
3011
  }
3012
+ // A trip leaves the place: a stay or shut owed to it goes no more.
3013
+ this.stayDue = null;
2809
3014
  this.fpsTelemetry?.leave();
2810
3015
  clearShot();
2811
3016
  if (Hub.deck.soundscape?.ui === true && target.exitDoor) {
@@ -2956,7 +3161,7 @@ class HubSystem {
2956
3161
  } else if (state === 'failed') {
2957
3162
  const age = now - trip.target.acquiredAt;
2958
3163
  if (trip.target.retryDoor && !trip.doorRetried && mp.joinFailure?.closeCode === 4404 &&
2959
- mp.joinFailure.code === 'MULTIPLAYER_CONNECTION_FAILED' && age >= 0 && age <= 5000) {
3164
+ mp.joinFailure.code === 'MULTIPLAYER_CONNECTION_FAILED' && age >= 0 && age <= DOOR_RETRY_WINDOW_MS) {
2960
3165
  trip.doorRetried = true;
2961
3166
  trip.retryDoorAt = now + 2500;
2962
3167
  trip.phase = 'retrying-door';
@@ -3089,6 +3294,22 @@ class HubSystem {
3089
3294
  trip.target.pendingFrom = now;
3090
3295
  return false;
3091
3296
  }
3297
+ // v1.169: the way back of the player's own door end, while the
3298
+ // connection was away: given back, and the end cancelled.
3299
+ if (trip.n === this.endTripN && this.endDoor !== null && this.pendingEnd !== null &&
3300
+ (this.endAway || Rehello.connectionAway(scene.multiplayer))) {
3301
+ trip.target.pending = null;
3302
+ if (!pending.done) {
3303
+ pending.abandoned = true;
3304
+ } else if (pending.join && !pending.error) {
3305
+ this.cancelHub();
3306
+ }
3307
+ const door = this.endDoor, end = this.endNumber;
3308
+ this.shutDoor(scene, trip, 'its end was taken while offline', now);
3309
+ this.toast = { text: '', until: 0 };
3310
+ this.cancelEnd(scene, door, end);
3311
+ return false;
3312
+ }
3092
3313
  const content = pending.content;
3093
3314
  const prefix = content?.sessionKeyPrefix ?? '';
3094
3315
  // A way back to a place this runtime already holds keeps its own content.
@@ -3119,7 +3340,10 @@ class HubSystem {
3119
3340
  this.cancelHub();
3120
3341
  }
3121
3342
  if (trip.phase === 'retrying-door') {this.uncommitted(scene, trip, now);}
3122
- else {this.shutDoor(scene, trip, error, now);}
3343
+ else {
3344
+ this.hostGoFailed(trip, pending.join ? 'content' : 'refused');
3345
+ this.shutDoor(scene, trip, error, now);
3346
+ }
3123
3347
  return false;
3124
3348
  }
3125
3349
  trip.marks.resolved = now;
@@ -3140,6 +3364,25 @@ class HubSystem {
3140
3364
  return true;
3141
3365
  }
3142
3366
 
3367
+ // v1.171: a host's Go (`hookHostGo`) that ended before the host committed
3368
+ // its join: the host is told once (`Hub.goFailed`), since only it can
3369
+ // acquire the door again -- from its own session, where ghost's pad check
3370
+ // passes. The kit never asks again itself (`retryDoor`). A join the host
3371
+ // committed and then lost is not a failed Go: the player went through.
3372
+ hostGoFailed(trip, why) {
3373
+ const go = trip.target.hostGo;
3374
+ if (!go || trip.hostGoFailed || typeof castleSdk.Hub?.goFailed !== 'function') {
3375
+ return;
3376
+ }
3377
+ trip.hostGoFailed = true;
3378
+ console.log(`[hub-host-go] ${JSON.stringify({ failed: go.doorId, why, owner: Boolean(go.owner) })}`);
3379
+ try {
3380
+ castleSdk.Hub.goFailed(go, why);
3381
+ } catch (err) {
3382
+ console.warn(`[hub-host-go] could not tell the host: ${err?.message ?? err}`);
3383
+ }
3384
+ }
3385
+
3143
3386
  // The door stays shut: forget the way back this trip pushed, and lift the
3144
3387
  // cover on the place the player never left.
3145
3388
  shutDoor(scene, trip, why, now) {
@@ -3255,6 +3498,7 @@ class HubSystem {
3255
3498
  // more from where the player still is, then left to the Back control.
3256
3499
  uncommitted(scene, trip, now) {
3257
3500
  console.warn(`[hub-door] the trip to ${trip.target.deck} did not commit`);
3501
+ this.hostGoFailed(trip, 'join');
3258
3502
  this.trip = null;
3259
3503
  this.toast = { text: trip.target.stuck ?? 'That door is stuck', until: now + TOAST_MS };
3260
3504
  const per = scene.persistent;
@@ -3332,14 +3576,110 @@ class HubSystem {
3332
3576
  if (this.pendingEnd !== null && !this.trip && joinState === 'joined') {
3333
3577
  this.settleEnd(scene);
3334
3578
  }
3579
+ // v1.169: the player's own door end whose way back ran while the
3580
+ // connection was away is the end of an offline walk-in.
3581
+ if (this.pendingEnd !== null && this.endDoor !== null && Rehello.connectionAway(mp)) {
3582
+ this.endAway = true;
3583
+ }
3335
3584
  if (this.pendingEnd !== null && now >= this.pendingEnd && !this.trip && joinState !== 'joining') {
3585
+ if (this.endDoor !== null && this.endAway) {
3586
+ // Not tried again: the player stays where they are.
3587
+ this.cancelEnd(scene, this.endDoor, this.endNumber);
3588
+ return;
3589
+ }
3336
3590
  // Armed until the player is out of the ended session (settleEnd): a
3337
3591
  // way back that fails is tried again a pause later.
3338
3592
  this.pendingEnd = now + END_PAUSE_MS;
3339
3593
  this.back(scene, { covered: this.endCovered === true });
3594
+ this.endTripN = this.trip?.n ?? null;
3340
3595
  }
3341
3596
  }
3342
3597
 
3598
+ // v1.169: whether a `hub-end` is the player's own door end in a place
3599
+ // without a result, met while this client is away (the resume gate armed or
3600
+ // the transport down when it arrived or now; never the gate's return tail). Its repeat for an end
3601
+ // already cancelled is the same end.
3602
+ offlineEnd(scene, msg) {
3603
+ const door = Rehello.ownDoor(msg, Hub.hub.place);
3604
+ if (door === null) {
3605
+ return false;
3606
+ }
3607
+ if (Number.isSafeInteger(msg.end) && this.stayDue?.end === msg.end && this.stayDue.door === door &&
3608
+ this.stayDue.session === sessionKey(scene)) {
3609
+ return true;
3610
+ }
3611
+ return this.pendingEnd === null && !this.trip && (Rehello.arrivedAway(msg) || Rehello.connectionAway(scene.multiplayer));
3612
+ }
3613
+
3614
+ // v1.169: whether a pad's `hub-go` reached this client while it was away,
3615
+ // in a place without a result: the player stays, and says the door is shut.
3616
+ offlineDoor(scene, msg) {
3617
+ return !msg.classic && !msg.owner && typeof msg.door === 'string' && !Hub.hub.place?.result &&
3618
+ !this.trip && this.pendingEnd === null && (Rehello.arrivedAway(msg) || Rehello.connectionAway(scene.multiplayer));
3619
+ }
3620
+
3621
+ // v1.169: the player's own door end, taken while offline, is cancelled: no
3622
+ // way back is tried again, the cover lifts on the place, and once the
3623
+ // session has the player again the place hears `hub-stay` with that end's
3624
+ // number (`sendStay`), until it answers `hub-stayed`. An acquisition a way
3625
+ // back made was given back where it failed.
3626
+ cancelEnd(scene, door, end) {
3627
+ console.warn(`[hub-door] the end through ${door} was taken while offline: staying`);
3628
+ this.pendingEnd = null;
3629
+ this.endSession = null;
3630
+ this.endLeaving = null;
3631
+ this.endCovered = false;
3632
+ this.endDoor = null;
3633
+ this.endNumber = null;
3634
+ this.endAway = false;
3635
+ this.endTripN = null;
3636
+ const n = Number.isSafeInteger(end) ? end : null;
3637
+ this.stayDue = { door, end: n, msg: { k: 'hub-stay', end: n }, session: sessionKey(scene) };
3638
+ }
3639
+
3640
+ // The word a cancelled end or door owes the place, said when this client
3641
+ // is placed in that same session again and out of any trip, and again right
3642
+ // after each resume hello (`resendStay`): placed() can turn true while the
3643
+ // socket is still down (the resume gate gives up on a visible page after
3644
+ // RESUME_WAIT_MS), and a word said into it is lost. A stay is owed until
3645
+ // the place answers `hub-stayed` with its end (placement proves nothing);
3646
+ // a pad's `hub-shut`, unnumbered, until a resume hello and a placement have
3647
+ // followed a send. A session change, a new player id, a later end or a trip
3648
+ // ends either. The place ignores a repeat.
3649
+ sendStay(scene, mp) {
3650
+ const due = this.stayDue;
3651
+ if (!due) {
3652
+ return;
3653
+ }
3654
+ if (sessionKey(scene) !== due.session) {
3655
+ this.stayDue = null;
3656
+ return;
3657
+ }
3658
+ if (this.trip || this.pendingEnd !== null || !mp?.net || mp.placed?.() !== true) {
3659
+ return;
3660
+ }
3661
+ if (due.helloAfter && due.msg.k !== 'hub-stay') {
3662
+ this.stayDue = null;
3663
+ return;
3664
+ }
3665
+ if (!due.sent) {
3666
+ due.sent = true;
3667
+ mp.net.send(due.msg);
3668
+ }
3669
+ }
3670
+
3671
+ // Right after a resume hello on `net`: the owed word goes again, behind the
3672
+ // hello on the connection the session just took back.
3673
+ resendStay(scene, net) {
3674
+ const due = this.stayDue;
3675
+ if (!due || sessionKey(scene) !== due.session || this.trip || this.pendingEnd !== null) {
3676
+ return;
3677
+ }
3678
+ due.sent = true;
3679
+ due.helloAfter = true;
3680
+ net.send(due.msg);
3681
+ }
3682
+
3343
3683
  // A game's end means the player's visit to that session is over. It stays
3344
3684
  // armed until the player, out of any trip, has joined another session (a
3345
3685
  // Back taken in the end pause included, however late the join resolves),
@@ -3356,11 +3696,24 @@ class HubSystem {
3356
3696
  // The camera starts behind the player, the way the place faced them
3357
3697
  // (contract §5: arrival facing is data). The Player behavior's facing is
3358
3698
  // PI - camAngle.
3699
+ // A rejoin under a new player id on the same connection (`newIdentity`: the
3700
+ // page was away past the place's reconnect window) is not an arrival the
3701
+ // player made: they are put back where they stood, and the camera stays
3702
+ // turned the way they had it. A trip's arrival always faces.
3359
3703
  faceArrival(scene) {
3360
3704
  if (Hub.hub.arrivedFacing !== null) {
3705
+ const rejoin = !this.trip && this.keepYawNet != null && this.keepYawNet === scene.multiplayer?.net &&
3706
+ Number.isFinite(scene.persistent?.camAngle);
3707
+ this.keepYawNet = null;
3361
3708
  if (Hub.deck.soundscape?.ui === true && !this.trip && !Hub.hub.faced) {
3362
3709
  this.soundscape?.uiArrival(performance.now());
3363
3710
  }
3711
+ if (rejoin) {
3712
+ // An earlier arrival's wait for its shot must not turn it later.
3713
+ cancelArrivalShot(scene);
3714
+ Hub.hub.faced = true;
3715
+ return;
3716
+ }
3364
3717
  faceArrivalCamera(scene, Hub.hub.arrivedFacing);
3365
3718
  // Under the engine's orbit camera key the character's facing is not
3366
3719
  // PI - camAngle: it is asked for.
@@ -3493,6 +3846,15 @@ class HubSystem {
3493
3846
  this.playAsk = { from: playerId, name, door, until: now + PLAY_ASK_MS, ...(Hub.deck.playCards ? { stranger } : {}) };
3494
3847
  }
3495
3848
 
3849
+ // v1.204: true, with the catching-up line, when a press must wait on the
3850
+ // server's progress read; false otherwise.
3851
+ refuseCatching() {
3852
+ if (Hub.hub.catching == null) {return false;}
3853
+ const now = performance.now();
3854
+ this.toast = { text: catchingLine(Hub.hub.catching, now), until: now + TOAST_MS };
3855
+ return true;
3856
+ }
3857
+
3496
3858
  drawChrome(scene, local, now) {
3497
3859
  const chrome = this.chrome;
3498
3860
  const place = Hub.hub.place;
@@ -3699,6 +4061,7 @@ class HubSystem {
3699
4061
  cam.updateMatrixWorld();
3700
4062
  }
3701
4063
  let worldLabelCount = 0;
4064
+ let qualityTagItems = null;
3702
4065
  // This player's goals: scene actors a `goal` label points at.
3703
4066
  const goals = [];
3704
4067
  if (cam && idle) {
@@ -3709,7 +4072,7 @@ class HubSystem {
3709
4072
  if (id === talkingWith && label.style === 'speech') {
3710
4073
  continue;
3711
4074
  }
3712
- const at = goalAt(label, scene.getActor(id)?.components.Transform);
4075
+ const at = goalAt(label, scene.getActor(id)?.components.Transform, label.at === 'self' ? local?.components.Transform : null);
3713
4076
  if (at && label.style === 'goal') {
3714
4077
  // Where the place is sending this player (v1.13): a pointer, not a label.
3715
4078
  goals.push({ id, at, label });
@@ -3735,7 +4098,8 @@ class HubSystem {
3735
4098
  this.attention,
3736
4099
  placed
3737
4100
  .filter(({ always }) => !always)
3738
- .map(({ id, at, label }) => ({ id, d: id === activePad ? 0 : Math.hypot(at.x - lt.x, at.z - lt.z), speech: label.style === 'speech' })),
4101
+ .map(({ id, at, label }) => ({ id, d: id === activePad ? 0 : Math.hypot(at.x - lt.x, at.z - lt.z), speech: label.style === 'speech',
4102
+ behind: id !== activePad && label.style !== 'speech' && behind(lt, local?.runtime?.facing, at.x, at.z) })),
3739
4103
  now,
3740
4104
  )
3741
4105
  : null;
@@ -3769,6 +4133,8 @@ class HubSystem {
3769
4133
  if (Hub.deck.quality) {
3770
4134
  const quality = lowQuality(scene);
3771
4135
  if (quality && lt) {
4136
+ // v1.168: cull now so this frame's marks and roles follow it.
4137
+ cullBeforeLabels(scene, qualityFor(scene), now);
3772
4138
  const party = new Set((Hub.hub.party.members ?? []).map((id) => scene.multiplayer?.avatars?.actors?.get(id)));
3773
4139
  // Party world labels bypass numerical caps, including the ordinary
3774
4140
  // near-label slots. Door labels still go through their 12/14 m rule.
@@ -3777,8 +4143,10 @@ class HubSystem {
3777
4143
  const screen = project(cam, at.x, at.y + 1.6, at.z, view);
3778
4144
  if (screen) {labels.push({ id, x: screen.x, y: screen.y, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity: 1 });}
3779
4145
  }
3780
- const capped = capWorldLabels(labels, placed, lt, quality.labels, party);
3781
- labels.splice(0, labels.length, ...capped);
4146
+ // v1.168: marks and role labels count under the same cap; a culled
4147
+ // bystander's are dropped. Drawn later, after the world labels.
4148
+ const tags = qualityTags(scene, local, this.markItems(scene, local, cam, view), roleItems(scene, local, cam, view, Hub.hub.roles, project));
4149
+ qualityTagItems = splitTags(capWorldLabels(labels, placed, lt, quality.labels, party, tags), labels, tags);
3782
4150
  }
3783
4151
  }
3784
4152
  worldLabelCount = labels.length;
@@ -3800,14 +4168,20 @@ class HubSystem {
3800
4168
  }
3801
4169
  chrome.setPointers?.(pointers.map((point) => offsetWorldPoint(point, view)));
3802
4170
  if (cam && idle) {
3803
- labels.push(...this.markItems(scene, local, cam, view));
3804
- labels.push(...roleItems(scene, local, cam, view, Hub.hub.roles, project));
4171
+ if (qualityTagItems) {labels.push(...qualityTagItems);} else {
4172
+ labels.push(...this.markItems(scene, local, cam, view));
4173
+ labels.push(...roleItems(scene, local, cam, view, Hub.hub.roles, project));
4174
+ }
3805
4175
  labels.push(...this.idle.labels(scene, local, cam, view, project));
3806
4176
  labels.push(...this.say.labels(scene, local, cam, view, project, scene.multiplayer?.net?.selfId?.() ?? null));
3807
4177
  }
3808
4178
  if (Hub.hub.place?.companion === true && cam && idle) {
3809
4179
  labels.push(...(this.companion?.labels(cam, view, project, now) ?? []));
3810
4180
  }
4181
+ const winRibbons = Celebrate.frame(scene, local, { now, low: this.lowTier === true, live: Boolean(cam && idle && !inGame), doors: Hub.hub.doors, cam, view, project });
4182
+ if (winRibbons.length || this.winRibbonsDrawn) {
4183
+ chrome.setWinRibbons?.(winRibbons); this.winRibbonsDrawn = winRibbons.length > 0;
4184
+ }
3811
4185
  if (!padOccupancy && !crowdNames) {chrome.setLabels(labels);}
3812
4186
  if (place?.companionChat) {
3813
4187
  const canTalk = cam && idle && this.pendingEnd === null && !this.talk.talking() && this.decor?.opened() !== true && !this.carded;
@@ -3898,17 +4272,19 @@ class HubSystem {
3898
4272
  drawPanelControls(scene, now, place, idle, inGame, free, town, frameYours = true) {
3899
4273
  const chrome = this.chrome;
3900
4274
  const inviteNet = scene.multiplayer?.net;
3901
- // A guest is an over-13 player like any other: the host's canInvite
3902
- // answer alone decides the rail.
4275
+ // The optional Character row also needs the viewer's trusted invite gate.
3903
4276
  const inviteRail = scene.data?.engine?.hubInviteRail === true && !inGame && place?.invite === true &&
3904
- this.invites?.canInvite(inviteNet, castleSdk.User) === true;
4277
+ this.invites?.canInvite(inviteNet, castleSdk.User) === true && this.invites?.inviteAvailable(scene, inviteNet, () => this.scene === scene) === true;
4278
+ const invitePlayer = inviteRail ? inviteNet?.selfId?.() : null;
4279
+ const inviteUser = inviteRail ? inviteNet?.userId?.(invitePlayer) : null, inviteData = scene.data;
3905
4280
  const pickerFree = idle && place !== null && !this.talk.talking() && !this.carded;
3906
4281
  chrome.showPicker(pickerFree && !inGame, Avatar.current(scene), { available: Avatar.colorsAvailable(), style: Avatar.style(), color: Avatar.currentColor(scene), files: scene.files, model: Avatar.colorsAvailable() && Avatar.style() === 'toon' ? Avatar.model(scene.files, Avatar.current(scene), 'toon') : null }, ...(inviteRail ? [{
3907
4282
  onPick: () => {
3908
4283
  // A stale menu cannot mint after a scene/connection change or a trip.
3909
- if (this.scene !== scene || scene.multiplayer?.net !== inviteNet || this.trip || this.pendingEnd !== null ||
4284
+ if (this.scene !== scene || scene.data !== inviteData || scene.multiplayer?.net !== inviteNet ||
4285
+ inviteNet?.selfId?.() !== invitePlayer || inviteNet?.userId?.(invitePlayer) !== inviteUser || this.trip || this.pendingEnd !== null ||
3910
4286
  scene.data?.engine?.hubInviteRail !== true || Hub.hub.place !== place || Boolean(place.result) || this.talk.talking() || this.carded ||
3911
- this.invites?.canInvite(inviteNet, castleSdk.User) !== true) {return;}
4287
+ this.invites?.canInvite(inviteNet, castleSdk.User) !== true || this.invites?.inviteAvailable(scene, inviteNet, () => this.scene === scene) !== true) {return;}
3912
4288
  this.invites?.open(true);
3913
4289
  },
3914
4290
  }] : []));
@@ -4062,6 +4438,7 @@ class HubSystem {
4062
4438
  const self = mp?.net?.selfId?.() ?? null;
4063
4439
  const out = [];
4064
4440
  for (const [playerId, mark] of Object.entries(Hub.hub.marks)) {
4441
+ if (disguiseTags(self, playerId)) {continue;}
4065
4442
  const actorId = playerId === self ? local?.id : mp?.avatars?.actors?.get(playerId);
4066
4443
  const at = actorId ? scene.getActor(actorId)?.components.Transform : null;
4067
4444
  const screen = at ? project(cam, at.x, at.y + 1.95, at.z, view) : null;
@@ -4087,7 +4464,7 @@ class HubSystem {
4087
4464
  this.fpsTelemetry = makeFpsTelemetry({ send: (data) => net.send(data) });
4088
4465
  }
4089
4466
  const tier = this.fpsTier ?? 0;
4090
- this.fpsTelemetry.frame(now, { scene: this.scenePath, tier, avatars: Math.min(255, (mp.avatars?.actors?.size ?? 0) + 1) });
4467
+ this.fpsTelemetry.frame(now, { scene: this.scenePath, tier, avatars: Math.min(255, (mp.avatars?.actors?.size ?? 0) + 1), quality: this.fpsQuality });
4091
4468
  }
4092
4469
  else {this.fpsTelemetry?.pause();}
4093
4470
  if (!this.stats) {
@@ -4117,6 +4494,7 @@ class HubSystem {
4117
4494
 
4118
4495
  dispose() {
4119
4496
  this.clearPadReadability();
4497
+ Celebrate.clear();
4120
4498
  this.hudRate?.dispose();
4121
4499
  this.hudRate = null;
4122
4500
  this.fpsTelemetry?.dispose();
@@ -4164,9 +4542,11 @@ class HubSystem {
4164
4542
  // hat builds: given back with the runtime.
4165
4543
  this.companion?.dispose();
4166
4544
  this.vehicle?.clear();
4545
+ this.disguise?.clear();
4167
4546
  this.wear?.clear();
4168
4547
  this.earned?.clear();
4169
4548
  this.roles?.clear();
4549
+ this.holdShows?.clear();
4170
4550
  }
4171
4551
  }
4172
4552