forked from noxious/server
Small improvement teleports
This commit is contained in:
parent
f2dd1a2ffe
commit
1191e6bf55
@ -44,10 +44,6 @@ class MapManager {
|
|||||||
.find((char) => char.character.id === characterId) ?? null
|
.find((char) => char.character.id === characterId) ?? null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeCharacter(characterId: UUID): void {
|
|
||||||
Object.values(this.maps).forEach((map) => map.removeCharacter(characterId))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new MapManager()
|
export default new MapManager()
|
||||||
|
@ -39,7 +39,11 @@ class MapCharacter {
|
|||||||
|
|
||||||
// Leave map and remove from manager
|
// Leave map and remove from manager
|
||||||
socket.leave(this.character.map.id)
|
socket.leave(this.character.map.id)
|
||||||
MapManager.removeCharacter(this.character.id)
|
|
||||||
|
const map = MapManager.getMapById(this.character.map.id)
|
||||||
|
if (map) {
|
||||||
|
await map.removeCharacter(this.character.id)
|
||||||
|
}
|
||||||
|
|
||||||
// Notify map players
|
// Notify map players
|
||||||
io.in(this.character.map.id).emit(SocketEvent.MAP_CHARACTER_LEAVE, this.character.id)
|
io.in(this.character.map.id).emit(SocketEvent.MAP_CHARACTER_LEAVE, this.character.id)
|
||||||
|
@ -48,6 +48,7 @@ class CharacterTeleportService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const currentMapId = mapCharacter.character.map?.id
|
const currentMapId = mapCharacter.character.map?.id
|
||||||
|
const currentMap = MapManager.getMapById(currentMapId!)
|
||||||
const io = SocketManager.getIO()
|
const io = SocketManager.getIO()
|
||||||
|
|
||||||
// Update character position and map
|
// Update character position and map
|
||||||
@ -67,9 +68,9 @@ class CharacterTeleportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle current map cleanup
|
// Handle current map cleanup
|
||||||
if (currentMapId) {
|
if (currentMapId && currentMap) {
|
||||||
socket.leave(currentMapId)
|
socket.leave(currentMapId)
|
||||||
MapManager.removeCharacter(characterId)
|
await currentMap.removeCharacter(characterId)
|
||||||
io.in(currentMapId).emit(SocketEvent.MAP_CHARACTER_LEAVE, characterId)
|
io.in(currentMapId).emit(SocketEvent.MAP_CHARACTER_LEAVE, characterId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user