Editor partially started.
This commit is contained in:
@@ -4,7 +4,7 @@ from PyQt5.QtWidgets import QFileDialog, QMessageBox
|
||||
from PyQt5.QtCore import QTimer
|
||||
import os
|
||||
from editortool.map.chunk import Chunk
|
||||
from editortool.map.mapdefs import MAP_WIDTH, MAP_HEIGHT, MAP_DEPTH
|
||||
from editortool.map.mapdefs import MAP_WIDTH, MAP_HEIGHT, MAP_DEPTH, CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH
|
||||
import traceback
|
||||
|
||||
MAP_DEFAULT_PATH = os.path.join(os.path.dirname(__file__), '../../../assets/map/')
|
||||
@@ -139,4 +139,25 @@ class Map:
|
||||
|
||||
def draw(self):
|
||||
for chunk in self.chunks.values():
|
||||
chunk.draw()
|
||||
chunk.draw()
|
||||
|
||||
def getChunkAtWorldPos(self, x, y, z):
|
||||
chunkX = x // CHUNK_WIDTH
|
||||
chunkY = y // CHUNK_HEIGHT
|
||||
chunkZ = z // CHUNK_DEPTH
|
||||
for chunk in self.chunks.values():
|
||||
if chunk.x == chunkX and chunk.y == chunkY and chunk.z == chunkZ:
|
||||
return chunk
|
||||
return None
|
||||
|
||||
def getTileAtWorldPos(self, x, y, z):
|
||||
chunk = self.getChunkAtWorldPos(x, y, z)
|
||||
if not chunk:
|
||||
print("No chunk found at position:", (x, y, z))
|
||||
return None
|
||||
|
||||
tileX = x % CHUNK_WIDTH
|
||||
tileY = y % CHUNK_HEIGHT
|
||||
tileZ = z % CHUNK_DEPTH
|
||||
tileIndex = tileX + tileY * CHUNK_WIDTH + tileZ * CHUNK_WIDTH * CHUNK_HEIGHT
|
||||
return chunk.tiles.get(tileIndex)
|
||||
Reference in New Issue
Block a user