moved aftermath collision check to action

This commit is contained in:
Steffen Illium
2023-11-17 10:36:02 +01:00
parent 6b97710a7b
commit fea327861e
2 changed files with 5 additions and 6 deletions

View File

@@ -52,6 +52,11 @@ class Move(Action, abc.ABC):
new_pos = self._calc_new_pos(entity.pos)
if state.check_move_validity(entity, new_pos):
valid = entity.move(new_pos, state)
# Aftermath Collision Check
if len([x for x in state.entities.by_pos(entity.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
else:
# There is no place to go, propably collision

View File

@@ -90,12 +90,6 @@ class Entity(Object, abc.ABC):
self.set_pos(next_pos)
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]) > 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
return valid
# Bad naming... Was the same was the same pos, not moving....
return not_same_pos