mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-23 07:16:44 +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:
|
for observer in self.observers:
|
||||||
observer.notify_add_entity(self)
|
observer.notify_add_entity(self)
|
||||||
# Aftermath Collision Check
|
# 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...
|
# The entity did move, but there was something to collide with...
|
||||||
# Is then reported as a non-valid move, which did work.
|
# Is then reported as a non-valid move, which did work.
|
||||||
valid = False
|
valid = False
|
||||||
|
@ -44,22 +44,19 @@ class Door(Entity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
return self._status == d.STATE_CLOSED
|
return self._state == d.STATE_CLOSED
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_open(self):
|
def is_open(self):
|
||||||
return self._status == d.STATE_OPEN
|
return self._state == d.STATE_OPEN
|
||||||
|
|
||||||
@property
|
|
||||||
def status(self):
|
|
||||||
return self._status
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def time_to_close(self):
|
def time_to_close(self):
|
||||||
return self._time_to_close
|
return self._time_to_close
|
||||||
|
|
||||||
def __init__(self, *args, closed_on_init=True, auto_close_interval=10, **kwargs):
|
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)
|
super(Door, self).__init__(*args, **kwargs)
|
||||||
self._auto_close_interval = auto_close_interval
|
self._auto_close_interval = auto_close_interval
|
||||||
self._time_to_close = 0
|
self._time_to_close = 0
|
||||||
@ -78,7 +75,7 @@ class Door(Entity):
|
|||||||
return RenderEntity(name, self.pos, 1, 'none', state, self.u_int + 1)
|
return RenderEntity(name, self.pos, 1, 'none', state, self.u_int + 1)
|
||||||
|
|
||||||
def use(self):
|
def use(self):
|
||||||
if self._status == d.STATE_OPEN:
|
if self._state == d.STATE_OPEN:
|
||||||
self._close()
|
self._close()
|
||||||
else:
|
else:
|
||||||
self._open()
|
self._open()
|
||||||
@ -102,12 +99,12 @@ class Door(Entity):
|
|||||||
return Result(f"{d.DOOR}_reset", c.VALID, entity=self)
|
return Result(f"{d.DOOR}_reset", c.VALID, entity=self)
|
||||||
|
|
||||||
def _open(self):
|
def _open(self):
|
||||||
self._status = d.STATE_OPEN
|
self._state = d.STATE_OPEN
|
||||||
self._reset_timer()
|
self._reset_timer()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _close(self):
|
def _close(self):
|
||||||
self._status = d.STATE_CLOSED
|
self._state = d.STATE_CLOSED
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _decrement_timer(self):
|
def _decrement_timer(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user