mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-22 23:06:43 +02:00
Fixed Doors
This commit is contained in:
parent
67a3f3f342
commit
6b97710a7b
@ -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
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user