TS improvements
This commit is contained in:
parent
c1edf31ca0
commit
110fd4e608
@ -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
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user