1
0
forked from noxious/client

Removed redundant code , refactor event tile code

This commit is contained in:
2024-10-18 02:48:27 +02:00
parent c6869f47b1
commit 9d774bcb18
5 changed files with 84 additions and 21 deletions

View File

@ -48,16 +48,16 @@ function addZoneObject(pointer: Phaser.Input.Pointer) {
// Check if draw mode is object
if (zoneEditorStore.drawMode !== 'object') return
// Check if there is a selected object
if (!zoneEditorStore.selectedObject) return
// Check if left mouse button is pressed
if (!pointer.isDown) return
// Check if there is a tile @TODO chekc if props.tilemap words
// Check if there is a tile
const tile = getTile(props.tilemap, pointer.worldX, pointer.worldY)
if (!tile) return
// Check if there is a selected object
if (!zoneEditorStore.selectedObject) return
// Check if object already exists on position
const existingObject = zoneEditorStore.zone?.zoneObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y)
if (existingObject) return