Reset player details when domain restarts or user teleports

This commit is contained in:
David Rowe 2017-04-13 12:23:10 +12:00
parent 7dddd266ba
commit 8bbce53f74

View file

@ -19,6 +19,7 @@
isDialogDisplayed = false,
tablet,
button,
isConnected,
CountdownTimer,
RecordingIndicator,
@ -436,6 +437,14 @@
Dialog.updatePlayerDetails(playerIsPlayings, playerRecordings, playerIDs);
}
function reset() {
playerIDs = [];
playerIsPlayings = [];
playerRecordings = [];
playerTimestamps = [];
Dialog.updatePlayerDetails(playerIsPlayings, playerRecordings, playerIDs);
}
function setUp() {
// Messaging with AC scripts.
Messages.messageReceived.connect(onMessageReceived);
@ -455,6 +464,7 @@
playRecording: playRecording,
stopPlayingRecording: stopPlayingRecording,
numberOfPlayers: numberOfPlayers,
reset: reset,
setUp: setUp,
tearDown: tearDown
};
@ -584,6 +594,17 @@
}
}
function onUpdate() {
if (isConnected !== Window.location.isConnected) {
// Server restarted or domain changed.
isConnected = !isConnected;
if (!isConnected) {
// Clear dialog.
Player.reset();
}
}
}
function setUp() {
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
if (!tablet) {
@ -606,6 +627,9 @@
Dialog.setUp();
Player.setUp();
Recorder.setUp(Player.playRecording);
isConnected = Window.location.isConnected;
Script.update.connect(onUpdate);
}
function tearDown() {
@ -613,6 +637,8 @@
return;
}
Script.update.disconnect(onUpdate);
Recorder.tearDown();
Player.tearDown();
Dialog.tearDown();