From bc0db8b32b79b40863a91d5db241c112dfc0ee06 Mon Sep 17 00:00:00 2001
From: Dennis Postma <dennis@directonline.io>
Date: Sun, 16 Feb 2025 17:29:21 +0100
Subject: [PATCH] Receive new location as array instead of object

---
 src/components/game/map/Characters.vue | 14 +++++++-------
 src/stores/mapStore.ts                 | 12 ++++++------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/components/game/map/Characters.vue b/src/components/game/map/Characters.vue
index 39228c2..00b0b47 100644
--- a/src/components/game/map/Characters.vue
+++ b/src/components/game/map/Characters.vue
@@ -25,13 +25,13 @@ gameStore.connection?.on(SocketEvent.MAP_CHARACTER_LEAVE, (characterId: UUID) =>
   mapStore.removeCharacter(characterId)
 })
 
-gameStore.connection?.on(SocketEvent.MAP_CHARACTER_MOVE, (data: { characterId: UUID; positionX: number; positionY: number; rotation: number; isMoving: boolean }) => {
-  mapStore.updateCharacterPosition(data)
-  // @TODO: Replace with universal class, composable or store
-  if (data.characterId === gameStore.character?.id) {
-    gameStore.character!.positionX = data.positionX
-    gameStore.character!.positionY = data.positionY
-    gameStore.character!.rotation = data.rotation
+gameStore.connection?.on(SocketEvent.MAP_CHARACTER_MOVE, ([characterId, posX, posY, rot, isMoving]: [UUID, number, number, number, boolean]) => {
+  mapStore.updateCharacterPosition([characterId, posX, posY, rot, isMoving])
+
+  if (characterId === gameStore.character?.id) {
+    gameStore.character!.positionX = posX
+    gameStore.character!.positionY = posY
+    gameStore.character!.rotation = rot
   }
 })
 
diff --git a/src/stores/mapStore.ts b/src/stores/mapStore.ts
index 0c20640..c69da33 100644
--- a/src/stores/mapStore.ts
+++ b/src/stores/mapStore.ts
@@ -35,13 +35,13 @@ export const useMapStore = defineStore('map', {
     removeCharacter(characterId: UUID) {
       this.characters = this.characters.filter((char) => char.character.id !== characterId)
     },
-    updateCharacterPosition(data: { characterId: UUID; positionX: number; positionY: number; rotation: number; isMoving: boolean }) {
-      const character = this.characters.find((char) => char.character.id === data.characterId)
+    updateCharacterPosition([characterId, posX, posY, rot, isMoving]: [UUID, number, number, number, boolean]) {
+      const character = this.characters.find((char) => char.character.id === characterId)
       if (character) {
-        character.character.positionX = data.positionX
-        character.character.positionY = data.positionY
-        character.character.rotation = data.rotation
-        character.isMoving = data.isMoving
+        character.character.positionX = posX
+        character.character.positionY = posY
+        character.character.rotation = rot
+        character.isMoving = isMoving
       }
     },
     reset() {