pxt-common-packages 10.3.11 → 10.3.12
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/built/common-sim.d.ts +6 -0
- package/built/common-sim.js +15 -0
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +8627 -8381
- package/libs/controller---none/built/debug/binary.js +8629 -8383
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/built/debug/binary.js +9031 -8785
- package/libs/game/multiplayer.ts +39 -0
- package/libs/game/sim/multiplayer.ts +23 -0
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +10613 -10367
- package/libs/palette/built/debug/binary.js +9030 -8784
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +8 -8
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/built/debug/binary.js +9030 -8784
- package/libs/storyboard/built/debug/binary.js +9030 -8784
- package/package.json +1 -1
package/libs/game/multiplayer.ts
CHANGED
|
@@ -25,6 +25,8 @@ namespace multiplayer {
|
|
|
25
25
|
game.pushScene();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
const MULTIPLAYER_PLAYER_JOINED_ID = 3241;
|
|
29
|
+
const MULTIPLAYER_PLAYER_LEFT_ID = 3242;
|
|
28
30
|
export function initServer() {
|
|
29
31
|
if (getOrigin() === "server") {
|
|
30
32
|
game.eventContext().registerFrameHandler(scene.MULTIPLAYER_POST_SCREEN_PRIORITY, () => {
|
|
@@ -32,7 +34,44 @@ namespace multiplayer {
|
|
|
32
34
|
postImage(screen);
|
|
33
35
|
}
|
|
34
36
|
})
|
|
37
|
+
|
|
38
|
+
for (let p = 1; p <= 4; p++) {
|
|
39
|
+
registerPlayerConnectionListeners(p);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function registerPlayerConnectionListeners(playerNumber: number) {
|
|
45
|
+
control.onEvent(
|
|
46
|
+
MULTIPLAYER_PLAYER_JOINED_ID,
|
|
47
|
+
playerNumber,
|
|
48
|
+
() => receiveConnectionChangedEvent(playerNumber, true)
|
|
49
|
+
);
|
|
50
|
+
control.onEvent(
|
|
51
|
+
MULTIPLAYER_PLAYER_LEFT_ID,
|
|
52
|
+
playerNumber,
|
|
53
|
+
() => receiveConnectionChangedEvent(playerNumber, false)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function receiveConnectionChangedEvent(playerNumber: number, connected: boolean) {
|
|
58
|
+
let c: controller.Controller;
|
|
59
|
+
switch (playerNumber) {
|
|
60
|
+
case 1:
|
|
61
|
+
c = controller.player1;
|
|
62
|
+
break;
|
|
63
|
+
case 2:
|
|
64
|
+
c = controller.player2;
|
|
65
|
+
break;
|
|
66
|
+
case 3:
|
|
67
|
+
c = controller.player3;
|
|
68
|
+
break;
|
|
69
|
+
case 4:
|
|
70
|
+
c = controller.player4;
|
|
71
|
+
break;
|
|
35
72
|
}
|
|
73
|
+
if (c)
|
|
74
|
+
c.connected = connected;
|
|
36
75
|
}
|
|
37
76
|
}
|
|
38
77
|
|
|
@@ -98,6 +98,15 @@ namespace pxsim {
|
|
|
98
98
|
soundbuf?: Uint8Array;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
export interface MultiplayerConnectionEvent extends SimulatorMultiplayerMessage {
|
|
102
|
+
content: "Connection";
|
|
103
|
+
slot: number;
|
|
104
|
+
connected: boolean;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const MULTIPLAYER_PLAYER_JOINED_ID = 3241;
|
|
108
|
+
const MULTIPLAYER_PLAYER_LEFT_ID = 3242;
|
|
109
|
+
|
|
101
110
|
export class MultiplayerState {
|
|
102
111
|
lastMessageId: number;
|
|
103
112
|
origin: string;
|
|
@@ -144,6 +153,12 @@ namespace pxsim {
|
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
|
|
156
|
+
registerConnectionState(player: number, connected: boolean) {
|
|
157
|
+
const evId = connected ? MULTIPLAYER_PLAYER_JOINED_ID : MULTIPLAYER_PLAYER_LEFT_ID;
|
|
158
|
+
const b = board();
|
|
159
|
+
b.bus.queue(evId, player);
|
|
160
|
+
}
|
|
161
|
+
|
|
147
162
|
protected messageHandler(msg: SimulatorMessage) {
|
|
148
163
|
if (!isMultiplayerMessage(msg)) {
|
|
149
164
|
return;
|
|
@@ -176,6 +191,10 @@ namespace pxsim {
|
|
|
176
191
|
pxsim.AudioContextManager.muteAllChannels();
|
|
177
192
|
}
|
|
178
193
|
}
|
|
194
|
+
} else if (isConnectionMessage(msg)) {
|
|
195
|
+
if (this.origin === "server") {
|
|
196
|
+
this.registerConnectionState(msg.slot, msg.connected);
|
|
197
|
+
}
|
|
179
198
|
}
|
|
180
199
|
}
|
|
181
200
|
}
|
|
@@ -195,4 +214,8 @@ namespace pxsim {
|
|
|
195
214
|
function isAudioMessage(msg: SimulatorMultiplayerMessage): msg is MultiplayerAudioEvent {
|
|
196
215
|
return msg && msg.content === "Audio";
|
|
197
216
|
}
|
|
217
|
+
|
|
218
|
+
function isConnectionMessage(msg: SimulatorMultiplayerMessage): msg is MultiplayerConnectionEvent {
|
|
219
|
+
return msg && msg.content === "Connection";
|
|
220
|
+
}
|
|
198
221
|
}
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P48755(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___48998 = (undefined);
|
|
70
|
+
globals._pollEventQueue___49011 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P48755.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P48755.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P48755_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P48755, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P48703_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P48755
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P98597(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___98840 = (undefined);
|
|
70
|
+
globals._pollEventQueue___98853 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P98597.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P98597.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P98597_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P98597, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P98441_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P98597
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P60057(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___60300 = (undefined);
|
|
70
|
+
globals._pollEventQueue___60313 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P60057.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P60057.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P60057_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P60057, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P60005_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P60057
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P191805(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___192048 = (undefined);
|
|
70
|
+
globals._pollEventQueue___192061 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P191805.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P191805.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P191805_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P191805, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P191441_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P191805
|
|
92
92
|
})
|