castle-web-cli 0.4.239 → 0.4.241

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 (396) 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 +163 -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 +6 -3
  16. package/dist/init.js +24 -2
  17. package/dist/multiplayerDoc.d.ts +1 -1
  18. package/dist/multiplayerDoc.js +2 -0
  19. package/dist/platformDoc.js +3 -2
  20. package/dist/playPagePolicy.js +5 -1
  21. package/dist/resetLeaderboards.d.ts +8 -1
  22. package/dist/resetLeaderboards.js +43 -8
  23. package/dist/roomLogs.d.ts +1 -0
  24. package/dist/roomLogs.js +30 -6
  25. package/dist/save-deck.d.ts +32 -2
  26. package/dist/save-deck.js +240 -39
  27. package/kits/base/CLAUDE.md +1 -1
  28. package/kits/base/castle.json +1 -1
  29. package/kits/base/sdk/README.md +174 -6
  30. package/kits/base/sdk/analytics.d.ts +8 -0
  31. package/kits/base/sdk/analytics.js +92 -0
  32. package/kits/base/sdk/castle.d.ts +5 -1
  33. package/kits/base/sdk/castle.js +2 -0
  34. package/kits/base/sdk/commands.d.ts +48 -0
  35. package/kits/base/sdk/commands.js +1 -0
  36. package/kits/base/sdk/debugConsole.d.ts +17 -0
  37. package/kits/base/sdk/debugConsole.js +154 -0
  38. package/kits/base/sdk/experiments.js +24 -1
  39. package/kits/base/sdk/hostRetry.d.ts +7 -0
  40. package/kits/base/sdk/hostRetry.js +57 -0
  41. package/kits/base/sdk/hub.d.ts +20 -2
  42. package/kits/base/sdk/hub.js +99 -13
  43. package/kits/base/sdk/multiplayer.d.ts +2 -0
  44. package/kits/base/sdk/multiplayer.js +168 -26
  45. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  46. package/kits/base/sdk/reconnectBudget.js +41 -1
  47. package/kits/base/sdk/runtime.js +36 -19
  48. package/kits/base/sdk/server/hub.d.ts +19 -0
  49. package/kits/base/sdk/server/hub.js +12 -0
  50. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  51. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  52. package/kits/base/sdk/server/wrapper.js +26 -1
  53. package/kits/base/sdk/transport.d.ts +2 -1
  54. package/kits/base/sdk/transport.js +35 -0
  55. package/kits/hub-game/CLAUDE.md +66 -19
  56. package/kits/hub-game/code/client/act.js +9 -6
  57. package/kits/hub-game/code/client/actCore.js +26 -6
  58. package/kits/hub-game/code/client/actGateLog.js +36 -0
  59. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  60. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  61. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  62. package/kits/hub-game/code/client/askSurface.js +85 -0
  63. package/kits/hub-game/code/client/askTree.js +51 -0
  64. package/kits/hub-game/code/client/attention.js +31 -6
  65. package/kits/hub-game/code/client/ballot.js +42 -5
  66. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  67. package/kits/hub-game/code/client/ballotTree.js +180 -0
  68. package/kits/hub-game/code/client/catchingUp.js +19 -0
  69. package/kits/hub-game/code/client/celebrate.js +66 -0
  70. package/kits/hub-game/code/client/chrome.js +481 -57
  71. package/kits/hub-game/code/client/companion.js +93 -23
  72. package/kits/hub-game/code/client/companionDress.js +1 -1
  73. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  74. package/kits/hub-game/code/client/cornerTree.js +83 -0
  75. package/kits/hub-game/code/client/decor.js +20 -11
  76. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  77. package/kits/hub-game/code/client/disguise.js +23 -0
  78. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  79. package/kits/hub-game/code/client/dockSurface.js +206 -0
  80. package/kits/hub-game/code/client/dockTree.js +232 -0
  81. package/kits/hub-game/code/client/earned.js +29 -0
  82. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  83. package/kits/hub-game/code/client/emoteTree.js +264 -0
  84. package/kits/hub-game/code/client/farAvatars.js +4 -3
  85. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  86. package/kits/hub-game/code/client/grab.js +121 -50
  87. package/kits/hub-game/code/client/holdShow.js +19 -0
  88. package/kits/hub-game/code/client/hookLayer.js +96 -12
  89. package/kits/hub-game/code/client/hubControls.js +7 -1
  90. package/kits/hub-game/code/client/hudSurface.js +11 -3
  91. package/kits/hub-game/code/client/hudTree.js +7 -4
  92. package/kits/hub-game/code/client/idle.js +21 -3
  93. package/kits/hub-game/code/client/invites.js +24 -3
  94. package/kits/hub-game/code/client/keys.js +15 -0
  95. package/kits/hub-game/code/client/labelsNear.js +8 -1
  96. package/kits/hub-game/code/client/layoutCache.js +57 -8
  97. package/kits/hub-game/code/client/loadingCover.js +53 -4
  98. package/kits/hub-game/code/client/menuIcons.js +15 -0
  99. package/kits/hub-game/code/client/menuSurface.js +102 -0
  100. package/kits/hub-game/code/client/menuTree.js +135 -0
  101. package/kits/hub-game/code/client/modelLook.js +41 -0
  102. package/kits/hub-game/code/client/padCues.js +11 -7
  103. package/kits/hub-game/code/client/padReadability.js +3 -3
  104. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  105. package/kits/hub-game/code/client/pickerTree.js +163 -0
  106. package/kits/hub-game/code/client/pushVisit.js +4 -2
  107. package/kits/hub-game/code/client/quality.js +188 -29
  108. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  109. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  110. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  111. package/kits/hub-game/code/client/rehello.js +75 -0
  112. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  113. package/kits/hub-game/code/client/replay.js +118 -0
  114. package/kits/hub-game/code/client/role.js +3 -0
  115. package/kits/hub-game/code/client/safeLayout.js +441 -56
  116. package/kits/hub-game/code/client/safeStyle.js +13 -10
  117. package/kits/hub-game/code/client/say.js +2 -0
  118. package/kits/hub-game/code/client/soundSurface.js +77 -0
  119. package/kits/hub-game/code/client/soundTree.js +74 -0
  120. package/kits/hub-game/code/client/soundscape.js +12 -9
  121. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  122. package/kits/hub-game/code/client/state.js +67 -1
  123. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  124. package/kits/hub-game/code/client/stuckTree.js +67 -0
  125. package/kits/hub-game/code/client/talk.js +42 -12
  126. package/kits/hub-game/code/client/talkTree.js +4 -2
  127. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  128. package/kits/hub-game/code/client/textAskTree.js +67 -0
  129. package/kits/hub-game/code/client/tiers.js +252 -27
  130. package/kits/hub-game/code/client/together.js +4 -1
  131. package/kits/hub-game/code/client/uiDom.js +86 -8
  132. package/kits/hub-game/code/client/uiTree.js +33 -4
  133. package/kits/hub-game/code/client/vehicle.js +72 -51
  134. package/kits/hub-game/code/client/weakestTier.js +75 -31
  135. package/kits/hub-game/code/client/wear.js +159 -5
  136. package/kits/hub-game/code/client/worldLabels.js +205 -25
  137. package/kits/hub-game/code/companionSpec.js +4 -2
  138. package/kits/hub-game/code/server/act.js +3 -0
  139. package/kits/hub-game/code/server/actGate.js +83 -0
  140. package/kits/hub-game/code/server/actions.js +71 -15
  141. package/kits/hub-game/code/server/actors.js +20 -5
  142. package/kits/hub-game/code/server/analytics.js +35 -3
  143. package/kits/hub-game/code/server/ask.js +39 -3
  144. package/kits/hub-game/code/server/ballot.js +167 -4
  145. package/kits/hub-game/code/server/celebrate.js +64 -0
  146. package/kits/hub-game/code/server/companion.js +17 -2
  147. package/kits/hub-game/code/server/decor.js +11 -2
  148. package/kits/hub-game/code/server/disguise.js +63 -0
  149. package/kits/hub-game/code/server/earned.js +6 -2
  150. package/kits/hub-game/code/server/friendBests.js +13 -4
  151. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  152. package/kits/hub-game/code/server/grab.js +12 -2
  153. package/kits/hub-game/code/server/heldOffers.js +142 -0
  154. package/kits/hub-game/code/server/holdShow.js +98 -0
  155. package/kits/hub-game/code/server/hub.js +991 -72
  156. package/kits/hub-game/code/server/idle.js +110 -9
  157. package/kits/hub-game/code/server/index.js +9 -0
  158. package/kits/hub-game/code/server/labels.js +13 -3
  159. package/kits/hub-game/code/server/manifest.js +94 -6
  160. package/kits/hub-game/code/server/menu.js +26 -3
  161. package/kits/hub-game/code/server/npcs.js +55 -9
  162. package/kits/hub-game/code/server/observe.js +67 -6
  163. package/kits/hub-game/code/server/players.js +14 -2
  164. package/kits/hub-game/code/server/replay.js +135 -0
  165. package/kits/hub-game/code/server/standing.js +7 -3
  166. package/kits/hub-game/code/server/storageLimit.js +4 -1
  167. package/kits/hub-game/code/server/townDay.js +74 -0
  168. package/kits/hub-game/code/server/vehicle.js +3 -0
  169. package/kits/hub-game/code/server/vis.js +26 -4
  170. package/kits/hub-game/code/server/wallet.js +677 -0
  171. package/kits/hub-game/code/server/wear.js +13 -3
  172. package/kits/hub-game/code/server/writerLease.js +191 -0
  173. package/kits/hub-game/code/shared/act.js +1 -1
  174. package/kits/hub-game/code/shared/expression.js +6 -0
  175. package/kits/hub-game/code/shared/replay.js +37 -0
  176. package/kits/hub-game/code/systems/hub.js +429 -55
  177. package/kits/hub-game/docs/analytics.md +16 -2
  178. package/kits/hub-game/docs/contract.md +956 -101
  179. package/kits/hub-game/docs/home-pieces.md +5 -6
  180. package/kits/hub-game/docs/observed-progress.md +49 -1
  181. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  182. package/kits/hub-game/index.html +1 -0
  183. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  184. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  185. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  186. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  187. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  188. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  189. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  190. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  200. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  201. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  202. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  203. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  204. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  205. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  206. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  207. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  208. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  209. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  210. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  211. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  212. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  213. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  214. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  215. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  216. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  217. package/kits/hub-game/package-lock.json +3 -3
  218. package/kits/hub-game/package.json +4 -3
  219. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  220. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  221. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  222. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  223. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  224. package/kits/hub-game/scripts/pack.mjs +89 -23
  225. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  226. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  227. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  228. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  229. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  230. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  231. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  232. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  233. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  234. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  235. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  236. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  237. package/kits/hub-game/scripts/test-analytics.mjs +79 -0
  238. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  239. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  240. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  241. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  242. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  243. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  244. package/kits/hub-game/scripts/test-ballot.mjs +421 -4
  245. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  246. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  247. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  248. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  249. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  250. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  251. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  252. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  253. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  254. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  255. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  256. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  257. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  258. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  259. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  260. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  261. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  262. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  263. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  264. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  265. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  266. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  267. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  268. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  269. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  270. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  271. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  272. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  273. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  274. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  275. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  276. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  277. package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
  278. package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
  279. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  280. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  281. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  282. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  283. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  284. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  285. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  286. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  287. package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
  288. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  289. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  290. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  291. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  292. package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
  293. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  294. package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
  295. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  296. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  297. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  298. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  299. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  300. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  301. package/kits/hub-game/scripts/test-rehello.mjs +242 -3
  302. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  303. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  304. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  305. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  306. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  307. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  308. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  309. package/kits/hub-game/scripts/test-role-client.mjs +2 -1
  310. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  311. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  312. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  313. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  314. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  315. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  316. package/kits/hub-game/scripts/test-standing.mjs +135 -2
  317. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  318. package/kits/hub-game/scripts/test-stuck.mjs +36 -1
  319. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  320. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  321. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  322. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  323. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  324. package/kits/hub-game/scripts/test-together.mjs +11 -0
  325. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  326. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  327. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  328. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  329. package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
  330. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  331. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  332. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  333. package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
  334. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  335. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  336. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  337. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  338. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  339. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
  340. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
  341. package/kits/multiplayer-3d/castle.json +5 -5
  342. package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
  343. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  344. package/kits/multiplayer-3d/code/server/world.js +19 -4
  345. package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
  346. package/kits/multiplayer-3d/package-lock.json +1 -1
  347. package/kits/multiplayer-3d/package.json +2 -1
  348. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  349. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  350. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  351. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
  352. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  353. package/kits/physics-2d/castle.json +2 -2
  354. package/kits/physics-2d/engine/scene.js +10 -2
  355. package/kits/physics-3d/CLAUDE.md +14 -0
  356. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  357. package/kits/physics-3d/castle.json +3 -3
  358. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  359. package/kits/physics-3d/docs/engine-player.md +76 -0
  360. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  361. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  362. package/kits/physics-3d/engine3d/gait.js +16 -8
  363. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  364. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  365. package/kits/physics-3d/engine3d/look.js +110 -17
  366. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  367. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  368. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  369. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  370. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  371. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  372. package/kits/physics-3d/engine3d/optimize.js +20 -9
  373. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  374. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  375. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  376. package/kits/physics-3d/engine3d/world3d.js +211 -17
  377. package/kits/physics-3d/package-lock.json +1 -1
  378. package/kits/physics-3d/package.json +2 -1
  379. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  380. package/kits/physics-3d/scripts/render.mjs +56 -8
  381. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  382. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  383. package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
  384. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  385. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  386. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  387. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  388. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  389. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  390. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  391. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  392. package/kits/physics-3d/systems/physics3d.js +59 -2
  393. package/kits/real-time/castle.json +2 -2
  394. package/kits/real-time/code/client/connection.js +3 -0
  395. package/package.json +2 -2
  396. 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';
