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 = { export type MapEventTile = {
id: string id: string
mapid: string mapId: string
type: MapEventTileType type: MapEventTileType
positionX: number positionX: number
positionY: 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) { if (!currentCommand) {
currentCommand = new EventTileCommand(operation) currentCommand = new EventTileCommand(operation)
} }
@ -106,9 +108,9 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
: undefined : 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) { function erase(pointer: Phaser.Input.Pointer, map: MapT) {
@ -149,7 +151,7 @@ function handlePointer(pointer: Phaser.Input.Pointer) {
} }
function clearTiles() { function clearTiles() {
if (mapEditor.currentMap.value.mapEventTiles.length === 0) return if (mapEditor.currentMap.value?.mapEventTiles.length === 0) return
createCommandUpdate(null, 'clear') createCommandUpdate(null, 'clear')
finalizeCommand() finalizeCommand()
} }