Cache world on portal spawn

This commit is contained in:
Natsumi
2022-01-05 02:03:20 +13:00
parent 9ff54d101a
commit 44652c2911
2 changed files with 66 additions and 3 deletions

View File

@@ -8796,6 +8796,7 @@ speechSynthesis.getVoices();
var args = await API.getCachedWorld({
worldId: L.worldId
});
this.portalDownloadWorldCache(args.ref, ref);
this.addPhotonEventToGameLog({
created_at,
type: 'PortalSpawn',
@@ -10888,6 +10889,9 @@ speechSynthesis.getVoices();
$app.data.worldAutoCacheGPSFilter = configRepository.getBool(
'VRCX_worldAutoCacheGPSFilter'
);
$app.data.portalAutoCache = configRepository.getString(
'VRCX_portalAutoCache'
);
$app.data.autoSweepVRChatCache = configRepository.getBool(
'VRCX_autoSweepVRChatCache'
);
@@ -10952,6 +10956,10 @@ speechSynthesis.getVoices();
'VRCX_worldAutoCacheGPSFilter',
this.worldAutoCacheGPSFilter
);
configRepository.setString(
'VRCX_portalAutoCache',
this.portalAutoCache
);
configRepository.setBool(
'VRCX_autoSweepVRChatCache',
this.autoSweepVRChatCache
@@ -11129,6 +11137,13 @@ speechSynthesis.getVoices();
$app.data.worldAutoCacheGPS
);
}
if (!configRepository.getString('VRCX_portalAutoCache')) {
$app.data.portalAutoCache = 'Off';
configRepository.setString(
'VRCX_portalAutoCache',
$app.data.portalAutoCache
);
}
if (!configRepository.getBool('VRCX_vrBackgroundEnabled')) {
$app.data.vrBackgroundEnabled = false;
configRepository.setBool(
@@ -17248,6 +17263,18 @@ speechSynthesis.getVoices();
}
};
$app.methods.portalDownloadWorldCache = function (worldRef, userRef) {
var isFriend = this.friends.has(userRef.id);
var isFavorite = API.cachedFavoritesByObjectId.has(userRef.id);
if (
this.portalAutoCache === 'Everyone' ||
(this.portalAutoCache === 'Friends' && isFriend) ||
(this.portalAutoCache === 'VIP' && isFavorite)
) {
this.autoDownloadWorldCache(worldRef.id, 'Portal', userRef.id);
}
};
$app.methods.feedDownloadWorldCache = function (id, location) {
if (
this.worldAutoCacheGPS === 'Always' ||
@@ -17341,6 +17368,20 @@ speechSynthesis.getVoices();
type: 'success'
});
}
if (
this.isGameRunning &&
(this.downloadCurrent.type === 'Invite' ||
this.downloadCurrent.type === 'Portal')
) {
var entry = {
created_at: new Date().toJSON(),
type: 'Event',
data: `World finished caching ${this.downloadCurrent.ref.name}`
};
this.queueGameLogNoty(entry);
this.addGameLog(entry);
database.addGamelogEventToDatabase(entry);
}
this.downloadCurrent.status = 'Success';
this.downloadCurrent.date = Date.now();
this.downloadHistoryTable.data.unshift(this.downloadCurrent);
@@ -17398,6 +17439,20 @@ speechSynthesis.getVoices();
type: 'warning'
});
}
if (
this.isGameRunning &&
(this.downloadCurrent.type === 'Invite' ||
this.downloadCurrent.type === 'Portal')
) {
var entry = {
created_at: new Date().toJSON(),
type: 'Event',
data: `World already in cache ${this.downloadCurrent.ref.name}`
};
this.queueGameLogNoty(entry);
this.addGameLog(entry);
database.addGamelogEventToDatabase(entry);
}
this.downloadCurrent.status = 'Already in cache';
this.downloadCurrent.date = Date.now();
this.downloadHistoryTable.data.unshift(this.downloadCurrent);