@@ -255,6 +261,14 @@ class HubSystem {
255
261
  this.pendingEnd = null;
256
262
  this.endSession = null;
257
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;
258
272
  this.helloNet = null;
259
273
  this.helloAvatar = null;
260
274
  this.signIn = makeSignIn({ api: castleSdk.Hub, signedIn: () => { this.helloNet = null; } });
@@ -270,8 +284,10 @@ class HubSystem {
270
284
  this.spin = null;
271
285
  this.wear = makeWear();
272
286
  this.vehicle = makeVehicle();
287
+ this.disguise = makeDisguise();
273
288
  this.earned = makeEarned();
274
289
  this.roles = makeRole();
290
+ this.holdShows = makeHoldShow();
275
291
  this.toast = { text: '', until: 0 };
276
292
  this.leavingToast = null;
277
293
  this.stats = statsWanted();
@@ -532,7 +548,7 @@ class HubSystem {
532
548
  this.endLayoutFrame();
533
549
  });
534
550
  }
535
- loadingCover?.sync(scene);
551
+ loadingCover?.sync(scene, { arriving: this.coverArriving(scene.multiplayer) });
536
552
  const mp = scene.multiplayer;
537
553
  if (!mp) {
538
554
  this.endLayoutFrame();
@@ -582,8 +598,8 @@ class HubSystem {
582
598
  }
583
599
  this.chrome.safeSurface?.('invite-dialog', this.invites?.surface?.());
584
600
  Avatar.load(scene);
585
- this.talk ??= makeTalk(this.chrome);
586
- this.grab ??= makeGrab(this.chrome);
601
+ this.talk ??= makeTalk(this.chrome, () => this.refuseCatching());
602
+ this.grab ??= makeGrab(this.chrome, () => this.refuseCatching());
587
603
  this.idle ??= makeIdle(this.chrome);
588
604
  this.sound ??= makeSound();
589
605
  if (Hub.deck.soundscape && !this.soundscape) {
@@ -626,7 +642,7 @@ class HubSystem {
626
642
  this.watchSession(scene, mp);
627
643
  this.sayHello(scene, mp);
628
644
  if (Hub.hub.place?.push?.version === 1 && Hub.hub.arrivedFacing !== null && mp.net) {
629
- 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);
630
646
  }
631
647
  if (Hub.hub.place?.visibility === true || this.visibility) {
632
648
  this.visibility ??= makeVisibility();
@@ -671,11 +687,12 @@ class HubSystem {
671
687
  this.decor = null;
672
688
  }
673
689
  if (Hub.hub.place?.decor && !this.decor) {
674
- this.decor = makeDecor(this.chrome);
690
+ this.decor = makeDecor(this.chrome, { refuse: () => this.refuseCatching() });
675
691
  }
676
692
  this.decor?.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && this.chrome.pickerSheetOpen?.() !== true);
677
693
  const decorating = this.decor?.opened() === true;
678
694
  this.stepEnd(scene, mp, now);
695
+ this.sendStay(scene, mp);
679
696
  // v1.68, rule B (`client/ballot.js`): the choice card runs only while
680
697
  // its one gate holds a card (`ballotHeld`), which a place without
681
698
  // `ballot` never does; when it lets go (another connection), the sheet
@@ -689,6 +706,7 @@ class HubSystem {
689
706
  this.ballot ??= makeBallot({
690
707
  ...((Hub.deck.safeInsets === true || Hub.deck.act === true) ? { safeInsets: true } : {}),
691
708
  send: (ids) => this.scene?.multiplayer?.net?.send({ k: 'hub-ballot', ...ids }),
709
+ refuse: () => this.refuseCatching(),
692
710
  ...(Hub.deck.soundscape?.ui === true ? { onChip: () => this.soundscape?.cue('tap', performance.now()) } : {}),
693
711
  });
694
712
  this.carded = card !== null && !this.trip;
@@ -716,12 +734,23 @@ class HubSystem {
716
734
  this.chrome.cancelActionOverflow();
717
735
  }
718
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
+ }
719
744
  if (Hub.hub.place?.ask === true) {
720
745
  this.askDrawn = true;
721
746
  Hub.hub.askClose ??= () => this.clearTextAsk();
722
747
  const canAsk = !this.trip && this.pendingEnd === null && !decorating && card === null && !this.talk.talking();
723
748
  this.chrome.setTextAsk(canAsk ? Hub.hub.ask : null,
724
- (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
+ },
725
754
  (open) => {
726
755
  if (open) {
727
756
  this.askInput = holdAskInput(scene);
@@ -738,7 +767,7 @@ class HubSystem {
738
767
  Hub.hub.menuClose ??= () => this.clearMenu();
739
768
  const canMenu = !this.trip && this.pendingEnd === null && !decorating && card === null && !this.talk.talking() && !this.askInput;
740
769
  this.chrome.setMenu(canMenu ? Hub.hub.menu : null,
741
- (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 });}},
742
771
  (open) => {
743
772
  if (open) {
744
773
  this.menuInput = holdAskInput(scene);
@@ -788,8 +817,16 @@ class HubSystem {
788
817
  this.chrome.hornPrompt?.(() => mp.net?.send({ k: 'hub-horn' }));
789
818
  }
790
819
  if (Hub.deck.act === true) {
791
- this.act ??= makeAct(this.chrome, this.grab, this.talk);
792
- 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
+ }
793
830
  }
794
831
  this.noteArrival(mp, now);
795
832
  if (this.trip) {
@@ -803,14 +840,16 @@ class HubSystem {
803
840
  const cam = scene.three?.camera;
804
841
  const view = { w: window.innerWidth, h: window.innerHeight };
805
842
  const framing = cam ? {
806
- 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 },
807
845
  panel: this.chrome.talkRect?.(), view,
808
846
  project: (at) => project(cam, at.x, at.y, at.z, view),
809
847
  } : null;
810
848
  const chat = Hub.hub.place?.companionChat && this.talk.talkingToCompanion?.() ? framing ?? {} : null;
811
849
  const activity = { ...framing, chatting: this.talk.talking() };
812
850
  const busy = Boolean(this.talk.talkingWith()?.startsWith('companion:') || now < (this.companionTappedUntil ?? -Infinity));
813
- 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);
814
853
  } else if (this.companion) {
815
854
  this.companion.dispose();
816
855
  delete this.companion;
@@ -823,12 +862,13 @@ class HubSystem {
823
862
  const inviting = () => Hub.hub.place?.invite === true && this.invites?.canInvite(mp.net, castleSdk.User) === true;
824
863
  const offered = Hub.hub.actions?.items ?? null, invites = offered?.some((item) => INVITE_ACTIONS.has(item?.id)) ? inviting() : true;
825
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.
826
866
  this.chrome.setActions(items, (id, n) => {
827
867
  if (id === 'signin' && Hub.hub.place?.anonymousEntry === true) {void this.signIn.press(hud?.text ?? 'Keep your progress');}
828
868
  else if (INVITE_ACTIONS.has(id) && !inviting()) {return;}
829
- else {mp.net?.send({ k: 'hub-action', id, n });}
869
+ else if (!this.refuseCatching()) {mp.net?.send({ k: 'hub-action', id, n });}
830
870
  }, !this.signIn.pending() && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput,
831
- Hub.hub.actions?.n, scene.data?.engine?.hubActionOverflow === true || !landscapeViewport(), (open) => {
871
+ Hub.hub.actions?.n, true, (open) => {
832
872
  if (open) {
833
873
  this.actionInput = holdAskInput(scene);
834
874
  } else if (this.actionInput) {
@@ -900,12 +940,22 @@ class HubSystem {
900
940
  onLayout: (node) => this.chrome?.safeSurface?.('cells-debug', node, 'text') });
901
941
  const pick = (mode) => {
902
942
  this.tiers.set(mode);
943
+ this.graphicsShown = this.tiers.mode;
903
944
  this.chrome?.setGraphics?.(this.tiers.mode, pick, Hub.deck.weakestTier === true);
904
945
  };
946
+ this.graphicsPick = pick;
947
+ this.graphicsShown = this.tiers.mode;
905
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);
906
954
  }
907
955
  const counts = !this.trip && this.pendingEnd === null && mp?.placed?.() === true;
908
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';
909
959
  const profile = Hub.deck.weakestTier === true
910
960
  ? (this.tiers.weakest() ? 'weakest' : this.tiers.middle?.() ? 'middle' : null)
911
961
  : null;
@@ -922,7 +972,7 @@ class HubSystem {
922
972
  ...Object.keys(Hub.hub.labelsMe ?? {}),
923
973
  ]);
924
974
  this.weakestTier.frame(scene, true, now, Hub.deck.weakestLookBake === true, pointerTargets);
925
- } else if (this.weakestTier?.active) {
975
+ } else if (this.weakestTier?.active || this.weakestTier?.capped) {
926
976
  this.weakestTier.restore();
927
977
  }
928
978
  const weakestActive = this.weakestTier?.active && this.weakestTier.profile === 'weakest';
@@ -939,12 +989,16 @@ class HubSystem {
939
989
  if (Hub.hub.place?.interest === 'cells') {
940
990
  this.interestTier = this.tiers.current();
941
991
  }
942
- 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
+ }
943
996
  if (Hub.deck.quality || Hub.deck.highOnly) {
944
997
  const quality = qualityFor(scene);
945
998
  if (quality) {
999
+ lowerLate(scene, quality);
946
1000
  restoreDecor(scene, quality, quality.build);
947
- if (Hub.deck.quality) {qualityPlayers(scene, quality, now);}
1001
+ if (Hub.deck.quality) {cullAfterTier(scene, quality, now);}
948
1002
  }
949
1003
  }
950
1004
  globalThis.__hub.tier = this.tiers.handle;
@@ -977,7 +1031,9 @@ class HubSystem {
977
1031
  // The systems that run after every other one, registered once per runtime.
978
1032
  // Cars (v1.160) after the multiplayer kit has placed every avatar: each
979
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'));}
980
1035
  applyCars(s) {
1036
+ replays.frame(s);
981
1037
  this.vehicle.draw(s, s.actorWith('Player'), Hub.hub.cars);
982
1038
  if (Object.keys(Hub.hub.cars).length) {
983
1039
  this.vehicle.camera(s, s.actorWith('Player'), Hub.hub.cars);
@@ -993,6 +1049,7 @@ class HubSystem {
993
1049
  this.applyWear(s);
994
1050
  this.applyCars(s);
995
1051
  this.fadeNames(s);
1052
+ this.applyDisguise(s);
996
1053
  },
997
1054
  });
998
1055
  // Device tiers run as a system of their own, registered only in a deck
@@ -1090,14 +1147,18 @@ class HubSystem {
1090
1147
  this.scenePath = scene.currentScenePath;
1091
1148
  this.sceneKey = sceneKeyOf(scene);
1092
1149
  this.doorBase.clear();
1093
- this.stash.clear();
1150
+ this.clearStash();
1094
1151
  this.tinted.clear();
1095
1152
  this.spawnedHere.clear();
1096
1153
  this.companion?.clear();
1097
1154
  this.vehicle.clear();
1155
+ this.disguise.clear();
1156
+ replays.clear();
1157
+ Celebrate.clear();
1098
1158
  this.wear.clear(scene);
1099
1159
  this.earned.clear();
1100
1160
  this.roles.clear();
1161
+ this.holdShows.clear();
1101
1162
  this.idle?.release();
1102
1163
  if (this.decor) {
1103
1164
  this.decor.dispose();
@@ -1138,18 +1199,23 @@ class HubSystem {
1138
1199
  this.decor.dispose();
1139
1200
  this.decor = null;
1140
1201
  }
1141
- this.stash.clear();
1202
+ this.clearStash();
1142
1203
  this.tinted.clear();
1143
1204
  this.spawnedHere.clear();
1144
1205
  this.vehicle.clear();
1206
+ this.disguise.clear();
1207
+ replays.clear();
1208
+ Celebrate.clear();
1145
1209
  if (scene) {
1146
1210
  this.wear.clear(scene);
1147
1211
  this.earned.clear();
1148
1212
  this.roles.clear();
1213
+ this.holdShows.clear();
1149
1214
  } else {
1150
1215
  this.wear.forget();
1151
1216
  this.earned.forget();
1152
1217
  this.roles.forget();
1218
+ this.holdShows.forget();
1153
1219
  }
1154
1220
  }
1155
1221
 
@@ -1183,13 +1249,23 @@ class HubSystem {
1183
1249
  return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
1184
1250
  });
1185
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
+ }
1186
1260
  // Earned items (v1.53): no work at all while nobody shows one and
1187
1261
  // nothing is drawn.
1188
1262
  if (Hub.hub.earned.size > 0 || this.earned.size > 0) {
1189
- 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) => {
1190
1266
  const index = indexOf(playerId);
1191
1267
  return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
1192
- });
1268
+ }, view);
1193
1269
  }
1194
1270
  }
1195
1271
 
@@ -1266,6 +1342,9 @@ class HubSystem {
1266
1342
  if (say !== 'none') {
1267
1343
  console.log(`[hub] the connection came back (${back}): saying a ${say} hello`);
1268
1344
  this.sendHello(scene, mp, net, avatar, say === 'resume' ? { resume: true } : { solo: true });
1345
+ if (say === 'resume') {
1346
+ this.resendStay(scene, net);
1347
+ }
1269
1348
  this.noTripsAfterHello(net);
1270
1349
  if (back === 'world') {
1271
1350
  this.talk?.resume();
@@ -1307,9 +1386,23 @@ class HubSystem {
1307
1386
  // as on any switch of session, along with what this client kept of it.
1308
1387
  newIdentity() {
1309
1388
  this.pushVisit = null;
1389
+ // Another player id is another session: nothing owed goes to it.
1390
+ this.stayDue = null;
1310
1391
  this.admitEpoch = (this.admitEpoch ?? 0) + 1;
1311
1392
  console.log('[hub] the connection has a new player id: a new session');
1312
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
+ }
1313
1406
  Hub.clear();
1314
1407
  // The server forgets invitations with an old player identity. Hub.clear
1315
1408
  // resets that occurrence, while the shared slot retains other expired
@@ -1324,6 +1417,19 @@ class HubSystem {
1324
1417
  this.startNear = null;
1325
1418
  }
1326
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
+
1327
1433
  // What this client keeps of one session, cleared when it joins another.
1328
1434
  freshSession(scene, { keepAskSlot = false } = {}) {
1329
1435
  // A player who walks in (no door, no jump to a friend) starts beside a
@@ -1368,7 +1474,15 @@ class HubSystem {
1368
1474
 
1369
1475
  // `solo`: a party of one carrying nothing and naming no friend, as `resume`
1370
1476
  // is, without saying it resumes (a game's new session, `helloAfter`).
1477
+ clearReplays() {
1478
+ replays.clear();
1479
+ Celebrate.clear();
1480
+ }
1481
+
1371
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?.();}
1372
1486
  if (resume && (this.menuDrawn || Object.hasOwn(Hub.hub, 'menu'))) {
1373
1487
  this.clearMenu();
1374
1488
  delete Hub.hub.menu;
@@ -1415,6 +1529,17 @@ class HubSystem {
1415
1529
  });
1416
1530
  }
1417
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
+
1418
1543
  // Hide what the place hid, and put back what it showed again (contract §10).
1419
1544
  // A hidden actor is dropped far below the ground, collider and all, rather
1420
1545
  // than despawned: the multiplayer kit reports a despawned scene actor to the
@@ -1424,23 +1549,64 @@ class HubSystem {
1424
1549
  // shown again by lifting it from wherever it is.
1425
1550
  // The engine is told before each write (`scene.touch`): a scene may hold
1426
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.
1427
1559
  applyVisibility(scene) {
1428
- 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
+ }
1429
1573
  const t = scene.getActor(id)?.components.Transform;
1430
- if (t && t.y > -HIDE_DROP_M / 2) {
1431
- this.stash.set(id, true);
1574
+ if (t && t.y < -HIDE_DROP_M / 2) {
1432
1575
  scene.touch?.(id);
1433
- t.y -= HIDE_DROP_M;
1576
+ t.y += HIDE_DROP_M;
1434
1577
  }
1435
1578
  }
1436
- for (const id of this.stash.keys()) {
1437
- if (!Hub.hub.hidden.has(id)) {
1438
- this.stash.delete(id);
1439
- const t = scene.getActor(id)?.components.Transform;
1440
- if (t && t.y < -HIDE_DROP_M / 2) {
1441
- scene.touch?.(id);
1442
- 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);
1443
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;
1444
1610
  }
1445
1611
  }
1446
1612
  }
@@ -1455,11 +1621,12 @@ class HubSystem {
1455
1621
  applySpawns(scene) {
1456
1622
  const want = Hub.hub.spawned;
1457
1623
  const mp = scene.multiplayer;
1458
- const quality = Hub.deck.quality ? lowQuality(scene) : null;
1459
- 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;
1460
1627
  if (allowed) {
1461
1628
  for (const id of this.spawnedHere) {
1462
- 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) {
1463
1630
  this.spawnedHere.delete(id);
1464
1631
  this.stash.delete(id); this.tinted.delete(id);
1465
1632
  mp?.avatars?.retired?.add(id);
@@ -1612,6 +1779,10 @@ class HubSystem {
1612
1779
  } else if (msg.k === 'hub-go' && msg.classic) {
1613
1780
  // A cabinet: the host plays a classic deck; this place waits (v1.7).
1614
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) };
1615
1786
  } else if (msg.k === 'hub-go' && !msg.key) {
1616
1787
  // A pad ghost fired: the host acquires the trip (Hub.go).
1617
1788
  this.goHub(scene, msg);
@@ -1619,6 +1790,14 @@ class HubSystem {
1619
1790
  this.go(scene, msg);
1620
1791
  } else if (msg.k === 'hub-result') {
1621
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);
1622
1801
  } else if (msg.k === 'hub-end' && Rehello.takesEnd(msg, this.pendingEnd, this.endSession, sessionKey(scene))) {
1623
1802
  // An end that meets a player coming back from away (a game that ran
1624
1803
  // out meanwhile, a fresh admission it ends at once) is not paused on:
@@ -1627,6 +1806,12 @@ class HubSystem {
1627
1806
  this.pendingEnd = this.endCovered ? now : now + END_PAUSE_MS;
1628
1807
  this.endSession = sessionKey(scene);
1629
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;
1630
1815
  // Only a game is over: a place without a result that sends a player
1631
1816
  // back (the House's front door, the first room's way to the Town)
1632
1817
  // says what it says in its own HUD.
@@ -1791,6 +1976,8 @@ class HubSystem {
1791
1976
  // refuses it, so a host's trip has no door retry.
1792
1977
  retryDoor: msg.host ? null : msg.door,
1793
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,
1794
1981
  pending: this.resolveHub(scene, () => hubGo(msg.door, msg.owner)),
1795
1982
  join: null,
1796
1983
  title: msg.title,
@@ -2255,12 +2442,15 @@ class HubSystem {
2255
2442
  // (`hub.stuck`): without it this is never called and nothing of it is made.
2256
2443
  // A chip is offered to a player who has walked for a few seconds and got
2257
2444
  // nowhere; nothing moves them but their own tap. Only in a town that says
2258
- // 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.
2259
2448
  offerUnstick(scene, local, town, now) {
2260
2449
  const offer = town ? Hub.hub.stuck : null;
2261
2450
  const t = local?.components.Transform;
2262
2451
  const selfId = scene.multiplayer?.net?.selfId?.();
2263
- 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) {
2264
2454
  if (this.stuck) {
2265
2455
  resetStuck(this.stuck);
2266
2456
  this.stuckShown = false;
@@ -2699,6 +2889,12 @@ class HubSystem {
2699
2889
  return;
2700
2890
  }
2701
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' });}
2702
2898
  this.back(scene);
2703
2899
  }
2704
2900
 
@@ -2813,6 +3009,8 @@ class HubSystem {
2813
3009
  if (this.trip) {
2814
3010
  return;
2815
3011
  }
3012
+ // A trip leaves the place: a stay or shut owed to it goes no more.
3013
+ this.stayDue = null;
2816
3014
  this.fpsTelemetry?.leave();
2817
3015
  clearShot();
2818
3016
  if (Hub.deck.soundscape?.ui === true && target.exitDoor) {
@@ -3096,6 +3294,22 @@ class HubSystem {
3096
3294
  trip.target.pendingFrom = now;
3097
3295
  return false;
3098
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
+ }
3099
3313
  const content = pending.content;
3100
3314
  const prefix = content?.sessionKeyPrefix ?? '';
3101
3315
  // A way back to a place this runtime already holds keeps its own content.
@@ -3126,7 +3340,10 @@ class HubSystem {
3126
3340
  this.cancelHub();
3127
3341
  }
3128
3342
  if (trip.phase === 'retrying-door') {this.uncommitted(scene, trip, now);}
3129
- 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
+ }
3130
3347
  return false;
3131
3348
  }
3132
3349
  trip.marks.resolved = now;
@@ -3147,6 +3364,25 @@ class HubSystem {
3147
3364
  return true;
3148
3365
  }
3149
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
+
3150
3386
  // The door stays shut: forget the way back this trip pushed, and lift the
3151
3387
  // cover on the place the player never left.
3152
3388
  shutDoor(scene, trip, why, now) {
@@ -3262,6 +3498,7 @@ class HubSystem {
3262
3498
  // more from where the player still is, then left to the Back control.
3263
3499
  uncommitted(scene, trip, now) {
3264
3500
  console.warn(`[hub-door] the trip to ${trip.target.deck} did not commit`);
3501
+ this.hostGoFailed(trip, 'join');
3265
3502
  this.trip = null;
3266
3503
  this.toast = { text: trip.target.stuck ?? 'That door is stuck', until: now + TOAST_MS };
3267
3504
  const per = scene.persistent;
@@ -3339,14 +3576,110 @@ class HubSystem {
3339
3576
  if (this.pendingEnd !== null && !this.trip && joinState === 'joined') {
3340
3577
  this.settleEnd(scene);
3341
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
+ }
3342
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
+ }
3343
3590
  // Armed until the player is out of the ended session (settleEnd): a
3344
3591
  // way back that fails is tried again a pause later.
3345
3592
  this.pendingEnd = now + END_PAUSE_MS;
3346
3593
  this.back(scene, { covered: this.endCovered === true });
3594
+ this.endTripN = this.trip?.n ?? null;
3595
+ }
3596
+ }
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);
3347
3668
  }
3348
3669
  }
3349
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
+
3350
3683
  // A game's end means the player's visit to that session is over. It stays
3351
3684
  // armed until the player, out of any trip, has joined another session (a
3352
3685
  // Back taken in the end pause included, however late the join resolves),
@@ -3363,11 +3696,24 @@ class HubSystem {
3363
3696
  // The camera starts behind the player, the way the place faced them
3364
3697
  // (contract §5: arrival facing is data). The Player behavior's facing is
3365
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.
3366
3703
  faceArrival(scene) {
3367
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;
3368
3708
  if (Hub.deck.soundscape?.ui === true && !this.trip && !Hub.hub.faced) {
3369
3709
  this.soundscape?.uiArrival(performance.now());
3370
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
+ }
3371
3717
  faceArrivalCamera(scene, Hub.hub.arrivedFacing);
3372
3718
  // Under the engine's orbit camera key the character's facing is not
3373
3719
  // PI - camAngle: it is asked for.
@@ -3500,6 +3846,15 @@ class HubSystem {
3500
3846
  this.playAsk = { from: playerId, name, door, until: now + PLAY_ASK_MS, ...(Hub.deck.playCards ? { stranger } : {}) };
3501
3847
  }
3502
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
+
3503
3858
  drawChrome(scene, local, now) {
3504
3859
  const chrome = this.chrome;
3505
3860
  const place = Hub.hub.place;
@@ -3706,6 +4061,7 @@ class HubSystem {
3706
4061
  cam.updateMatrixWorld();
3707
4062
  }
3708
4063
  let worldLabelCount = 0;
4064
+ let qualityTagItems = null;
3709
4065
  // This player's goals: scene actors a `goal` label points at.
3710
4066
  const goals = [];
3711
4067
  if (cam && idle) {
@@ -3716,7 +4072,7 @@ class HubSystem {
3716
4072
  if (id === talkingWith && label.style === 'speech') {
3717
4073
  continue;
3718
4074
  }
3719
- 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);
3720
4076
  if (at && label.style === 'goal') {
3721
4077
  // Where the place is sending this player (v1.13): a pointer, not a label.
3722
4078
  goals.push({ id, at, label });
@@ -3742,7 +4098,8 @@ class HubSystem {
3742
4098
  this.attention,
3743
4099
  placed
3744
4100
  .filter(({ always }) => !always)
3745
- .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) })),
3746
4103
  now,
3747
4104
  )
3748
4105
  : null;
@@ -3776,6 +4133,8 @@ class HubSystem {
3776
4133
  if (Hub.deck.quality) {
3777
4134
  const quality = lowQuality(scene);
3778
4135
  if (quality && lt) {
4136
+ // v1.168: cull now so this frame's marks and roles follow it.
4137
+ cullBeforeLabels(scene, qualityFor(scene), now);
3779
4138
  const party = new Set((Hub.hub.party.members ?? []).map((id) => scene.multiplayer?.avatars?.actors?.get(id)));
3780
4139
  // Party world labels bypass numerical caps, including the ordinary
3781
4140
  // near-label slots. Door labels still go through their 12/14 m rule.
@@ -3784,8 +4143,10 @@ class HubSystem {
3784
4143
  const screen = project(cam, at.x, at.y + 1.6, at.z, view);
3785
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 });}
3786
4145
  }
3787
- const capped = capWorldLabels(labels, placed, lt, quality.labels, party);
3788
- 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);
3789
4150
  }
3790
4151
  }
3791
4152
  worldLabelCount = labels.length;
@@ -3807,14 +4168,20 @@ class HubSystem {
3807
4168
  }
3808
4169
  chrome.setPointers?.(pointers.map((point) => offsetWorldPoint(point, view)));
3809
4170
  if (cam && idle) {
3810
- labels.push(...this.markItems(scene, local, cam, view));
3811
- 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
+ }
3812
4175
  labels.push(...this.idle.labels(scene, local, cam, view, project));
3813
4176
  labels.push(...this.say.labels(scene, local, cam, view, project, scene.multiplayer?.net?.selfId?.() ?? null));
3814
4177
  }
3815
4178
  if (Hub.hub.place?.companion === true && cam && idle) {
3816
4179
  labels.push(...(this.companion?.labels(cam, view, project, now) ?? []));
3817
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
+ }
3818
4185
  if (!padOccupancy && !crowdNames) {chrome.setLabels(labels);}
3819
4186
  if (place?.companionChat) {
3820
4187
  const canTalk = cam && idle && this.pendingEnd === null && !this.talk.talking() && this.decor?.opened() !== true && !this.carded;
@@ -3905,17 +4272,19 @@ class HubSystem {
3905
4272
  drawPanelControls(scene, now, place, idle, inGame, free, town, frameYours = true) {
3906
4273
  const chrome = this.chrome;
3907
4274
  const inviteNet = scene.multiplayer?.net;
3908
- // A guest is an over-13 player like any other: the host's canInvite
3909
- // answer alone decides the rail.
4275
+ // The optional Character row also needs the viewer's trusted invite gate.
3910
4276
  const inviteRail = scene.data?.engine?.hubInviteRail === true && !inGame && place?.invite === true &&
3911
- 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;
3912
4280
  const pickerFree = idle && place !== null && !this.talk.talking() && !this.carded;
3913
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 ? [{
3914
4282
  onPick: () => {
3915
4283
  // A stale menu cannot mint after a scene/connection change or a trip.
3916
- 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 ||
3917
4286
  scene.data?.engine?.hubInviteRail !== true || Hub.hub.place !== place || Boolean(place.result) || this.talk.talking() || this.carded ||
3918
- 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;}
3919
4288
  this.invites?.open(true);
3920
4289
  },
3921
4290
  }] : []));
@@ -3970,8 +4339,9 @@ class HubSystem {
3970
4339
  this.padReadabilityScope = { data: scene.data, place: Hub.hub.place.id,
3971
4340
  context: engine.hubPadContext, ring: engine.hubPadRing, spawn: engine.hubSpawnRing };
3972
4341
  }
4342
+ const selfId = scene.multiplayer?.net?.selfId?.();
3973
4343
  this.padReadability.frame(scene.actors, Hub.hub.hidden, local?.components.Transform, Boolean(this.trip),
3974
- this.carded || this.decor?.opened() === true);
4344
+ this.carded || this.decor?.opened() === true, selfId != null && Hub.hub.guests?.has?.(selfId) === true);
3975
4345
  }
3976
4346
 
3977
4347
  // A town's world labels under `hub.labels: "near"` (v1.43): the plate and
@@ -4069,6 +4439,7 @@ class HubSystem {
4069
4439
  const self = mp?.net?.selfId?.() ?? null;
4070
4440
  const out = [];
4071
4441
  for (const [playerId, mark] of Object.entries(Hub.hub.marks)) {
4442
+ if (disguiseTags(self, playerId)) {continue;}
4072
4443
  const actorId = playerId === self ? local?.id : mp?.avatars?.actors?.get(playerId);
4073
4444
  const at = actorId ? scene.getActor(actorId)?.components.Transform : null;
4074
4445
  const screen = at ? project(cam, at.x, at.y + 1.95, at.z, view) : null;
@@ -4094,7 +4465,7 @@ class HubSystem {
4094
4465
  this.fpsTelemetry = makeFpsTelemetry({ send: (data) => net.send(data) });
4095
4466
  }
4096
4467
  const tier = this.fpsTier ?? 0;
4097
- this.fpsTelemetry.frame(now, { scene: this.scenePath, tier, avatars: Math.min(255, (mp.avatars?.actors?.size ?? 0) + 1) });
4468
+ this.fpsTelemetry.frame(now, { scene: this.scenePath, tier, avatars: Math.min(255, (mp.avatars?.actors?.size ?? 0) + 1), quality: this.fpsQuality });
4098
4469
  }
4099
4470
  else {this.fpsTelemetry?.pause();}
4100
4471
  if (!this.stats) {
@@ -4124,6 +4495,7 @@ class HubSystem {
4124
4495
 
4125
4496
  dispose() {
4126
4497
  this.clearPadReadability();
4498
+ Celebrate.clear();
4127
4499
  this.hudRate?.dispose();
4128
4500
  this.hudRate = null;
4129
4501
  this.fpsTelemetry?.dispose();
@@ -4171,9 +4543,11 @@ class HubSystem {
4171
4543
  // hat builds: given back with the runtime.
4172
4544
  this.companion?.dispose();
4173
4545
  this.vehicle?.clear();
4546
+ this.disguise?.clear();
4174
4547
  this.wear?.clear();
4175
4548
  this.earned?.clear();
4176
4549
  this.roles?.clear();
4550
+ this.holdShows?.clear();
4177
4551
  }
4178
4552
  }
4179
4553