forked from noxious/client
Added depth logics for objects
This commit is contained in:
parent
abe58961ba
commit
c4c12179b8
@ -17,8 +17,8 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="mb-1.5 font-titles hidden" for="z-index">Z-index</label>
|
<label class="mb-1.5 font-titles hidden" for="depth">Depth</label>
|
||||||
<input @mousedown.stop class="input-cyan" type="number" name="z-index" placeholder="Z-index" />
|
<input v-model="objectDepth" @mousedown.stop class="input-cyan" type="number" name="depth" placeholder="Depth" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted, computed, watch } from 'vue'
|
||||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||||
import { useSocketStore } from '@/stores/socket'
|
import { useSocketStore } from '@/stores/socket'
|
||||||
import Modal from '@/components/utilities/Modal.vue'
|
import Modal from '@/components/utilities/Modal.vue'
|
||||||
@ -58,6 +58,11 @@ const socket = useSocketStore()
|
|||||||
const isModalOpen = ref(false)
|
const isModalOpen = ref(false)
|
||||||
const zoneEditorStore = useZoneEditorStore()
|
const zoneEditorStore = useZoneEditorStore()
|
||||||
const searchQuery = ref('')
|
const searchQuery = ref('')
|
||||||
|
const objectDepth = ref(0)
|
||||||
|
|
||||||
|
watch(objectDepth, (depth) => {
|
||||||
|
zoneEditorStore.setObjectDepth(depth)
|
||||||
|
})
|
||||||
|
|
||||||
const filteredObjects = computed(() => {
|
const filteredObjects = computed(() => {
|
||||||
if (!searchQuery.value) {
|
if (!searchQuery.value) {
|
||||||
@ -69,6 +74,8 @@ const filteredObjects = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
zoneEditorStore.setObjectDepth(0)
|
||||||
|
|
||||||
isModalOpen.value = true
|
isModalOpen.value = true
|
||||||
socket.connection.emit('gm:object:list', {}, (response: Object[]) => {
|
socket.connection.emit('gm:object:list', {}, (response: Object[]) => {
|
||||||
zoneEditorStore.setObjectList(response)
|
zoneEditorStore.setObjectList(response)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<Controls :layer="tiles" />
|
<Controls :layer="tiles" />
|
||||||
|
|
||||||
<Container :depth="2">
|
<Container :depth="2">
|
||||||
<Image v-for="object in zoneObjects" :key="object.object.id" :x="tileToWorldX(zoneTilemap, object.position_x, object.position_y)" :y="tileToWorldY(zoneTilemap, object.position_x, object.position_y)" :texture="object.object.id" :originY="Number(object.object.origin_x)" :originX="Number(object.object.origin_y)" />
|
<Image v-for="object in zoneObjects" :depth="object.depth" :key="object.object.id" :x="tileToWorldX(zoneTilemap, object.position_x, object.position_y)" :y="tileToWorldY(zoneTilemap, object.position_x, object.position_y)" :texture="object.object.id" :originY="Number(object.object.origin_x)" :originX="Number(object.object.origin_y)" />
|
||||||
</Container>
|
</Container>
|
||||||
|
|
||||||
<Container :depth="3">
|
<Container :depth="3">
|
||||||
@ -122,6 +122,7 @@ function pencil(tile: Phaser.Tilemaps.Tile) {
|
|||||||
zone: zoneEditorStore.zone,
|
zone: zoneEditorStore.zone,
|
||||||
objectId: zoneEditorStore.selectedObject.id,
|
objectId: zoneEditorStore.selectedObject.id,
|
||||||
object: zoneEditorStore.selectedObject,
|
object: zoneEditorStore.selectedObject,
|
||||||
|
depth: zoneEditorStore.objectDepth,
|
||||||
position_x: tile.x,
|
position_x: tile.x,
|
||||||
position_y: tile.y
|
position_y: tile.y
|
||||||
})
|
})
|
||||||
|
@ -11,6 +11,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
objectList: [] as Object[],
|
objectList: [] as Object[],
|
||||||
selectedTile: '',
|
selectedTile: '',
|
||||||
selectedObject: null as Object | null,
|
selectedObject: null as Object | null,
|
||||||
|
objectDepth: 0,
|
||||||
isZoneListModalShown: false,
|
isZoneListModalShown: false,
|
||||||
isCreateZoneModalShown: false,
|
isCreateZoneModalShown: false,
|
||||||
isSettingsModalShown: false
|
isSettingsModalShown: false
|
||||||
@ -40,6 +41,9 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
setSelectedObject(object: any) {
|
setSelectedObject(object: any) {
|
||||||
this.selectedObject = object
|
this.selectedObject = object
|
||||||
},
|
},
|
||||||
|
setObjectDepth(depth: number) {
|
||||||
|
this.objectDepth = depth
|
||||||
|
},
|
||||||
toggleSettingsModal() {
|
toggleSettingsModal() {
|
||||||
this.isSettingsModalShown = !this.isSettingsModalShown
|
this.isSettingsModalShown = !this.isSettingsModalShown
|
||||||
},
|
},
|
||||||
@ -57,6 +61,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
this.drawMode = 'tile'
|
this.drawMode = 'tile'
|
||||||
this.selectedTile = ''
|
this.selectedTile = ''
|
||||||
this.selectedObject = null
|
this.selectedObject = null
|
||||||
|
this.objectDepth = 0
|
||||||
this.isSettingsModalShown = false
|
this.isSettingsModalShown = false
|
||||||
this.isZoneListModalShown = false
|
this.isZoneListModalShown = false
|
||||||
this.isCreateZoneModalShown = false
|
this.isCreateZoneModalShown = false
|
||||||
|
@ -90,6 +90,7 @@ export type ZoneObject = {
|
|||||||
zone: Zone
|
zone: Zone
|
||||||
objectId: string
|
objectId: string
|
||||||
object: Object
|
object: Object
|
||||||
|
depth: number
|
||||||
position_x: number
|
position_x: number
|
||||||
position_y: number
|
position_y: number
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user