forked from noxious/client
npm run format, moved some files for improved file structure, removed redundant logic
This commit is contained in:
@ -13,7 +13,7 @@ import { type MapCharacter } from '@/application/types'
|
||||
import CharacterHair from '@/components/game/character/partials/CharacterHair.vue'
|
||||
import ChatBubble from '@/components/game/character/partials/ChatBubble.vue'
|
||||
import HealthBar from '@/components/game/character/partials/HealthBar.vue'
|
||||
import { useCharacterSprite } from '@/composables/useCharacterSpriteComposable'
|
||||
import { useCharacterSpriteComposable } from '@/composables/useCharacterSpriteComposable'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useMapStore } from '@/stores/mapStore'
|
||||
import { Container, Sprite, useScene } from 'phavuer'
|
||||
@ -28,7 +28,7 @@ const gameStore = useGameStore()
|
||||
const mapStore = useMapStore()
|
||||
const scene = useScene()
|
||||
|
||||
const { characterContainer, characterSprite, currentPositionX, currentPositionY, isometricDepth, isFlippedX, updatePosition, calcDirection, updateSprite, initializeSprite, cleanup } = useCharacterSprite(scene, props.tilemap, props.mapCharacter)
|
||||
const { characterContainer, characterSprite, currentPositionX, currentPositionY, isometricDepth, isFlippedX, updatePosition, calcDirection, updateSprite, initializeSprite, cleanup } = useCharacterSpriteComposable(scene, props.tilemap, props.mapCharacter)
|
||||
|
||||
const handlePositionUpdate = (newValues: any, oldValues: any) => {
|
||||
if (!newValues) return
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { MapCharacter, Sprite as SpriteT } from '@/application/types'
|
||||
import { loadSpriteTextures } from '@/composables/gameComposable'
|
||||
import { loadSpriteTextures } from '@/services/textureService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { Image, useScene } from 'phavuer'
|
||||
import { computed } from 'vue'
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { MapCharacter, Sprite as SpriteT } from '@/application/types'
|
||||
import { loadSpriteTextures } from '@/composables/gameComposable'
|
||||
import { loadSpriteTextures } from '@/services/textureService'
|
||||
import { CharacterHairStorage, CharacterTypeStorage, SpriteStorage } from '@/storage/storages'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { Image, useScene } from 'phavuer'
|
||||
|
@ -3,13 +3,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { UUID } from '@/application/types'
|
||||
import Controls from '@/components/utilities/Controls.vue'
|
||||
import { createTileMap, createTileLayer, loadMapTilesIntoScene, setLayerTiles } from '@/composables/mapComposable'
|
||||
import { createTileLayer, createTileMap, loadTileTexturesFromMapTileArray, setLayerTiles } from '@/services/mapService'
|
||||
import { MapStorage } from '@/storage/storages'
|
||||
import { useMapStore } from '@/stores/mapStore'
|
||||
import { useScene } from 'phavuer'
|
||||
import { onBeforeUnmount, shallowRef } from 'vue'
|
||||
import type { UUID } from '@/application/types'
|
||||
|
||||
const emit = defineEmits(['tileMap:create'])
|
||||
const scene = useScene()
|
||||
@ -19,7 +19,7 @@ const mapStorage = new MapStorage()
|
||||
const tileMap = shallowRef<Phaser.Tilemaps.Tilemap>()
|
||||
const tileLayer = shallowRef<Phaser.Tilemaps.TilemapLayer>()
|
||||
|
||||
loadMapTilesIntoScene(mapStore.mapId as UUID, scene)
|
||||
loadTileTexturesFromMapTileArray(mapStore.mapId as UUID, scene)
|
||||
.then(() => mapStorage.get(mapStore.mapId))
|
||||
.then((mapData) => {
|
||||
if (!mapData || !mapData?.tiles) return
|
||||
|
@ -3,19 +3,20 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import config from '@/application/config'
|
||||
import type { PlacedMapObject, TextureData } from '@/application/types'
|
||||
import { loadTexture } from '@/composables/gameComposable'
|
||||
import { calculateIsometricDepth, tileToWorldXY } from '@/composables/mapComposable'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { calculateIsometricDepth, tileToWorldXY } from '@/services/mapService'
|
||||
import { loadTexture } from '@/services/textureService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { Image, useScene } from 'phavuer'
|
||||
import { computed, onMounted } from 'vue'
|
||||
import config from '@/application/config'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
|
||||
import Tilemap = Phaser.Tilemaps.Tilemap
|
||||
import TilemapLayer = Phaser.Tilemaps.TilemapLayer
|
||||
|
||||
const props = defineProps<{
|
||||
placedMapObject: PlacedMapObject,
|
||||
placedMapObject: PlacedMapObject
|
||||
tileMap: Tilemap
|
||||
tileMapLayer: TilemapLayer
|
||||
}>()
|
||||
@ -35,23 +36,23 @@ const imageProps = computed(() => ({
|
||||
originY: props.placedMapObject.mapObject.originY
|
||||
}))
|
||||
|
||||
function calculateObjectPlacement(mapObj: PlacedMapObject) : {x: number; y: number} {
|
||||
function calculateObjectPlacement(mapObj: PlacedMapObject): { x: number; y: number } {
|
||||
let position = tileToWorldXY(props.tileMapLayer, mapObj.positionX, mapObj.positionY)
|
||||
|
||||
return {
|
||||
x: position.worldPositionX - mapObj.mapObject.frameWidth/2,
|
||||
y: position.worldPositionY - mapObj.mapObject.frameHeight/2 + config.tile_size.height
|
||||
x: position.worldPositionX - mapObj.mapObject.frameWidth / 2,
|
||||
y: position.worldPositionY - mapObj.mapObject.frameHeight / 2 + config.tile_size.height
|
||||
}
|
||||
}
|
||||
|
||||
loadTexture(scene, {
|
||||
key: props.placedMapObject.mapObject.id,
|
||||
data: '/textures/map_objects/' + props.placedMapObject.mapObject.id + '.png',
|
||||
group: 'map_objects',
|
||||
updatedAt: props.placedMapObject.mapObject.updatedAt,
|
||||
frameWidth: props.placedMapObject.mapObject.frameWidth,
|
||||
frameHeight: props.placedMapObject.mapObject.frameHeight
|
||||
} as TextureData).catch((error) => {
|
||||
console.error('Error loading texture:', error)
|
||||
})
|
||||
key: props.placedMapObject.mapObject.id,
|
||||
data: '/textures/map_objects/' + props.placedMapObject.mapObject.id + '.png',
|
||||
group: 'map_objects',
|
||||
updatedAt: props.placedMapObject.mapObject.updatedAt,
|
||||
frameWidth: props.placedMapObject.mapObject.frameWidth,
|
||||
frameHeight: props.placedMapObject.mapObject.frameHeight
|
||||
} as TextureData).catch((error) => {
|
||||
console.error('Error loading texture:', error)
|
||||
})
|
||||
</script>
|
||||
|
@ -9,9 +9,9 @@ import MapEventTiles from '@/components/gameMaster/mapEditor/mapPartials/MapEven
|
||||
import MapTiles from '@/components/gameMaster/mapEditor/mapPartials/MapTiles.vue'
|
||||
import PlacedMapObjects from '@/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { createTileLayer, createTileMap } from '@/services/mapService'
|
||||
import { useScene } from 'phavuer'
|
||||
import { onBeforeUnmount, onMounted, onUnmounted, shallowRef, useTemplateRef } from 'vue'
|
||||
import { createTileLayer, createTileMap } from '@/composables/mapComposable'
|
||||
|
||||
const tileMap = shallowRef<Phaser.Tilemaps.Tilemap>()
|
||||
const tileMapLayer = shallowRef<Phaser.Tilemaps.TilemapLayer>()
|
||||
@ -52,7 +52,7 @@ function handlePointerDown(pointer: Phaser.Input.Pointer) {
|
||||
|
||||
function handleKeyDown(event: KeyboardEvent) {
|
||||
//CTRL+Y
|
||||
if (event.key === 'y' && event.ctrlKey ) {
|
||||
if (event.key === 'y' && event.ctrlKey) {
|
||||
mapTiles.value!.redo()
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ function handlePointerMove(pointer: Phaser.Input.Pointer) {
|
||||
}
|
||||
|
||||
function handlePointerUp(pointer: Phaser.Input.Pointer) {
|
||||
if (mapEditor.drawMode.value === 'tile' ) {
|
||||
if (mapEditor.drawMode.value === 'tile') {
|
||||
mapTiles.value?.finalizeCommand()
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
<script setup lang="ts">
|
||||
import { MapEventTileType, type MapEventTile, type Map as MapT, type UUID } from '@/application/types'
|
||||
import { uuidv4 } from '@/application/utilities'
|
||||
import { getTile, tileToWorldX, tileToWorldY } from '@/composables/mapComposable'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { getTile, tileToWorldX, tileToWorldY } from '@/services/mapService'
|
||||
import { Image, useScene } from 'phavuer'
|
||||
import { shallowRef } from 'vue'
|
||||
|
||||
|
@ -4,16 +4,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import Controls from '@/components/utilities/Controls.vue'
|
||||
import { createTileArray, getTile, placeTile, setLayerTiles } from '@/composables/mapComposable'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { TileStorage } from '@/storage/storages'
|
||||
import { createTileArray, getTile, placeTile, setLayerTiles } from '@/services/mapService'
|
||||
import { useScene } from 'phavuer'
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
|
||||
const emit = defineEmits(['tileMap:create'])
|
||||
const scene = useScene()
|
||||
const mapEditor = useMapEditorComposable()
|
||||
const tileStorage = new TileStorage()
|
||||
|
||||
defineExpose({ handlePointer, finalizeCommand, undo, redo })
|
||||
|
||||
@ -24,7 +21,7 @@ const props = defineProps<{
|
||||
|
||||
class EditorCommand {
|
||||
public operation: 'draw' | 'erase' = 'draw'
|
||||
public tileName: string = "blank_tile"
|
||||
public tileName: string = 'blank_tile'
|
||||
public affectedTiles: number[][]
|
||||
|
||||
constructor(operation: 'draw' | 'erase', tileName: string) {
|
||||
@ -139,7 +136,7 @@ function createCommandUpdate(x: number, y: number, tileName: string, operation:
|
||||
if (vec[0] === x && vec[1] === y) return
|
||||
}
|
||||
|
||||
currentCommand.affectedTiles.push([x,y])
|
||||
currentCommand.affectedTiles.push([x, y])
|
||||
}
|
||||
|
||||
function finalizeCommand() {
|
||||
@ -190,8 +187,8 @@ function updateMapTiles() {
|
||||
}
|
||||
|
||||
//Recursive Array Clone
|
||||
function cloneArray(arr: any[]) : any[] {
|
||||
return arr.map((item) => item instanceof Array ? cloneArray(item) : item)
|
||||
function cloneArray(arr: any[]): any[] {
|
||||
return arr.map((item) => (item instanceof Array ? cloneArray(item) : item))
|
||||
}
|
||||
|
||||
watch(
|
||||
@ -206,17 +203,6 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
// Then overlay the map tiles, but only within the current map dimensions
|
||||
function replaceTiles(originalTiles: string[][], mapTiles: string[][], width: number, height: number) {
|
||||
for (let y = 0; y < height; y++) {
|
||||
for (let x = 0; x < width; x++) {
|
||||
if (mapTiles[y] && mapTiles[y][x] !== undefined) {
|
||||
originalTiles[y][x] = mapTiles[y][x]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
if (!mapEditor.currentMap.value) return
|
||||
const mapState = mapEditor.currentMap.value
|
||||
@ -226,5 +212,4 @@ onMounted(async () => {
|
||||
|
||||
setLayerTiles(props.tileMap, props.tileMapLayer, mapState.tiles)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
@ -9,8 +9,9 @@ import { uuidv4 } from '@/application/utilities'
|
||||
import PlacedMapObject from '@/components/game/map/partials/PlacedMapObject.vue'
|
||||
import SelectedPlacedMapObjectComponent from '@/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { getTile } from '@/services/mapService'
|
||||
import { useScene } from 'phavuer'
|
||||
import { getTile } from '@/composables/mapComposable'
|
||||
|
||||
import Tilemap = Phaser.Tilemaps.Tilemap
|
||||
import TilemapLayer = Phaser.Tilemaps.TilemapLayer
|
||||
|
||||
@ -20,7 +21,7 @@ const mapEditor = useMapEditorComposable()
|
||||
defineExpose({ handlePointer })
|
||||
|
||||
const props = defineProps<{
|
||||
tileMap: Tilemap,
|
||||
tileMap: Tilemap
|
||||
tileMapLayer: TilemapLayer
|
||||
}>()
|
||||
|
||||
@ -58,7 +59,7 @@ function eraser(pointer: Phaser.Input.Pointer, map: MapT) {
|
||||
map.placedMapObjects = map.placedMapObjects.filter((placedMapObject) => placedMapObject.id !== existingPlacedMapObject.id)
|
||||
}
|
||||
|
||||
function findObjectByPointer(pointer: Phaser.Input.Pointer, map: MapT) : PlacedMapObjectT | undefined {
|
||||
function findObjectByPointer(pointer: Phaser.Input.Pointer, map: MapT): PlacedMapObjectT | undefined {
|
||||
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
|
||||
if (!tile) return undefined
|
||||
|
||||
@ -136,5 +137,4 @@ function handlePointer(pointer: Phaser.Input.Pointer) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -60,7 +60,7 @@ const modalRef = useTemplateRef('modalRef')
|
||||
defineExpose({
|
||||
open: () => modalRef.value?.open(),
|
||||
close: () => modalRef.value?.close(),
|
||||
getModal: () => modalRef.value,
|
||||
getModal: () => modalRef.value
|
||||
})
|
||||
|
||||
const uniqueTags = computed(() => {
|
||||
|
@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<label class="mr-4" for="pvp">PVP enabled</label>
|
||||
<input type="checkbox" v-model="pvp" @input="updateValue" class="input-field scale-125" name="pvp" id="pvp"/>
|
||||
<input type="checkbox" v-model="pvp" @input="updateValue" class="input-field scale-125" name="pvp" id="pvp" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -53,7 +53,7 @@ import { onMounted, ref, useTemplateRef, watch } from 'vue'
|
||||
const mapEditor = useMapEditorComposable()
|
||||
const screen = ref('settings')
|
||||
|
||||
const name = ref<string | undefined>("Map")
|
||||
const name = ref<string | undefined>('Map')
|
||||
const width = ref<number>(0)
|
||||
const height = ref<number>(0)
|
||||
const pvp = ref<boolean>(false)
|
||||
@ -69,14 +69,17 @@ function updateValue(event: Event) {
|
||||
mapEditor.updateProperty(ev.name as 'name' | 'width' | 'height' | 'pvp' | 'mapEffects', ev.value)
|
||||
}
|
||||
|
||||
watch(() => mapEditor.currentMap.value, (map) => {
|
||||
if (!map) return
|
||||
name.value = map.name
|
||||
width.value = map.width
|
||||
height.value = map.height
|
||||
pvp.value = map.pvp
|
||||
mapEffects.value = map.mapEffects
|
||||
})
|
||||
watch(
|
||||
() => mapEditor.currentMap.value,
|
||||
(map) => {
|
||||
if (!map) return
|
||||
name.value = map.name
|
||||
width.value = map.width
|
||||
height.value = map.height
|
||||
pvp.value = map.pvp
|
||||
mapEffects.value = map.mapEffects
|
||||
}
|
||||
)
|
||||
|
||||
const addEffect = () => {
|
||||
mapEffects.value.push({
|
||||
@ -92,5 +95,4 @@ const removeEffect = (index: number) => {
|
||||
mapEffects.value.splice(index, 1)
|
||||
mapEditor.updateProperty('mapEffects', mapEffects.value)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -101,7 +101,7 @@ const modalRef = useTemplateRef('modalRef')
|
||||
defineExpose({
|
||||
open: () => modalRef.value?.open(),
|
||||
close: () => modalRef.value?.close(),
|
||||
getModal: () => modalRef.value,
|
||||
getModal: () => modalRef.value
|
||||
})
|
||||
|
||||
const uniqueTags = computed(() => {
|
||||
|
@ -73,7 +73,7 @@
|
||||
<div class="w-px bg-cyan"></div>
|
||||
|
||||
<label class="my-auto gap-0" for="checkbox">Continuous Drawing</label>
|
||||
<input @change="handleCheck" v-model="checkboxValue" type="checkbox"/>
|
||||
<input @change="handleCheck" v-model="checkboxValue" type="checkbox" />
|
||||
</div>
|
||||
|
||||
<div class="toolbar fixed bottom-0 right-0 m-3 rounded flex bg-gray solid border-solid border-2 border-gray-500 text-gray-300 p-1.5 px-3 h-10 space-x-2">
|
||||
|
@ -26,7 +26,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { login } from '@/services/authentication'
|
||||
import { login } from '@/services/authenticationService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useCookies } from '@vueuse/integrations/useCookies'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
@ -22,7 +22,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { newPassword } from '@/services/authentication'
|
||||
import { newPassword } from '@/services/authenticationService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useCookies } from '@vueuse/integrations/useCookies'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
@ -26,7 +26,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { login, register } from '@/services/authentication'
|
||||
import { login, register } from '@/services/authenticationService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useCookies } from '@vueuse/integrations/useCookies'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import { resetPassword } from '@/services/authentication'
|
||||
import { resetPassword } from '@/services/authenticationService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { ref } from 'vue'
|
||||
|
||||
|
@ -39,24 +39,21 @@ import MapSettings from '@/components/gameMaster/mapEditor/partials/MapSettings.
|
||||
import TeleportModal from '@/components/gameMaster/mapEditor/partials/TeleportModal.vue'
|
||||
import TileList from '@/components/gameMaster/mapEditor/partials/TileList.vue'
|
||||
import Toolbar from '@/components/gameMaster/mapEditor/partials/Toolbar.vue'
|
||||
import { loadAllTilesIntoScene } from '@/composables/mapComposable'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { MapObjectStorage, MapStorage } from '@/storage/storages'
|
||||
import { loadAllTileTextures } from '@/services/mapService'
|
||||
import { MapStorage } from '@/storage/storages'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { Game, Scene } from 'phavuer'
|
||||
import { ref, useTemplateRef, watch } from 'vue'
|
||||
import { ref, useTemplateRef } from 'vue'
|
||||
|
||||
const mapStorage = new MapStorage()
|
||||
const mapObjectStorage = new MapObjectStorage()
|
||||
const mapEditor = useMapEditorComposable()
|
||||
const gameStore = useGameStore()
|
||||
|
||||
const toolbar = useTemplateRef('toolbar')
|
||||
const mapModal = useTemplateRef('mapModal')
|
||||
const tileList = useTemplateRef('tileList')
|
||||
const objectList = useTemplateRef('objectList')
|
||||
const mapSettingsModal = useTemplateRef('mapSettingsModal')
|
||||
const teleportModal = useTemplateRef('teleportModal')
|
||||
|
||||
const isLoaded = ref(false)
|
||||
|
||||
@ -83,7 +80,7 @@ const preloadScene = async (scene: Phaser.Scene) => {
|
||||
scene.load.image('waypoint', '/assets/waypoint.png')
|
||||
|
||||
// Get all tiles from IndexedDB and load them into the scene
|
||||
await loadAllTilesIntoScene(scene)
|
||||
await loadAllTileTextures(scene)
|
||||
|
||||
// Wait for all assets to be loaded before continuing
|
||||
await new Promise<void>((resolve) => {
|
||||
@ -98,7 +95,6 @@ function save() {
|
||||
const currentMap = mapEditor.currentMap.value
|
||||
if (!currentMap) return
|
||||
|
||||
console.log(currentMap.tiles)
|
||||
const data = {
|
||||
mapId: currentMap.id,
|
||||
name: currentMap.name,
|
||||
@ -108,7 +104,7 @@ function save() {
|
||||
pvp: currentMap.pvp,
|
||||
mapEffects: currentMap.mapEffects,
|
||||
mapEventTiles: currentMap.mapEventTiles,
|
||||
placedMapObjects: currentMap.placedMapObjects.map(({ id, mapObject, depth, isRotated, positionX, positionY }) => ({ id, mapObject: {...mapObject}, depth, isRotated, positionX, positionY })) ?? []
|
||||
placedMapObjects: currentMap.placedMapObjects.map(({ id, mapObject, depth, isRotated, positionX, positionY }) => ({ id, mapObject: { ...mapObject }, depth, isRotated, positionX, positionY })) ?? []
|
||||
}
|
||||
|
||||
gameStore.connection?.emit('gm:map:update', data, (response: MapT) => {
|
||||
@ -116,13 +112,6 @@ function save() {
|
||||
})
|
||||
}
|
||||
|
||||
function closeLists() {
|
||||
tileList.value?.getModal()?.setPosition(window.innerWidth-650,6)
|
||||
tileList.value?.close()
|
||||
objectList.value?.getModal()?.setPosition(window.innerWidth-650,6)
|
||||
objectList.value?.close()
|
||||
}
|
||||
|
||||
function clear() {
|
||||
if (!mapEditor.currentMap.value) return
|
||||
|
||||
|
@ -87,7 +87,10 @@ defineExpose({
|
||||
open: () => (isModalOpenRef.value = true),
|
||||
close: () => (isModalOpenRef.value = false),
|
||||
toggle: () => (isModalOpenRef.value = !isModalOpenRef.value),
|
||||
setPosition: (a: number, b: number) => { x.value = a; y.value = b}
|
||||
setPosition: (a: number, b: number) => {
|
||||
x.value = a
|
||||
y.value = b
|
||||
}
|
||||
})
|
||||
|
||||
const isModalOpenRef = ref(props.isModalOpen)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import config from '@/application/config'
|
||||
import { getTile, tileToWorldXY } from '@/composables/mapComposable'
|
||||
import { getTile, tileToWorldXY } from '@/services/mapService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { ref, type Ref } from 'vue'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getTile } from '@/composables/mapComposable'
|
||||
import { getTile } from '@/services/mapService'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import type { Ref } from 'vue'
|
||||
import { useBaseControlsComposable } from './useBaseControlsComposable'
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Direction } from '@/application/enums'
|
||||
import { type MapCharacter } from '@/application/types'
|
||||
import { loadSpriteTextures } from '@/composables/gameComposable'
|
||||
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/mapComposable'
|
||||
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/services/mapService'
|
||||
import { loadSpriteTextures } from '@/services/textureService'
|
||||
import { CharacterTypeStorage } from '@/storage/storages'
|
||||
import { refObj } from 'phavuer'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
export function useCharacterSprite(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, mapCharacter: MapCharacter) {
|
||||
export function useCharacterSpriteComposable(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, mapCharacter: MapCharacter) {
|
||||
const characterContainer = refObj<Phaser.GameObjects.Container>()
|
||||
const characterSpriteId = ref('')
|
||||
const characterSprite = refObj<Phaser.GameObjects.Sprite>()
|
||||
|
@ -1,7 +1,7 @@
|
||||
import config from '@/application/config';
|
||||
import type { Map as MapT, TextureData, Tile as TileT, UUID } from '@/application/types';
|
||||
import { unduplicateArray } from '@/application/utilities';
|
||||
import { loadTexture } from '@/composables/gameComposable';
|
||||
import config from '@/application/config'
|
||||
import type { Map as MapT, TextureData, Tile as TileT, UUID } from '@/application/types'
|
||||
import { unduplicateArray } from '@/application/utilities'
|
||||
import { loadTexture } from '@/services/textureService'
|
||||
import { MapStorage, TileStorage } from '@/storage/storages'
|
||||
|
||||
import Tilemap = Phaser.Tilemaps.Tilemap
|
||||
@ -75,7 +75,7 @@ export const calculateIsometricDepth = (positionX: number, positionY: number, wi
|
||||
return baseDepth + (width + height) / 4
|
||||
}
|
||||
|
||||
async function getTiles(tiles: TileT[], scene: Phaser.Scene) {
|
||||
async function loadTileTextures(tiles: TileT[], scene: Phaser.Scene) {
|
||||
// Load each tile into the scene
|
||||
for (const tile of tiles) {
|
||||
if (!tile) continue
|
||||
@ -89,7 +89,7 @@ async function getTiles(tiles: TileT[], scene: Phaser.Scene) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadMapTilesIntoScene(map_id: UUID, scene: Phaser.Scene) {
|
||||
export async function loadTileTexturesFromMapTileArray(map_id: UUID, scene: Phaser.Scene) {
|
||||
const tileStorage = new TileStorage()
|
||||
const mapStorage = new MapStorage()
|
||||
const map = await mapStorage.get(map_id)
|
||||
@ -98,21 +98,21 @@ export async function loadMapTilesIntoScene(map_id: UUID, scene: Phaser.Scene) {
|
||||
const tileArray = unduplicateArray(map.tiles)
|
||||
const tiles = await tileStorage.getByIds(tileArray)
|
||||
|
||||
await getTiles(tiles, scene)
|
||||
await loadTileTextures(tiles, scene)
|
||||
}
|
||||
|
||||
export async function loadTilesIntoScene(tileIds: string[], scene: Phaser.Scene) {
|
||||
export async function loadTileTexturesFromTileIds(tileIds: string[], scene: Phaser.Scene) {
|
||||
const tileStorage = new TileStorage()
|
||||
const tiles = await tileStorage.getByIds(tileIds)
|
||||
|
||||
await getTiles(tiles, scene)
|
||||
await loadTileTextures(tiles, scene)
|
||||
}
|
||||
|
||||
export async function loadAllTilesIntoScene(scene: Phaser.Scene) {
|
||||
export async function loadAllTileTextures(scene: Phaser.Scene) {
|
||||
const tileStorage = new TileStorage()
|
||||
const tiles = await tileStorage.getAll()
|
||||
|
||||
await getTiles(tiles, scene)
|
||||
await loadTileTextures(tiles, scene)
|
||||
}
|
||||
|
||||
export function createTileMap(scene: Phaser.Scene, map: MapT) {
|
||||
@ -143,4 +143,4 @@ export function createTileLayer(currentTileMap: Phaser.Tilemaps.Tilemap, mapData
|
||||
layer.setDepth(0)
|
||||
layer.setCullPadding(2, 2)
|
||||
return layer
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user