1
0
forked from noxious/client

Renamed zone > map

This commit is contained in:
2025-01-02 17:31:31 +01:00
parent 736ddddc54
commit 40c87f0ee3
65 changed files with 762 additions and 762 deletions

View File

@ -1,42 +1,42 @@
import type { Object, Tile, Zone, ZoneEffect, ZoneObject } from '@/application/types'
import type { Object, Tile, Map, MapEffect, PlacedMapObject } from '@/application/types'
import { useGameStore } from '@/stores/gameStore'
import { defineStore } from 'pinia'
export type TeleportSettings = {
toZoneId: number
toMapId: number
toPositionX: number
toPositionY: number
toRotation: number
}
export const useZoneEditorStore = defineStore('zoneEditor', {
export const useMapEditorStore = defineStore('mapEditor', {
state: () => {
return {
active: false,
zone: null as Zone | null,
map: null as Map | null,
tool: 'move',
drawMode: 'tile',
eraserMode: 'tile',
zoneList: [] as Zone[],
mapList: [] as Map[],
tileList: [] as Tile[],
objectList: [] as Object[],
selectedTile: '',
selectedObject: null as Object | null,
isTileListModalShown: false,
isObjectListModalShown: false,
isZoneListModalShown: false,
isCreateZoneModalShown: false,
isMapListModalShown: false,
isCreateMapModalShown: false,
isSettingsModalShown: false,
shouldClearTiles: false,
zoneSettings: {
mapSettings: {
name: '',
width: 0,
height: 0,
pvp: false,
zoneEffects: [] as ZoneEffect[]
mapEffects: [] as MapEffect[]
},
teleportSettings: {
toZoneId: 0,
toMapId: 0,
toPositionX: 0,
toPositionY: 0,
toRotation: 0
@ -46,29 +46,29 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
actions: {
toggleActive() {
const gameStore = useGameStore()
if (!this.active) gameStore.connection?.emit('zone:character:leave')
if (!this.active) gameStore.connection?.emit('map:character:leave')
if (this.active) this.reset()
this.active = !this.active
},
setZone(zone: Zone | null) {
this.zone = zone
setMap(map: Map | null) {
this.map = map
},
setZoneName(name: string) {
this.zoneSettings.name = name
setMapName(name: string) {
this.mapSettings.name = name
},
setZoneWidth(width: number) {
this.zoneSettings.width = width
setMapWidth(width: number) {
this.mapSettings.width = width
},
setZoneHeight(height: number) {
this.zoneSettings.height = height
setMapHeight(height: number) {
this.mapSettings.height = height
},
setZonePvp(pvp: boolean) {
if (!this.zone) return
this.zone.pvp = pvp
setMapPvp(pvp: boolean) {
if (!this.map) return
this.map.pvp = pvp
},
setZoneEffects(zoneEffects: ZoneEffect[]) {
if (!this.zone) return
this.zoneSettings.zoneEffects = zoneEffects
setMapEffects(mapEffects: MapEffect[]) {
if (!this.map) return
this.mapSettings.mapEffects = mapEffects
},
setTool(tool: string) {
this.tool = tool
@ -79,8 +79,8 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
setEraserMode(mode: string) {
this.eraserMode = mode
},
setZoneList(zones: Zone[]) {
this.zoneList = zones
setMapList(maps: Map[]) {
this.mapList = maps
},
setTileList(tiles: Tile[]) {
this.tileList = tiles
@ -97,12 +97,12 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
toggleSettingsModal() {
this.isSettingsModalShown = !this.isSettingsModalShown
},
toggleZoneListModal() {
this.isZoneListModalShown = !this.isZoneListModalShown
this.isCreateZoneModalShown = false
toggleMapListModal() {
this.isMapListModalShown = !this.isMapListModalShown
this.isCreateMapModalShown = false
},
toggleCreateZoneModal() {
this.isCreateZoneModalShown = !this.isCreateZoneModalShown
toggleCreateMapModal() {
this.isCreateMapModalShown = !this.isCreateMapModalShown
},
setTeleportSettings(teleportSettings: TeleportSettings) {
this.teleportSettings = teleportSettings
@ -114,9 +114,9 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
resetClearTilesFlag() {
this.shouldClearTiles = false
},
reset(resetZone = false) {
if (resetZone) this.zone = null
this.zoneList = []
reset(resetMap = false) {
if (resetMap) this.map = null
this.mapList = []
this.tileList = []
this.objectList = []
this.tool = 'move'
@ -126,8 +126,8 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
this.isTileListModalShown = false
this.isObjectListModalShown = false
this.isSettingsModalShown = false
this.isZoneListModalShown = false
this.isCreateZoneModalShown = false
this.isMapListModalShown = false
this.isCreateMapModalShown = false
this.shouldClearTiles = false
}
}

View File

@ -1,11 +1,11 @@
import type { Zone, ZoneCharacter } from '@/application/types'
import type { Map, MapCharacter } from '@/application/types'
import { defineStore } from 'pinia'
export const useZoneStore = defineStore('zone', {
export const useMapStore = defineStore('map', {
state: () => {
return {
zone: null as Zone | null,
characters: [] as ZoneCharacter[],
map: null as Map | null,
characters: [] as MapCharacter[],
characterLoaded: false
}
},
@ -16,21 +16,21 @@ export const useZoneStore = defineStore('zone', {
getCharacterCount: (state) => {
return state.characters.length
},
isZoneSet: (state) => {
return state.zone !== null
isMapSet: (state) => {
return state.map !== null
}
},
actions: {
setZone(zone: Zone | null) {
this.zone = zone
setMap(map: Map | null) {
this.map = map
},
setCharacters(characters: ZoneCharacter[]) {
setCharacters(characters: MapCharacter[]) {
this.characters = characters
},
addCharacter(character: ZoneCharacter) {
addCharacter(character: MapCharacter) {
this.characters.push(character)
},
updateCharacter(updatedCharacter: ZoneCharacter) {
updateCharacter(updatedCharacter: MapCharacter) {
const index = this.characters.findIndex((char) => char.character.id === updatedCharacter.character.id)
if (index !== -1) this.characters[index] = updatedCharacter
},
@ -50,7 +50,7 @@ export const useZoneStore = defineStore('zone', {
}
},
reset() {
this.zone = null
this.map = null
this.characters = []
this.characterLoaded = false
}