Fixed Doors

This commit is contained in:
Steffen Illium 2023-11-16 17:28:45 +01:00
parent 67a3f3f342
commit 6b97710a7b
2 changed files with 7 additions and 10 deletions

View File

@ -91,7 +91,7 @@ class Entity(Object, abc.ABC):
for observer in self.observers:
observer.notify_add_entity(self)
# Aftermath Collision Check
if len([x for x in state.entities.by_pos(next_pos) if x.var_can_collide]):
if len([x for x in state.entities.by_pos(next_pos) if x.var_can_collide]) > 1:
# The entity did move, but there was something to collide with...
# Is then reported as a non-valid move, which did work.
valid = False

View File

@ -44,22 +44,19 @@ class Door(Entity):
@property
def is_closed(self):
return self._status == d.STATE_CLOSED
return self._state == d.STATE_CLOSED
@property
def is_open(self):
return self._status == d.STATE_OPEN
return self._state == d.STATE_OPEN
@property
def status(self):
return self._status
@property
def time_to_close(self):
return self._time_to_close
def __init__(self, *args, closed_on_init=True, auto_close_interval=10, **kwargs):
self._status = d.STATE_CLOSED
self._state = d.STATE_CLOSED
super(Door, self).__init__(*args, **kwargs)
self._auto_close_interval = auto_close_interval
self._time_to_close = 0
@ -78,7 +75,7 @@ class Door(Entity):
return RenderEntity(name, self.pos, 1, 'none', state, self.u_int + 1)
def use(self):
if self._status == d.STATE_OPEN:
if self._state == d.STATE_OPEN:
self._close()
else:
self._open()
@ -102,12 +99,12 @@ class Door(Entity):
return Result(f"{d.DOOR}_reset", c.VALID, entity=self)
def _open(self):
self._status = d.STATE_OPEN
self._state = d.STATE_OPEN
self._reset_timer()
return True
def _close(self):
self._status = d.STATE_CLOSED
self._state = d.STATE_CLOSED
return True
def _decrement_timer(self):