Improve speed of starting playing animations at server start-up

This commit is contained in:
David Rowe 2017-04-15 13:20:42 +12:00
parent e91cf4a4e8
commit ef8f36026c

View file

@ -279,15 +279,19 @@
} }
function autoPlay() { function autoPlay() {
var recording; var recording,
AUTOPLAY_SEARCH_DELTA = 1000; // TODO: Final value.
recording = Entity.find(); // Random delay to help reduce collisions between AC scripts.
if (recording) { Script.setTimeout(function () {
log("Play persisted recording " + recordingFilename); recording = Entity.find();
playRecording(recording.recording, recording.position, recording.orientation); if (recording) {
} else { log("Play persisted recording " + recordingFilename);
autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_SEARCH_INTERVAL); // Try again soon. playRecording(recording.recording, recording.position, recording.orientation);
} } else {
autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_SEARCH_INTERVAL); // Try again soon.
}
}, Math.random() * AUTOPLAY_SEARCH_DELTA);
} }
playRecording = function (recording, position, orientation) { playRecording = function (recording, position, orientation) {