Teleport fix
This commit is contained in:
parent
74f5214ca3
commit
0ba79c2299
@ -55,7 +55,7 @@ export default class CharacterMove extends BaseEvent {
|
|||||||
if (mapEventTile?.type === 'BLOCK') break
|
if (mapEventTile?.type === 'BLOCK') break
|
||||||
if (mapEventTile?.type === 'TELEPORT' && mapEventTile.teleport) {
|
if (mapEventTile?.type === 'TELEPORT' && mapEventTile.teleport) {
|
||||||
await this.handleMapEventTile(mapEventTile as MapEventTileWithTeleport)
|
await this.handleMapEventTile(mapEventTile as MapEventTileWithTeleport)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update position first
|
// Update position first
|
||||||
|
@ -48,13 +48,6 @@ class TeleportService {
|
|||||||
const currentMapId = mapCharacter.character.map?.id
|
const currentMapId = mapCharacter.character.map?.id
|
||||||
const io = SocketManager.getIO()
|
const io = SocketManager.getIO()
|
||||||
|
|
||||||
// Handle current map cleanup
|
|
||||||
if (currentMapId) {
|
|
||||||
socket.leave(currentMapId)
|
|
||||||
MapManager.removeCharacter(characterId)
|
|
||||||
io.in(currentMapId).emit('map:character:leave', characterId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update character position and map
|
// Update character position and map
|
||||||
await mapCharacter
|
await mapCharacter
|
||||||
.getCharacter()
|
.getCharacter()
|
||||||
@ -64,6 +57,26 @@ class TeleportService {
|
|||||||
.setMap(targetMap.getMap())
|
.setMap(targetMap.getMap())
|
||||||
.save()
|
.save()
|
||||||
|
|
||||||
|
// 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('map:character:move', {
|
||||||
|
characterId: mapCharacter.character.id,
|
||||||
|
positionX: options.targetX,
|
||||||
|
positionY: options.targetY,
|
||||||
|
rotation: options.rotation ?? 0,
|
||||||
|
isMoving: false
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle current map cleanup
|
||||||
|
if (currentMapId) {
|
||||||
|
socket.leave(currentMapId)
|
||||||
|
MapManager.removeCharacter(characterId)
|
||||||
|
io.in(currentMapId).emit('map:character:leave', characterId)
|
||||||
|
}
|
||||||
|
|
||||||
// Join new map
|
// Join new map
|
||||||
socket.join(options.targetMapId)
|
socket.join(options.targetMapId)
|
||||||
targetMap.addCharacter(mapCharacter.getCharacter())
|
targetMap.addCharacter(mapCharacter.getCharacter())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user