Replaced all event names with numbers for less bandwidth usage
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { SocketEvent } from '@/application/enums';
|
||||
import { getTile } from '@/services/mapService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import type { Ref } from 'vue'
|
||||
@ -22,7 +23,7 @@ export function useGameControlsComposable(scene: Phaser.Scene, layer: Phaser.Til
|
||||
const pointerTile = getTile(layer, pointer.worldX, pointer.worldY)
|
||||
if (!pointerTile) return
|
||||
|
||||
gameStore.connection?.emit('map:character:move', {
|
||||
gameStore.connection?.emit(SocketEvent.MAP_CHARACTER_MOVE, {
|
||||
positionX: pointerTile.x,
|
||||
positionY: pointerTile.y
|
||||
})
|
||||
@ -49,7 +50,7 @@ export function useGameControlsComposable(scene: Phaser.Scene, layer: Phaser.Til
|
||||
|
||||
// Attack on CTRL
|
||||
if (event.key === 'Control') {
|
||||
gameStore.connection?.emit('map:character:attack')
|
||||
gameStore.connection?.emit(SocketEvent.MAP_CHARACTER_ATTACK)
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,9 +66,6 @@ export function useGameControlsComposable(scene: Phaser.Scene, layer: Phaser.Til
|
||||
|
||||
function moveCharacter() {
|
||||
if (!gameStore.character) return
|
||||
|
||||
// Don't allow movement while attacking
|
||||
if (gameStore.character.isAttacking) return
|
||||
|
||||
const { positionX, positionY } = gameStore.character
|
||||
let newX = positionX
|
||||
@ -81,7 +79,7 @@ export function useGameControlsComposable(scene: Phaser.Scene, layer: Phaser.Til
|
||||
|
||||
// Only emit if position changed
|
||||
if (newX !== positionX || newY !== positionY) {
|
||||
gameStore.connection?.emit('map:character:move', {
|
||||
gameStore.connection?.emit(SocketEvent.MAP_CHARACTER_MOVE, {
|
||||
positionX: newX,
|
||||
positionY: newY
|
||||
})
|
||||
|
Reference in New Issue
Block a user