Load textures using cache data instead of data sent from server

This commit is contained in:
2025-01-08 21:13:04 +01:00
parent 574777da80
commit 03fef60621
7 changed files with 42 additions and 30 deletions

View File

@ -9,7 +9,7 @@ export const useGameStore = defineStore('game', {
state: () => {
return {
notifications: [] as Notification[],
token: '' as string | null,
token: '',
connection: null as Socket | null,
user: null as User | null,
character: null as Character | null,
@ -17,12 +17,12 @@ export const useGameStore = defineStore('game', {
date: new Date(),
isRainEnabled: false,
isFogEnabled: false,
fogDensity: 0.5
fogDensity: 0
} as WorldSettings,
game: {
isLoading: false,
isLoaded: false, // isLoaded is currently being used to determine if the player has interacted with the game
loadedAssets: [] as string[],
loadedTextures: [] as string[],
isPlayerDraggingCamera: false,
isCameraFollowingCharacter: false
},
@ -35,10 +35,10 @@ export const useGameStore = defineStore('game', {
},
getters: {
getLoadedAssets: (state) => {
return state.game.loadedAssets
return state.game.loadedTextures
},
isAssetLoaded: (state) => {
return (key: string) => { return state.game.loadedAssets.includes(key)}
return (key: string) => { return state.game.loadedTextures.includes(key)}
},
},
actions: {
@ -106,12 +106,12 @@ export const useGameStore = defineStore('game', {
})
this.connection = null
this.token = null
this.token = ''
this.user = null
this.character = null
this.game.isLoaded = false
this.game.loadedAssets = []
this.game.loadedTextures = []
this.game.isPlayerDraggingCamera = false
this.game.isCameraFollowingCharacter = false
@ -122,7 +122,7 @@ export const useGameStore = defineStore('game', {
this.world.date = new Date()
this.world.isRainEnabled = false
this.world.isFogEnabled = false
this.world.fogDensity = 0.5
this.world.fogDensity = 0
}
}
})