@hology/core 0.0.256 → 0.0.258
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.
- package/dist/gameplay/game-mode.d.ts +3 -2
- package/dist/gameplay/game-mode.js +1 -1
- package/dist/gameplay/game-state-context.d.ts +13 -0
- package/dist/gameplay/game-state-context.js +4 -0
- package/dist/gameplay/index.d.ts +2 -1
- package/dist/gameplay/index.js +1 -1
- package/dist/gameplay/initiate.js +1 -1
- package/dist/gameplay/net/player-session.d.ts +6 -0
- package/dist/gameplay/net/player-session.js +1 -1
- package/dist/gameplay/net/service/net-service.d.ts +3 -2
- package/dist/gameplay/net/service/net-service.js +1 -1
- package/dist/gameplay/network-travel-coordinator.js +1 -1
- package/dist/gameplay/player-lifecycle-coordinator.d.ts +2 -1
- package/dist/gameplay/player-lifecycle-coordinator.js +1 -1
- package/dist/gameplay/{players.d.ts → player-sessions.d.ts} +7 -10
- package/dist/gameplay/player-sessions.js +4 -0
- package/dist/rendering/node-material-webgpu-resolver.js +1 -1
- package/dist/rendering/webgpu-experimental-backend.d.ts +1 -0
- package/dist/rendering/webgpu-experimental-backend.js +1 -1
- package/dist/rendering.d.ts +4 -0
- package/dist/rendering.js +1 -1
- package/dist/test/game-state-context.test.d.ts +2 -0
- package/dist/test/game-state-context.test.js +4 -0
- package/dist/test/player-sessions.test.d.ts +2 -0
- package/dist/test/player-sessions.test.js +4 -0
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/gameplay/players.js +0 -4
- package/dist/test/players.test.d.ts +0 -2
- package/dist/test/players.test.js +0 -4
package/dist/gameplay/players.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{__decorate as t,__metadata as e}from"tslib";import{BehaviorSubject as r}from"rxjs";import{Service as a}from"typedi";import{NetMode as i}from"./net/net-session.js";import{NetPlayerRegistry as n}from"./net/player-session.js";let s=class{constructor(){this.registry=new n,this.revisionSubject=new r(0),this.changed$=this.revisionSubject.asObservable(),this.playerJoined$=this.registry.playerJoined$,this.playerLeft$=this.registry.playerLeft$,this.isAuthority=!0,this.registry.changed$.subscribe(()=>this.notifyChanged())}get revision(){return this.revisionSubject.value}get gameState(){return this.currentGameState}get all(){return this.registry.values}get active(){return this.registry.values.filter(t=>"active"===t.status)}get local(){return this.registry.values.filter(t=>null!=t.localPlayerIndex)}get(t){return this.registry.get(t)}getGameState(){return this.currentGameState}getLocalPlayer(t=0){return this.registry.values.find(e=>e.localPlayerIndex===t)}getLocalController(t=0){return this.getLocalPlayer(t)?.controller}getLocalPlayerState(t=0){return this.getLocalPlayer(t)?.playerState}requireGameState(){const t=this.getGameState();if(null==t)throw new Error("Game state is not available");return t}requireLocalPlayer(t=0){const e=this.getLocalPlayer(t);if(null==e)throw new Error(`Local player ${t} is not available`);return e}requireLocalController(t=0){const e=this.getLocalController(t);if(null==e)throw new Error(`Controller for local player ${t} is not available`);return e}requireLocalPlayerState(t=0){const e=this.getLocalPlayerState(t);if(null==e)throw new Error(`Player state for local player ${t} is not available`);return e}startStandalone(t){this.stop(),this.isAuthority=!0,this.registry.startLocal(t)}startNetwork(t){this.stop(),this.isAuthority=t.mode<i.client,this.registry.start(t)}attachController(t,e){this.registry.attachController(t,e)}attachPlayerState(t,e){this.registry.attachPlayerState(t,e)}setStatus(t,e){this.registry.setStatus(t,e)}setClearOwningConnectionHandler(t){this.clearOwningConnectionHandler=t}setOwningConnectionHandler(t){this.owningConnectionHandler=t}setOwningConnection(t,e){this.owningConnectionHandler?.(t,e)}setGameState(t){this.validateGameStateHandler?.(t),this.currentGameState!==t&&(this.currentGameState=t,this.notifyChanged())}clearGameState(t){null==this.currentGameState||null!=t&&this.currentGameState!==t||(this.currentGameState=void 0,this.notifyChanged())}setGameStateValidator(t){this.validateGameStateHandler=t}clearOwningConnection(t){this.clearOwningConnectionHandler?.(t)}stop(){this.registry.stop(),this.clearGameState(),this.clearOwningConnectionHandler=void 0,this.owningConnectionHandler=void 0,this.validateGameStateHandler=void 0}notifyChanged(){this.revisionSubject.next(this.revisionSubject.value+1)}};s=t([a(),e("design:paramtypes",[])],s);export{s as Players};/*
|
|
2
|
-
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
-
* See the LICENSE.md file for details.
|
|
4
|
-
*/
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{describe as e,expect as t,it as a}from"vitest";import{Players as l}from"../gameplay/players.js";e("Players",()=>{a("exposes player collections and resolves local gameplay state",()=>{const e=new l,a=[],o=e.changed$.subscribe(e=>a.push(e)),r={},c={},s={};e.startStandalone({id:"local"}),e.setGameState(r),e.attachPlayerState("local",s),e.attachController("local",c),t(e.all).toHaveLength(1),t(e.active).toEqual(e.all),t(e.local).toEqual(e.all),t(e.get("local")).toBe(e.all[0]),t(e.getGameState()).toBe(r),t(e.getLocalPlayer()?.info.id).toBe("local"),t(e.getLocalController()).toBe(c),t(e.getLocalPlayerState()).toBe(s),t(e.requireGameState()).toBe(r),t(e.requireLocalPlayer().controller).toBe(c),t(e.requireLocalController()).toBe(c),t(e.requireLocalPlayerState()).toBe(s),t(a.at(-1)).toBe(e.revision),t(e.revision).toBeGreaterThan(0),o.unsubscribe()}),a("clears only the active game state",()=>{const e=new l,a={};e.setGameState(a),e.clearGameState({}),t(e.gameState).toBe(a),e.clearGameState(a),t(e.gameState).toBeUndefined()})});/*
|
|
2
|
-
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
-
* See the LICENSE.md file for details.
|
|
4
|
-
*/
|