Begin adding entities to editor
Some checks failed
Build Dusk / build-linux (push) Failing after 56s
Build Dusk / build-psp (push) Failing after 1m8s

This commit is contained in:
2025-11-22 10:38:16 -06:00
parent 3697cc3eef
commit 6f33522c1c
17 changed files with 261 additions and 56 deletions

View File

@@ -3,6 +3,7 @@ import os
from dusk.event import Event
from dusk.defs import CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH, CHUNK_VERTEX_COUNT_MAX, TILE_SHAPE_NULL
from dusk.tile import Tile
from dusk.entity import Entity
from editortool.map.vertexbuffer import VertexBuffer
from OpenGL.GL import *
@@ -14,12 +15,16 @@ class Chunk:
self.z = z
self.current = {}
self.original = {}
self.entities = {}
self.onChunkData = Event()
self.dirty = False
self.tiles = {}
self.vertexBuffer = VertexBuffer()
# TEST
self.addEntity()
tileIndex = 0
for tz in range(CHUNK_DEPTH):
for ty in range(CHUNK_HEIGHT):
@@ -100,4 +105,18 @@ class Chunk:
return f"{dir_path}/{self.x}_{self.y}_{self.z}.json"
def draw(self):
self.vertexBuffer.draw()
self.vertexBuffer.draw()
def addEntity(self):
ent = Entity()
self.entities[len(self.entities)] = ent
self.map.onEntityData.invoke()
return ent
def removeEntity(self, entity):
for key, val in list(self.entities.items()):
if val == entity:
del self.entities[key]
self.map.onEntityData.invoke()
return True
return False

View File

@@ -37,4 +37,11 @@ TILE_SHAPES = {}
for key in defs.keys():
if key.startswith('TILE_SHAPE_'):
globals()[key] = int(defs.get(key))
TILE_SHAPES[key] = int(defs.get(key))
TILE_SHAPES[key] = int(defs.get(key))
ENTITY_TYPES = {}
for key in defs.keys():
if key.startswith('ENTITY_TYPE_'):
globals()[key] = int(defs.get(key))
if key != 'ENTITY_TYPE_COUNT':
ENTITY_TYPES[key] = int(defs.get(key))

9
tools/dusk/entity.py Normal file
View File

@@ -0,0 +1,9 @@
from dusk.defs import ENTITY_TYPE_NULL, ENTITY_TYPE_NPC
class Entity:
def __init__(self):
self.type = ENTITY_TYPE_NPC
self.localX = 0
self.localY = 8
self.localZ = 1
pass

View File

@@ -19,6 +19,7 @@ class Map:
self.chunks = {}
self.onMapData = Event()
self.onPositionChange = Event()
self.onEntityData = Event()
self.mapFileName = None
self.lastFile = None