Minor movement improvements
This commit is contained in:
parent
d68d307895
commit
f2dd1a2ffe
@ -121,6 +121,11 @@ export default class CharacterMove extends BaseEvent {
|
||||
if (mapEventTile) {
|
||||
if (mapEventTile.type === 'BLOCK') break
|
||||
if (mapEventTile.type === 'TELEPORT' && mapEventTile.teleport) {
|
||||
// Force clear movement state before teleport
|
||||
mapCharacter.isMoving = false
|
||||
mapCharacter.currentPath = null
|
||||
this.lastKnownPosition = null // Reset last known position
|
||||
|
||||
await CharacterMoveService.handleTeleportMapEventTile(character.id, mapEventTile as MapEventTileWithTeleport)
|
||||
return
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ type Position = { positionX: number; positionY: number }
|
||||
export type Node = Position & { parent?: Node; g: number; h: number; f: number }
|
||||
|
||||
class CharacterMoveService extends BaseService {
|
||||
private io: Server = SocketManager.getIO()
|
||||
|
||||
// Rotation lookup table for better performance
|
||||
private readonly ROTATION_MAP = {
|
||||
diagonal: {
|
||||
@ -223,8 +221,9 @@ class CharacterMoveService extends BaseService {
|
||||
return path
|
||||
}
|
||||
|
||||
public broadcastMovement(character: Character, isMoving: boolean): void {
|
||||
this.io.in(character.map.id).emit(SocketEvent.MAP_CHARACTER_MOVE, [character.id, character.getPositionX(), character.getPositionY(), character.getRotation(), isMoving])
|
||||
public broadcastMovement(character: Character, isMoving: boolean = false): void {
|
||||
const io: Server = SocketManager.getIO()
|
||||
io.in(character.map.id).emit(SocketEvent.MAP_CHARACTER_MOVE, [character.id, character.getPositionX(), character.getPositionY(), character.getRotation(), isMoving])
|
||||
}
|
||||
|
||||
public validateMovementDistance(
|
||||
|
@ -6,6 +6,7 @@ import MapManager from '@/managers/mapManager'
|
||||
import SocketManager from '@/managers/socketManager'
|
||||
import MapCharacter from '@/models/mapCharacter'
|
||||
import MapRepository from '@/repositories/mapRepository'
|
||||
import CharacterMoveService from '@/services/characterMoveService'
|
||||
|
||||
interface TeleportOptions {
|
||||
targetMapId: UUID
|
||||
@ -61,13 +62,7 @@ class CharacterTeleportService {
|
||||
// If the current map is the target map and we are not joining, send move event
|
||||
if (currentMapId === options.targetMapId && !options.isInitialJoin) {
|
||||
// If the current map is the target map, send move event
|
||||
io.in(currentMapId).emit(SocketEvent.MAP_CHARACTER_MOVE, {
|
||||
characterId: mapCharacter.character.id,
|
||||
positionX: options.targetX,
|
||||
positionY: options.targetY,
|
||||
rotation: options.rotation ?? 0,
|
||||
isMoving: false
|
||||
})
|
||||
CharacterMoveService.broadcastMovement(mapCharacter.character, false)
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user