Minor improvements
This commit is contained in:
parent
9baffd1327
commit
ba96ae7dd4
@ -27,19 +27,19 @@ export default class MapObjectUpdateEvent extends BaseEvent {
|
|||||||
const mapObject = await mapObjectRepository.getById(data.id)
|
const mapObject = await mapObjectRepository.getById(data.id)
|
||||||
if (!mapObject) return callback(false)
|
if (!mapObject) return callback(false)
|
||||||
|
|
||||||
await mapObject
|
if (data.name !== undefined) mapObject.name = data.name
|
||||||
.setName(data.name)
|
if (data.tags !== undefined) mapObject.tags = data.tags
|
||||||
.setTags(data.tags)
|
if (data.originX !== undefined) mapObject.originX = data.originX
|
||||||
.setOriginX(data.originX)
|
if (data.originY !== undefined) mapObject.originY = data.originY
|
||||||
.setOriginY(data.originY)
|
if (data.frameRate !== undefined) mapObject.frameRate = data.frameRate
|
||||||
.setFrameRate(data.frameRate)
|
if (data.frameWidth !== undefined) mapObject.frameWidth = data.frameWidth
|
||||||
.setFrameWidth(data.frameWidth)
|
if (data.frameHeight !== undefined) mapObject.frameHeight = data.frameHeight
|
||||||
.setFrameHeight(data.frameHeight)
|
|
||||||
.save()
|
await mapObject.save()
|
||||||
|
|
||||||
return callback(true)
|
return callback(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
this.socket.emit('notification', { title: 'Error', message: 'Failed to update mapObject.' })
|
||||||
return callback(false)
|
return callback(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ export default class CharacterMove extends BaseEvent {
|
|||||||
// If already moving, cancel current movement and wait for it to fully stop
|
// If already moving, cancel current movement and wait for it to fully stop
|
||||||
if (mapCharacter.isMoving) {
|
if (mapCharacter.isMoving) {
|
||||||
mapCharacter.isMoving = false
|
mapCharacter.isMoving = false
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100))
|
mapCharacter.currentPath = null
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = await this.characterService.calculatePath(mapCharacter.character, positionX, positionY)
|
const path = await this.characterService.calculatePath(mapCharacter.character, positionX, positionY)
|
||||||
|
@ -29,6 +29,7 @@ class CharacterMoveService extends BaseService {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure we're working with valid coordinates
|
||||||
const start: Position = {
|
const start: Position = {
|
||||||
positionX: Math.floor(character.positionX),
|
positionX: Math.floor(character.positionX),
|
||||||
positionY: Math.floor(character.positionY)
|
positionY: Math.floor(character.positionY)
|
||||||
@ -39,6 +40,11 @@ class CharacterMoveService extends BaseService {
|
|||||||
positionY: Math.floor(targetY)
|
positionY: Math.floor(targetY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't calculate path if start and end are the same
|
||||||
|
if (start.positionX === end.positionX && start.positionY === end.positionY) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return this.findPath(start, end, grid)
|
return this.findPath(start, end, grid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user