mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:17:02 +02:00
Fix auto-playback logic
This commit is contained in:
parent
8e3bc31c36
commit
9495bf6a47
1 changed files with 11 additions and 6 deletions
|
@ -19,13 +19,15 @@
|
||||||
PLAYER_COMMAND_STOP = "stop",
|
PLAYER_COMMAND_STOP = "stop",
|
||||||
heartbeatTimer = null,
|
heartbeatTimer = null,
|
||||||
HEARTBEAT_INTERVAL = 3000, // TODO: Final value.
|
HEARTBEAT_INTERVAL = 3000, // TODO: Final value.
|
||||||
|
TIMESTAMP_UPDATE_INTERVAL = 2500, // TODO: Final value.
|
||||||
|
AUTOPLAY_SEARCH_INTERVAL = 5000, // TODO: Final value.
|
||||||
scriptUUID,
|
scriptUUID,
|
||||||
|
|
||||||
Entity,
|
Entity,
|
||||||
Player;
|
Player;
|
||||||
|
|
||||||
function log(message) {
|
function log(message) {
|
||||||
print(APP_NAME + ": " + message);
|
print(APP_NAME + " " + scriptUUID + ": " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity = (function () {
|
Entity = (function () {
|
||||||
|
@ -33,7 +35,6 @@
|
||||||
var entityID = null,
|
var entityID = null,
|
||||||
userData,
|
userData,
|
||||||
updateTimestampTimer = null,
|
updateTimestampTimer = null,
|
||||||
TIMESTAMP_UPDATE_INTERVAL = 2000, // TODO: Final value.
|
|
||||||
ENTITY_NAME = "Recording",
|
ENTITY_NAME = "Recording",
|
||||||
ENTITY_DESCRIPTION = "Avatar recording to play back",
|
ENTITY_DESCRIPTION = "Avatar recording to play back",
|
||||||
ENTITIY_POSITION = { x: -16382, y: -16382, z: -16382 }, // Near but not right on domain corner.
|
ENTITIY_POSITION = { x: -16382, y: -16382, z: -16382 }, // Near but not right on domain corner.
|
||||||
|
@ -52,6 +53,8 @@
|
||||||
// Create a new persistence entity (even if already have one but that should never occur).
|
// Create a new persistence entity (even if already have one but that should never occur).
|
||||||
var properties;
|
var properties;
|
||||||
|
|
||||||
|
log("Create recording " + filename);
|
||||||
|
|
||||||
if (updateTimestampTimer !== null) {
|
if (updateTimestampTimer !== null) {
|
||||||
Script.clearInterval(updateTimestampTimer); // Just in case.
|
Script.clearInterval(updateTimestampTimer); // Just in case.
|
||||||
}
|
}
|
||||||
|
@ -104,10 +107,11 @@
|
||||||
}
|
}
|
||||||
isClaiming = false;
|
isClaiming = false;
|
||||||
|
|
||||||
// Return claim as "found" if still valid.
|
// Complete claim as "found" if still valid.
|
||||||
properties = Entities.getEntityProperties(entityID, ["userData"]);
|
properties = Entities.getEntityProperties(entityID, ["userData"]);
|
||||||
userData = JSON.parse(properties.userData);
|
userData = JSON.parse(properties.userData);
|
||||||
if (userData.scriptUUID === scriptUUID) {
|
if (userData.scriptUUID === scriptUUID) {
|
||||||
|
log("Complete claim " + entityID);
|
||||||
userData.timestamp = Date.now();
|
userData.timestamp = Date.now();
|
||||||
Entities.editEntity(entityID, { userData: JSON.stringify(userData) });
|
Entities.editEntity(entityID, { userData: JSON.stringify(userData) });
|
||||||
EntityViewer.queryOctree(); // Update octree ready for next find() call.
|
EntityViewer.queryOctree(); // Update octree ready for next find() call.
|
||||||
|
@ -116,6 +120,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise resume searching.
|
// Otherwise resume searching.
|
||||||
|
log("Release claim " + entityID);
|
||||||
EntityViewer.queryOctree(); // Update octree ready for next find() call.
|
EntityViewer.queryOctree(); // Update octree ready for next find() call.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -130,13 +135,14 @@
|
||||||
properties = Entities.getEntityProperties(entityIDs[index], ["name", "userData"]);
|
properties = Entities.getEntityProperties(entityIDs[index], ["name", "userData"]);
|
||||||
if (properties.name === ENTITY_NAME) {
|
if (properties.name === ENTITY_NAME) {
|
||||||
userData = JSON.parse(properties.userData);
|
userData = JSON.parse(properties.userData);
|
||||||
isFound = (Date.now() - userData.timestamp) > ((CLAIM_CHECKS + 1) * TIMESTAMP_UPDATE_INTERVAL);
|
isFound = (Date.now() - userData.timestamp) > ((CLAIM_CHECKS + 1) * AUTOPLAY_SEARCH_INTERVAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Claim entity if found.
|
// Claim entity if found.
|
||||||
if (isFound) {
|
if (isFound) {
|
||||||
|
log("Claim entity " + entityIDs[index]);
|
||||||
isClaiming = true;
|
isClaiming = true;
|
||||||
claimCheckCount = 0;
|
claimCheckCount = 0;
|
||||||
entityID = entityIDs[index];
|
entityID = entityIDs[index];
|
||||||
|
@ -186,8 +192,7 @@
|
||||||
// Recording playback functions.
|
// Recording playback functions.
|
||||||
var isPlayingRecording = false,
|
var isPlayingRecording = false,
|
||||||
recordingFilename = "",
|
recordingFilename = "",
|
||||||
autoPlayTimer = null,
|
autoPlayTimer = null;
|
||||||
AUTOPLAY_SEARCH_INTERVAL = 5000; // TODO: Final value.
|
|
||||||
|
|
||||||
function playRecording(recording, position, orientation) {
|
function playRecording(recording, position, orientation) {
|
||||||
Agent.isAvatar = true;
|
Agent.isAvatar = true;
|
||||||
|
|
Loading…
Reference in a new issue