43 lines
986 B
Python
43 lines
986 B
Python
|
# -*- coding: utf-8 -*-
|
||
|
"""
|
||
|
Python class for DF_Hack::Position
|
||
|
"""
|
||
|
from ._pydfhack import _PositionManager
|
||
|
from .blocks import Point, Block
|
||
|
from .mixins import NoStart
|
||
|
from .decorators import suspend
|
||
|
|
||
|
class Position(NoStart, _PositionManager):
|
||
|
api = None
|
||
|
cls = _PositionManager
|
||
|
def __init__(self, api, *args, **kwds):
|
||
|
self.cls.__init__(self, args, kwds)
|
||
|
self.api = api
|
||
|
|
||
|
@suspend
|
||
|
def get_cursor(self):
|
||
|
coords = self.cursor_coords
|
||
|
if coords:
|
||
|
return Point(*coords)
|
||
|
else:
|
||
|
return None
|
||
|
|
||
|
@suspend
|
||
|
def get_window_size(self):
|
||
|
wsize = self.window_size
|
||
|
return wsize
|
||
|
|
||
|
@suspend
|
||
|
def get_view_coords(self):
|
||
|
coords = self.view_coords
|
||
|
return Point(*coords)
|
||
|
|
||
|
@suspend
|
||
|
def get_cursor_tile(self):
|
||
|
point = self.get_cursor()
|
||
|
if point:
|
||
|
tile = self.api.maps.get_tile(point=point)
|
||
|
return tile
|
||
|
else:
|
||
|
return None
|