@antha/multiplayer-p2p-lock-step 0.0.1 → 0.0.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiAndRoomConnectionState
|
|
1
|
+
import { type ApiAndRoomConnectionState } from '@antha/multiplayer-core';
|
|
2
2
|
import { type JsonCompatibleValue, type PartialWithUndefined, type SelectFrom } from '@augment-vir/common';
|
|
3
3
|
import { P2pLockStepMultiplayerController, type P2pLockStepMultiplayerControllerParams } from './p2p-lock-step-multiplayer-controller.js';
|
|
4
4
|
/**
|
|
@@ -15,8 +15,6 @@ export type AnthaMultiplayerP2pLockStepState<MultiplayerPacket extends JsonCompa
|
|
|
15
15
|
multiplayerController: P2pLockStepMultiplayerController<MultiplayerPacket>;
|
|
16
16
|
/** Current backend API and room connection state. */
|
|
17
17
|
connectionState: ApiAndRoomConnectionState;
|
|
18
|
-
/** Rooms currently available for joining. */
|
|
19
|
-
availableRooms: MultiplayerClientRooms;
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
20
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineAnthaMod } from '@antha/engine';
|
|
2
|
-
import { ControllerConnectionEvent,
|
|
2
|
+
import { ControllerConnectionEvent, emptyApiAndRoomConnectionState, } from '@antha/multiplayer-core';
|
|
3
3
|
import { log, } from '@augment-vir/common';
|
|
4
4
|
import { P2pLockStepMultiplayerController, } from './p2p-lock-step-multiplayer-controller.js';
|
|
5
5
|
/**
|
|
@@ -24,7 +24,6 @@ export function createAnthaMultiplayerP2pLockStepMod(options = {}) {
|
|
|
24
24
|
frameDuration: undefined,
|
|
25
25
|
}),
|
|
26
26
|
connectionState: emptyApiAndRoomConnectionState,
|
|
27
|
-
availableRooms: {},
|
|
28
27
|
};
|
|
29
28
|
state.multiplayerP2pLockStep.multiplayerController.listen(ControllerConnectionEvent, ({ detail: newConnectionState }) => {
|
|
30
29
|
if (!state.multiplayerP2pLockStep) {
|
|
@@ -33,12 +32,6 @@ export function createAnthaMultiplayerP2pLockStepMod(options = {}) {
|
|
|
33
32
|
log.if(!!state.debugMultiplayer).faint(`[multiplayer] mod connection state updated: api=${String(newConnectionState.api)} room=${String(newConnectionState.room)}`);
|
|
34
33
|
state.multiplayerP2pLockStep.connectionState = newConnectionState;
|
|
35
34
|
});
|
|
36
|
-
state.multiplayerP2pLockStep.multiplayerController.listen(ControllerRoomListEvent, ({ detail: rooms }) => {
|
|
37
|
-
if (!state.multiplayerP2pLockStep) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
state.multiplayerP2pLockStep.availableRooms = rooms;
|
|
41
|
-
});
|
|
42
35
|
}
|
|
43
36
|
},
|
|
44
37
|
cleanup({ state }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiAndRoomConnectionState, type ClientId, ControllerClientEvent, ControllerConnectionEvent, ControllerRoomListEvent, type MultiplayerInitParams, type MultiplayerRoomConnection, MultiplayerRoomController, type RoomInput, RoomRejectionError } from '@antha/multiplayer-core';
|
|
1
|
+
import { type ApiAndRoomConnectionState, type ClientId, ControllerClientEvent, ControllerConnectionEvent, ControllerRoomListEvent, type ControllerRoomListListener, type MultiplayerInitParams, type MultiplayerRoomConnection, MultiplayerRoomController, type RoomInput, RoomRejectionError } from '@antha/multiplayer-core';
|
|
2
2
|
import { type JsonCompatibleValue, type MaybePromise, type PartialWithUndefined } from '@augment-vir/common';
|
|
3
3
|
import { type AnyDuration } from 'date-vir';
|
|
4
4
|
import { ListenTarget, type TypedCustomEventInit } from 'typed-event-target';
|
|
@@ -142,12 +142,13 @@ export declare class P2pLockStepMultiplayerController<MultiplayerPacket extends
|
|
|
142
142
|
/** The current client id. */
|
|
143
143
|
get clientId(): ClientId;
|
|
144
144
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
145
|
+
* Listen for room list updates, including while connected to a room.
|
|
146
|
+
*
|
|
147
|
+
* If a callback is provided, it is called each time the room list is updated.
|
|
147
148
|
*/
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
|
|
149
|
+
startRoomUpdates(callback?: ControllerRoomListListener | undefined): import("typed-event-target").RemoveListenerCallback;
|
|
150
|
+
/** Turn off room list updates and remove callbacks added via `startRoomUpdates`. */
|
|
151
|
+
stopRoomUpdates(): void;
|
|
151
152
|
/** Currently joined room id. If a room has not been joined yet, this will be empty. */
|
|
152
153
|
get roomId(): import("@antha/multiplayer-core").RoomId | undefined;
|
|
153
154
|
/** The current connection state of the controller's connection to a backend API. */
|
|
@@ -86,15 +86,16 @@ export class P2pLockStepMultiplayerController extends ListenTarget {
|
|
|
86
86
|
return this.roomConnection?.clientId || this.localClientId;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
89
|
+
* Listen for room list updates, including while connected to a room.
|
|
90
|
+
*
|
|
91
|
+
* If a callback is provided, it is called each time the room list is updated.
|
|
91
92
|
*/
|
|
92
|
-
|
|
93
|
-
return this.roomController.
|
|
93
|
+
startRoomUpdates(callback) {
|
|
94
|
+
return this.roomController.startRoomUpdates(callback);
|
|
94
95
|
}
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
this.roomController.
|
|
96
|
+
/** Turn off room list updates and remove callbacks added via `startRoomUpdates`. */
|
|
97
|
+
stopRoomUpdates() {
|
|
98
|
+
this.roomController.stopRoomUpdates();
|
|
98
99
|
}
|
|
99
100
|
/** Currently joined room id. If a room has not been joined yet, this will be empty. */
|
|
100
101
|
get roomId() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/multiplayer-p2p-lock-step",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Multiplayer mod for the Antha engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"istanbul-smart-text-reporter": "^1.1.5"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@antha/multiplayer-core": "^0.0.
|
|
52
|
+
"@antha/multiplayer-core": "^0.0.2"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=22"
|