pxt-arcade 1.12.14 → 1.12.16

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.
@@ -818,6 +818,11 @@ declare namespace pxsim {
818
818
  instruction: "playinstructions" | "muteallchannels";
819
819
  soundbuf?: Uint8Array;
820
820
  }
821
+ interface MultiplayerConnectionEvent extends SimulatorMultiplayerMessage {
822
+ content: "Connection";
823
+ slot: number;
824
+ connected: boolean;
825
+ }
821
826
  class MultiplayerState {
822
827
  lastMessageId: number;
823
828
  origin: string;
@@ -826,6 +831,7 @@ declare namespace pxsim {
826
831
  send(msg: SimulatorMultiplayerMessage): void;
827
832
  init(origin: string): void;
828
833
  setButton(key: number, isPressed: boolean): void;
834
+ registerConnectionState(player: number, connected: boolean): void;
829
835
  protected messageHandler(msg: SimulatorMessage): void;
830
836
  }
831
837
  }
@@ -2594,6 +2594,8 @@ var pxsim;
2594
2594
  IconType[IconType["Player"] = 0] = "Player";
2595
2595
  IconType[IconType["Reaction"] = 1] = "Reaction";
2596
2596
  })(IconType = pxsim.IconType || (pxsim.IconType = {}));
2597
+ const MULTIPLAYER_PLAYER_JOINED_ID = 3241;
2598
+ const MULTIPLAYER_PLAYER_LEFT_ID = 3242;
2597
2599
  class MultiplayerState {
2598
2600
  constructor() {
2599
2601
  this.lastMessageId = 0;
@@ -2626,6 +2628,11 @@ var pxsim;
2626
2628
  });
2627
2629
  }
2628
2630
  }
2631
+ registerConnectionState(player, connected) {
2632
+ const evId = connected ? MULTIPLAYER_PLAYER_JOINED_ID : MULTIPLAYER_PLAYER_LEFT_ID;
2633
+ const b = pxsim.board();
2634
+ b.bus.queue(evId, player);
2635
+ }
2629
2636
  messageHandler(msg) {
2630
2637
  if (!isMultiplayerMessage(msg)) {
2631
2638
  return;
@@ -2659,6 +2666,11 @@ var pxsim;
2659
2666
  }
2660
2667
  }
2661
2668
  }
2669
+ else if (isConnectionMessage(msg)) {
2670
+ if (this.origin === "server") {
2671
+ this.registerConnectionState(msg.slot, msg.connected);
2672
+ }
2673
+ }
2662
2674
  }
2663
2675
  }
2664
2676
  pxsim.MultiplayerState = MultiplayerState;
@@ -2674,6 +2686,9 @@ var pxsim;
2674
2686
  function isAudioMessage(msg) {
2675
2687
  return msg && msg.content === "Audio";
2676
2688
  }
2689
+ function isConnectionMessage(msg) {
2690
+ return msg && msg.content === "Connection";
2691
+ }
2677
2692
  })(pxsim || (pxsim = {}));
2678
2693
  var pxsim;
2679
2694
  (function (pxsim) {
package/built/sim.js CHANGED
@@ -2908,6 +2908,8 @@ var pxsim;
2908
2908
  IconType[IconType["Player"] = 0] = "Player";
2909
2909
  IconType[IconType["Reaction"] = 1] = "Reaction";
2910
2910
  })(IconType = pxsim.IconType || (pxsim.IconType = {}));
2911
+ const MULTIPLAYER_PLAYER_JOINED_ID = 3241;
2912
+ const MULTIPLAYER_PLAYER_LEFT_ID = 3242;
2911
2913
  class MultiplayerState {
2912
2914
  constructor() {
2913
2915
  this.lastMessageId = 0;
@@ -2940,6 +2942,11 @@ var pxsim;
2940
2942
  });
2941
2943
  }
2942
2944
  }
2945
+ registerConnectionState(player, connected) {
2946
+ const evId = connected ? MULTIPLAYER_PLAYER_JOINED_ID : MULTIPLAYER_PLAYER_LEFT_ID;
2947
+ const b = pxsim.board();
2948
+ b.bus.queue(evId, player);
2949
+ }
2943
2950
  messageHandler(msg) {
2944
2951
  if (!isMultiplayerMessage(msg)) {
2945
2952
  return;
@@ -2973,6 +2980,11 @@ var pxsim;
2973
2980
  }
2974
2981
  }
2975
2982
  }
2983
+ else if (isConnectionMessage(msg)) {
2984
+ if (this.origin === "server") {
2985
+ this.registerConnectionState(msg.slot, msg.connected);
2986
+ }
2987
+ }
2976
2988
  }
2977
2989
  }
2978
2990
  pxsim.MultiplayerState = MultiplayerState;
@@ -2988,6 +3000,9 @@ var pxsim;
2988
3000
  function isAudioMessage(msg) {
2989
3001
  return msg && msg.content === "Audio";
2990
3002
  }
3003
+ function isConnectionMessage(msg) {
3004
+ return msg && msg.content === "Connection";
3005
+ }
2991
3006
  })(pxsim || (pxsim = {}));
2992
3007
  var pxsim;
2993
3008
  (function (pxsim) {