def _optimalDestination(self): """ Returns the optimal destination given the current location of the unit and the desired end point. Returns given endpoint if none found. """ destX,destY = self.path.pop(0) destX=destX%self.worldSize[0] destY=destY%self.worldSize[1] return specialMath.findClosest(self.realCenter, (destX, destY), self.worldSize)
def moveCloseToObject(self,radius, obj): """ Moves unit within specified radius of objectOfAction. Returns True if within radius, False if otherwise """ if obj is not None: closest=specialMath.findClosest(self.realCenter, obj.realCenter, self.worldSize) self.dest=closest if specialMath.distance(self.realCenter, self.dest) > radius: self.move() return False else: return True return False