forked from noxious/server
Started improving character move event
This commit is contained in:
@ -23,8 +23,7 @@ export class CharacterService {
|
||||
if (!user) return null
|
||||
|
||||
const character = new Character()
|
||||
character.name = name
|
||||
character.user = user
|
||||
character.setName(name).setUser(user)
|
||||
|
||||
return await character.save()
|
||||
}
|
||||
@ -34,12 +33,12 @@ export class CharacterService {
|
||||
if (!character) return null
|
||||
|
||||
if (characterHairId === null) {
|
||||
character.characterHair = undefined
|
||||
character.setCharacterHair(undefined)
|
||||
return await character.save()
|
||||
}
|
||||
|
||||
const characterHair = await CharacterHairRepository.getById(characterHairId)
|
||||
character.characterHair = characterHair ?? undefined
|
||||
character.setCharacterHair(characterHair ?? undefined)
|
||||
|
||||
return await character.save()
|
||||
}
|
||||
@ -61,10 +60,11 @@ export class CharacterService {
|
||||
const character = await CharacterRepository.getById(id)
|
||||
if (!character) return null
|
||||
|
||||
character.positionX = positionX
|
||||
character.positionY = positionY
|
||||
character.rotation = rotation
|
||||
character.zone = (await ZoneRepository.getById(zoneId)) as Zone
|
||||
character
|
||||
.setPositionX(positionX)
|
||||
.setPositionY(positionY)
|
||||
.setRotation(rotation)
|
||||
.setZone((await ZoneRepository.getById(zoneId)) as Zone)
|
||||
|
||||
await character.save()
|
||||
|
||||
@ -80,12 +80,12 @@ export class CharacterService {
|
||||
positionX: position.x,
|
||||
positionY: position.y,
|
||||
rotation: Rotation.calculate(character.positionX, character.positionY, position.x, position.y),
|
||||
zoneId: newZoneId ?? character.zone.id
|
||||
zoneId: newZoneId ?? character.zone!.id
|
||||
})
|
||||
}
|
||||
|
||||
public async calculatePath(character: Character, targetX: number, targetY: number): Promise<Position[] | null> {
|
||||
const zone = ZoneManager.getZoneById(character.zone.id)
|
||||
const zone = ZoneManager.getZoneById(character.zone!.id)
|
||||
const grid = await zone?.getGrid()
|
||||
|
||||
if (!grid?.length) {
|
||||
|
Reference in New Issue
Block a user