Fixed issue with targets forwards to player

This commit is contained in:
Marcin Kostrzewski 2020-05-17 01:02:07 +02:00
parent d1b6027ffa
commit ada3564713

View File

@ -218,14 +218,17 @@ class Entity(pygame.sprite.Sprite):
self.movementTarget = target self.movementTarget = target
from src.AI.AutomaticMovement import aStar from src.AI.AutomaticMovement import aStar
self.movesList = aStar(self, self.movementTarget, map) self.movesList = aStar(self, self.movementTarget, map)
if not self.movesList:
self.movementTarget = None
def updateEntityCoords(self): def updateEntityCoords(self):
""" """
Called each frame. Will consume moves from the moveList, if there are any. Called each frame. Will consume moves from the moveList, if there are any.
""" """
# Special case, where the selected entitiy was directly forwards the player
if self.movementTarget is not None and not self.movesList:
self.movementTarget.on_interaction(self)
self.movementTarget = None
if self.movementTarget is not None and self.movesList: if self.movementTarget is not None and self.movesList:
nextMove = self.movesList[0] nextMove = self.movesList[0]
if self.move(nextMove): if self.move(nextMove):