Closer to actually editing
This commit is contained in:
37
tools/editortool/map/map.py
Normal file
37
tools/editortool/map/map.py
Normal file
@@ -0,0 +1,37 @@
|
||||
class Map:
|
||||
def __init__(self):
|
||||
self._position = [0, 0, 0] # x, y, z
|
||||
self.listeners = []
|
||||
self.chunks = []
|
||||
self.width = 5
|
||||
self.height = 5
|
||||
self.depth = 3
|
||||
|
||||
@property
|
||||
def position(self):
|
||||
return self._position
|
||||
|
||||
@position.setter
|
||||
def position(self, value):
|
||||
self._position = value
|
||||
self.notifyPositionListeners()
|
||||
|
||||
def addPositionListener(self, listener):
|
||||
self.listeners.append(listener)
|
||||
|
||||
def notifyPositionListeners(self):
|
||||
for listener in self.listeners:
|
||||
listener(self._position)
|
||||
|
||||
def moveTo(self, x, y, z):
|
||||
self.position = [x, y, z]
|
||||
|
||||
def moveRelative(self, x, y, z):
|
||||
self.moveTo(
|
||||
self._position[0] + x,
|
||||
self._position[1] + y,
|
||||
self._position[2] + z
|
||||
)
|
||||
|
||||
# Singleton instance
|
||||
map = Map()
|
||||
Reference in New Issue
Block a user