Trying to find entity editor bug
This commit is contained in:
@@ -36,6 +36,7 @@ class Chunk:
|
||||
self.x = newX
|
||||
self.y = newY
|
||||
self.z = newZ
|
||||
self.entities = {}
|
||||
for tile in self.tiles.values():
|
||||
tile.chunkReload(newX, newY, newZ)
|
||||
self.load()
|
||||
|
||||
@@ -5,9 +5,12 @@ class Entity:
|
||||
def __init__(self, chunk, localX=0, localY=0, localZ=0):
|
||||
self.type = ENTITY_TYPE_NPC
|
||||
self.name = "Unititled"
|
||||
self.localX = localX
|
||||
self.localY = localY
|
||||
self.localZ = localZ
|
||||
self.localX = localX % CHUNK_WIDTH
|
||||
self.localY = localY % CHUNK_HEIGHT
|
||||
self.localZ = localZ % CHUNK_DEPTH
|
||||
|
||||
print(f"Raw localX: {localX}, adjusted localX: {self.localX}")
|
||||
|
||||
self.chunk = chunk
|
||||
self.vertexBuffer = VertexBuffer()
|
||||
pass
|
||||
|
||||
@@ -46,10 +46,13 @@ class Map:
|
||||
config = json.load(f)
|
||||
lastFile = config.get('lastFile')
|
||||
lastPosition = config.get('lastPosition')
|
||||
leftPanelIndex = config.get('leftPanelIndex')
|
||||
if lastFile and os.path.exists(lastFile):
|
||||
self.load(lastFile)
|
||||
if lastPosition and isinstance(lastPosition, list) and len(lastPosition) == 3:
|
||||
self.moveTo(*lastPosition)
|
||||
if leftPanelIndex is not None:
|
||||
self.parent.leftPanel.tabs.setCurrentIndex(leftPanelIndex)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -58,7 +61,8 @@ class Map:
|
||||
mapFileName = self.getMapFilename()
|
||||
config = {
|
||||
'lastFile': mapFileName if mapFileName else "",
|
||||
'lastPosition': self.position
|
||||
'lastPosition': self.position,
|
||||
'leftPanelIndex': self.parent.leftPanel.tabs.currentIndex()
|
||||
}
|
||||
config_dir = os.path.dirname(EDITOR_CONFIG_PATH)
|
||||
if not os.path.exists(config_dir):
|
||||
|
||||
@@ -118,14 +118,14 @@ class EntityPanel(QWidget):
|
||||
chunk = self.parent.map.getChunkAtWorldPos(*position)
|
||||
if chunk is None:
|
||||
return
|
||||
|
||||
localX = position[0] - chunk.x
|
||||
localY = position[1] - chunk.y
|
||||
localZ = position[2] - chunk.z
|
||||
|
||||
|
||||
localX = (position[0] - chunk.x) % CHUNK_WIDTH
|
||||
localY = (position[1] - chunk.y) % CHUNK_HEIGHT
|
||||
localZ = (position[2] - chunk.z) % CHUNK_DEPTH
|
||||
|
||||
for ent in chunk.entities.values():
|
||||
if ent.localX != localX or ent.localY != localY or ent.localZ != localZ:
|
||||
continue
|
||||
continue
|
||||
self.onEntitySelect(ent)
|
||||
self.entityList.setCurrentItem(ent.item)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user