dfhack/library/python/deprecated/pydfhack/map.py

117 lines
3.3 KiB
Python

# -*- coding: utf-8 -*-
"""
Python class for DF_Hack::Maps
"""
from ._pydfhack import _MapManager
2010-05-03 01:03:32 -06:00
from .mixins import NeedsStart
from .decorators import suspend
2010-05-03 04:19:40 -06:00
from .blocks import Block, Point
2010-05-03 01:03:32 -06:00
class Map(NeedsStart, _MapManager):
api = None
2010-05-03 01:03:32 -06:00
cls = _MapManager
def __init__(self, api, *args, **kwds):
2010-05-03 01:03:32 -06:00
self.cls.__init__(self, args, kwds)
self.api = api
2010-05-03 01:03:32 -06:00
@suspend
2010-05-03 04:19:40 -06:00
def get_size(self):
return self.size
@suspend
def Is_Valid_Block(self, x=0, y=0, z=0, point=None):
"""
Checks if coords are valid
"""
2010-05-03 01:03:32 -06:00
if point:
point = point.get_block()
x, y, z = point.xyz
2010-05-03 04:19:40 -06:00
return self.cls.Is_Valid_Block(self, x, y, z)
2010-05-03 01:03:32 -06:00
@suspend
def Read_Tile_Types(self, x=0, y=0, z=0, point=None):
"""
2010-05-03 01:03:32 -06:00
Returns 16x16 block in form of list of lists.
Should be called either by point or x,y,z coords. Coords are in block form.
"""
2010-05-03 01:03:32 -06:00
if point:
point = point.get_block()
x, y, z = point.xyz
return self.cls.Read_Tile_Types(self, x, y, z)
@suspend
2010-05-03 04:19:40 -06:00
def Write_Tile_Types(self, x=0, y=0, z=0, tiles=None, point=None):
if point:
point = point.get_block()
x, y, z = point.xyz
return self.cls.Write_Tile_Types(self, x, y, z, tiles)
@suspend
def Read_Designations(self, x=0, y=0, z=0, point=None):
"""
Returns 16x16 block in form of list of lists.
"""
if point:
point = point.get_block()
x, y, z = point.xyz
return self.cls.Read_Designations(self, x, y, z)
@suspend
def Write_Designations(self, x=0, y=0, z=0, tiles=None, point=None):
if point:
point = point.get_block()
x, y, z = point.xyz
return self.cls.Write_Designations(self, x, y, z, tiles)
@suspend
def Write_Occupancy(self, *args, **kw):
return self.cls.Write_Occupancy(self, *args, **kw)
2010-05-03 01:03:32 -06:00
@suspend
def Write_Dirty_Bit(self, *args, **kw):
return self.cls.Write_Dirty_Bit(self, *args, **kw)
@suspend
def Write_Block_Flags(self, *args, **kw):
return self.cls.Write_Block_Flags(self, *args, **kw)
@suspend
def Read_Region_Offsets(self, *args, **kw):
return self.cls.Read_Region_Offsets(self, *args, **kw)
@suspend
def Read_Dirty_Bit(self, *args, **kw):
return self.cls.Read_Dirty_Bit(self, *args, **kw)
@suspend
def Read_Occupancy(self, *args, **kw):
return self.cls.Read_Occupancy(self, *args, **kw)
@suspend
def Read_Block_Flags(self, *args, **kw):
return self.cls.Read_Block_Flags(self, *args, **kw)
@suspend
def Read_Geology(self, *args, **kw):
return self.cls.Read_Geology(self, *args, **kw)
@suspend
def Read_Block_40d(self, *args, **kw):
return self.cls.Read_Block_40d(self, *args, **kw)
2010-05-03 01:03:32 -06:00
@suspend
2010-05-03 04:19:40 -06:00
def get_block(self, point):
point = point.get_block()
block = Block(api=self.api, coords=point)
return block
@suspend
def get_tile(self, x=0, y=0, z=0, point=None):
if not point:
point = Point(x, y, z)
block = Block(api=self.api, coords=point.get_block())
return block.get_tile(point=point)