forked from noxious/client
Receive new location as array instead of object
This commit is contained in:
parent
ad611ef593
commit
bc0db8b32b
@ -25,13 +25,13 @@ gameStore.connection?.on(SocketEvent.MAP_CHARACTER_LEAVE, (characterId: UUID) =>
|
|||||||
mapStore.removeCharacter(characterId)
|
mapStore.removeCharacter(characterId)
|
||||||
})
|
})
|
||||||
|
|
||||||
gameStore.connection?.on(SocketEvent.MAP_CHARACTER_MOVE, (data: { characterId: UUID; positionX: number; positionY: number; rotation: number; isMoving: boolean }) => {
|
gameStore.connection?.on(SocketEvent.MAP_CHARACTER_MOVE, ([characterId, posX, posY, rot, isMoving]: [UUID, number, number, number, boolean]) => {
|
||||||
mapStore.updateCharacterPosition(data)
|
mapStore.updateCharacterPosition([characterId, posX, posY, rot, isMoving])
|
||||||
// @TODO: Replace with universal class, composable or store
|
|
||||||
if (data.characterId === gameStore.character?.id) {
|
if (characterId === gameStore.character?.id) {
|
||||||
gameStore.character!.positionX = data.positionX
|
gameStore.character!.positionX = posX
|
||||||
gameStore.character!.positionY = data.positionY
|
gameStore.character!.positionY = posY
|
||||||
gameStore.character!.rotation = data.rotation
|
gameStore.character!.rotation = rot
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -35,13 +35,13 @@ export const useMapStore = defineStore('map', {
|
|||||||
removeCharacter(characterId: UUID) {
|
removeCharacter(characterId: UUID) {
|
||||||
this.characters = this.characters.filter((char) => char.character.id !== characterId)
|
this.characters = this.characters.filter((char) => char.character.id !== characterId)
|
||||||
},
|
},
|
||||||
updateCharacterPosition(data: { characterId: UUID; positionX: number; positionY: number; rotation: number; isMoving: boolean }) {
|
updateCharacterPosition([characterId, posX, posY, rot, isMoving]: [UUID, number, number, number, boolean]) {
|
||||||
const character = this.characters.find((char) => char.character.id === data.characterId)
|
const character = this.characters.find((char) => char.character.id === characterId)
|
||||||
if (character) {
|
if (character) {
|
||||||
character.character.positionX = data.positionX
|
character.character.positionX = posX
|
||||||
character.character.positionY = data.positionY
|
character.character.positionY = posY
|
||||||
character.character.rotation = data.rotation
|
character.character.rotation = rot
|
||||||
character.isMoving = data.isMoving
|
character.isMoving = isMoving
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user