1
0
forked from noxious/client

TS improvements

This commit is contained in:
Dennis Postma 2025-02-14 02:49:14 +01:00
parent c1edf31ca0
commit 110fd4e608
2 changed files with 7 additions and 5 deletions

View File

@ -100,7 +100,7 @@ export enum MapEventTileType {
export type MapEventTile = {
id: string
mapid: string
mapId: string
type: MapEventTileType
positionX: number
positionY: number

View File

@ -46,7 +46,9 @@ class EventTileCommand implements EditorCommand {
}
}
function createCommandUpdate(tile?: MapEventTile, operation: 'draw' | 'erase' | 'clear') {
function createCommandUpdate(tile?: MapEventTile | null, operation: 'draw' | 'erase' | 'clear' = 'draw') {
if (!tile) return
if (!currentCommand) {
currentCommand = new EventTileCommand(operation)
}
@ -106,9 +108,9 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
: undefined
}
createCommandUpdate(newEventTile, 'draw')
createCommandUpdate(newEventTile as MapEventTile, 'draw')
map.mapEventTiles.push(newEventTile)
map.mapEventTiles.push(newEventTile as MapEventTile)
}
function erase(pointer: Phaser.Input.Pointer, map: MapT) {
@ -149,7 +151,7 @@ function handlePointer(pointer: Phaser.Input.Pointer) {
}
function clearTiles() {
if (mapEditor.currentMap.value.mapEventTiles.length === 0) return
if (mapEditor.currentMap.value?.mapEventTiles.length === 0) return
createCommandUpdate(null, 'clear')
finalizeCommand()
}