WIP: removing tiles

This commit is contained in:
Chanumask
2023-10-16 11:06:51 +02:00
parent 3bf3246aeb
commit 3677b7b7dc
37 changed files with 255 additions and 247 deletions

View File

@@ -81,11 +81,11 @@ class Door(Entity):
self._open()
return c.VALID
def tick(self):
if self.is_open and len(self.tile) == 1 and self.time_to_close:
def tick(self, state):
if self.is_open and len(state.entities.pos_dict[self.pos]) == 2 and self.time_to_close:
self.time_to_close -= 1
return c.NOT_VALID
elif self.is_open and not self.time_to_close and len(self.tile) == 1:
elif self.is_open and not self.time_to_close and len(state.entities.pos_dict[self.pos]) == 2:
self.use()
return c.VALID
else:

View File

@@ -14,9 +14,9 @@ class Doors(PositionMixin, EnvObjects):
def __init__(self, *args, **kwargs):
super(Doors, self).__init__(*args, can_collide=True, **kwargs)
def tick_doors(self):
def tick_doors(self, state):
result_dict = dict()
for door in self:
did_tick = door.tick()
did_tick = door.tick(state)
result_dict.update({door.name: did_tick})
return result_dict

View File

@@ -12,7 +12,7 @@ class DoorAutoClose(Rule):
def tick_step(self, state):
if doors := state[d.DOORS]:
doors_tick_result = doors.tick_doors()
doors_tick_result = doors.tick_doors(state)
doors_that_ticked = [key for key, val in doors_tick_result.items() if val]
state.print(f'{doors_that_ticked} were auto-closed'
if doors_that_ticked else 'No Doors were auto-closed')