@hology/core 0.0.255 → 0.0.257
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/player-sessions.d.ts +32 -0
- package/dist/gameplay/player-sessions.js +4 -0
- 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 +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/gameplay/player-runtime.d.ts +0 -41
- package/dist/gameplay/player-runtime.js +0 -4
- package/dist/test/player-runtime.test.d.ts +0 -2
- package/dist/test/player-runtime.test.js +0 -4
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { BaseActor } from './actors/actor.js';
|
|
2
|
-
import type { BasePlayerController, BasePlayerState } from './actors/controller/actor-controller.js';
|
|
3
|
-
import type { BaseGameState } from './actors/controller/game-state.js';
|
|
4
|
-
import type { NetConnection, NetPlayerInfo } from './net/net-connection.js';
|
|
5
|
-
import { type NetSession } from './net/net-session.js';
|
|
6
|
-
import { NetPlayerRegistry, type PlayerSession } from './net/player-session.js';
|
|
7
|
-
/** Lightweight player/lifecycle state shared by standalone and network games. */
|
|
8
|
-
export declare class PlayerRuntime {
|
|
9
|
-
readonly players: NetPlayerRegistry;
|
|
10
|
-
private currentGameState?;
|
|
11
|
-
private readonly revisionSubject;
|
|
12
|
-
/** Emits after any player association/status or game-state identity change. */
|
|
13
|
-
readonly changed$: import("rxjs").Observable<number>;
|
|
14
|
-
isAuthority: boolean;
|
|
15
|
-
private clearOwningConnectionHandler?;
|
|
16
|
-
private owningConnectionHandler?;
|
|
17
|
-
private validateGameStateHandler?;
|
|
18
|
-
constructor();
|
|
19
|
-
get revision(): number;
|
|
20
|
-
get gameState(): BaseGameState | undefined;
|
|
21
|
-
getGameState<T extends BaseGameState = BaseGameState>(): T | undefined;
|
|
22
|
-
getLocalPlayer(localPlayerIndex?: number): PlayerSession | undefined;
|
|
23
|
-
getLocalController<T extends BasePlayerController = BasePlayerController>(localPlayerIndex?: number): T | undefined;
|
|
24
|
-
getLocalPlayerState<T extends BasePlayerState = BasePlayerState>(localPlayerIndex?: number): T | undefined;
|
|
25
|
-
requireGameState<T extends BaseGameState = BaseGameState>(): T;
|
|
26
|
-
requireLocalPlayer(localPlayerIndex?: number): PlayerSession;
|
|
27
|
-
requireLocalController<T extends BasePlayerController = BasePlayerController>(localPlayerIndex?: number): T;
|
|
28
|
-
requireLocalPlayerState<T extends BasePlayerState = BasePlayerState>(localPlayerIndex?: number): T;
|
|
29
|
-
startStandalone(localPlayer: NetPlayerInfo): void;
|
|
30
|
-
startNetwork(session: NetSession): void;
|
|
31
|
-
setClearOwningConnectionHandler(handler?: (actor: BaseActor) => void): void;
|
|
32
|
-
setOwningConnectionHandler(handler?: (actor: BaseActor, connection: NetConnection) => void): void;
|
|
33
|
-
setOwningConnection(actor: BaseActor, connection: NetConnection): void;
|
|
34
|
-
setGameState(gameState: BaseGameState): void;
|
|
35
|
-
clearGameState(gameState?: BaseGameState): void;
|
|
36
|
-
setGameStateValidator(handler?: (gameState: BaseGameState) => void): void;
|
|
37
|
-
clearOwningConnection(actor: BaseActor): void;
|
|
38
|
-
stop(): void;
|
|
39
|
-
private notifyChanged;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=player-runtime.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{__decorate as t,__metadata as e}from"tslib";import{Service as r}from"typedi";import{NetMode as a}from"./net/net-session.js";import{NetPlayerRegistry as n}from"./net/player-session.js";import{BehaviorSubject as i}from"rxjs";let o=class{constructor(){this.players=new n,this.revisionSubject=new i(0),this.changed$=this.revisionSubject.asObservable(),this.isAuthority=!0,this.players.changed$.subscribe(()=>this.notifyChanged())}get revision(){return this.revisionSubject.value}get gameState(){return this.currentGameState}getGameState(){return this.currentGameState}getLocalPlayer(t=0){return this.players.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.players.startLocal(t)}startNetwork(t){this.stop(),this.isAuthority=t.mode<a.client,this.players.start(t)}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.players.stop(),this.clearGameState(),this.clearOwningConnectionHandler=void 0,this.owningConnectionHandler=void 0,this.validateGameStateHandler=void 0}notifyChanged(){this.revisionSubject.next(this.revisionSubject.value+1)}};o=t([r(),e("design:paramtypes",[])],o);export{o as PlayerRuntime};/*
|
|
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{PlayerRuntime as o}from"../gameplay/player-runtime.js";e("PlayerRuntime",()=>{a("resolves local gameplay state and emits association changes",()=>{const e=new o,a=[],l=e.changed$.subscribe(e=>a.push(e)),r={},c={},s={};e.startStandalone({id:"local"}),e.setGameState(r),e.players.attachPlayerState("local",s),e.players.attachController("local",c),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),l.unsubscribe()}),a("clears only the active game state",()=>{const e=new o,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
|
-
*/
|