big worlds refactor with more scalable api, which allows hmr workers
fix: better free up ram after world unload & create meshers only when needed feat: add low ram setting, which makes chunks load performance ~4x worse
This commit is contained in:
parent
4fb2de503b
commit
0acaa652a3
18 changed files with 201 additions and 90 deletions
|
|
@ -8,10 +8,15 @@ import { options } from './optionsStorage'
|
|||
import { loadOrPlaySound } from './basicSounds'
|
||||
import { showNotification } from './react/NotificationProvider'
|
||||
|
||||
const globalObject = window as {
|
||||
allSoundsMap?: Record<string, Record<string, string>>,
|
||||
allSoundsVersionedMap?: Record<string, string[]>,
|
||||
}
|
||||
|
||||
subscribeKey(miscUiState, 'gameLoaded', async () => {
|
||||
if (!miscUiState.gameLoaded) return
|
||||
const soundsLegacyMap = window.allSoundsVersionedMap as Record<string, string[]>
|
||||
const allSoundsMap = window.allSoundsMap as Record<string, Record<string, string>>
|
||||
const { allSoundsMap } = globalObject
|
||||
const allSoundsMeta = window.allSoundsMeta as { format: string, baseUrl: string }
|
||||
if (!allSoundsMap) {
|
||||
return
|
||||
|
|
@ -115,7 +120,7 @@ subscribeKey(miscUiState, 'gameLoaded', async () => {
|
|||
}
|
||||
|
||||
const getStepSound = (blockUnder: Block) => {
|
||||
// const soundsMap = window.allSoundsMap?.[bot.version]
|
||||
// const soundsMap = globalObject.allSoundsMap?.[bot.version]
|
||||
// if (!soundsMap) return
|
||||
// let soundResult = 'block.stone.step'
|
||||
// for (const x of Object.keys(soundsMap).map(n => n.split(';')[1])) {
|
||||
|
|
@ -215,8 +220,21 @@ subscribeKey(miscUiState, 'gameLoaded', async () => {
|
|||
// })
|
||||
})
|
||||
|
||||
// todo
|
||||
// const music = {
|
||||
// activated: false,
|
||||
// playing: '',
|
||||
// activate () {
|
||||
// const gameMusic = Object.entries(globalObject.allSoundsMap?.[bot.version] ?? {}).find(([id, sound]) => sound.includes('music.game'))
|
||||
// if (!gameMusic) return
|
||||
// const soundPath = gameMusic[0].split(';')[1]
|
||||
// const next = () => {}
|
||||
// }
|
||||
// }
|
||||
|
||||
export const earlyCheck = () => {
|
||||
const allSoundsMap = window.allSoundsMap as Record<string, Record<string, string>>
|
||||
const { allSoundsMap } = globalObject
|
||||
if (!allSoundsMap) return
|
||||
|
||||
// todo also use major versioned hardcoded sounds
|
||||
const soundsMap = allSoundsMap[bot.version]
|
||||
|
|
@ -239,7 +257,7 @@ const getVersionedSound = (version: string, item: string, itemsMapSortedEntries:
|
|||
}
|
||||
|
||||
export const downloadSoundsIfNeeded = async () => {
|
||||
if (!window.allSoundsMap) {
|
||||
if (!globalObject.allSoundsMap) {
|
||||
try {
|
||||
await loadScript('./sounds.js')
|
||||
} catch (err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue