Validate routes across crawl-mode changes
This commit is contained in:
1 parent
777018d24b
commit
928ce064eb
2 files changed
+31
-5
No files matched your search
+23
-5
@@ -276,13 +276,30 @@ class Pathfinder(AStar):
|
||||
node = tuple(node)
|
||||
if not self.bair(node) or self.bavoid(node):
|
||||
return False
|
||||
if not self.g.get('crawling'):
|
||||
above = utils.padd(node, BLOCK_ABOVE)
|
||||
if not self.bair(above) or self.bavoid(above):
|
||||
return False
|
||||
below = utils.padd(node, BLOCK_BELOW)
|
||||
return not self.bair(below) and not self.bavoid(below)
|
||||
|
||||
def _path_edge_is_valid(self, start, end):
|
||||
offset = utils.psub(end, start)
|
||||
if offset in TRAVERSE:
|
||||
# A changed ceiling can put the bot into crawl mode without
|
||||
# invalidating an otherwise traversable horizontal step.
|
||||
return (self.check_traverse(start, offset) or
|
||||
self.check_traverse_crawling(start, offset))
|
||||
if offset in DIAGONAL:
|
||||
return self.check_diagonal(start, offset)
|
||||
if offset in ASCEND:
|
||||
return self.check_ascend(start, offset)
|
||||
if offset in DESCEND:
|
||||
return self.check_descend(start, offset)
|
||||
if offset in DESCEND2:
|
||||
return self.check_descend2(start, offset)
|
||||
if offset in DESCEND3:
|
||||
return self.check_descend3(start, offset)
|
||||
if offset in PARKOUR:
|
||||
return self.check_parkour(start, offset)
|
||||
return False
|
||||
|
||||
def path_prefix_is_valid(self, route, steps=2):
|
||||
"""Check upcoming route nodes against the current loaded block state."""
|
||||
previous = None
|
||||
@@ -290,7 +307,8 @@ class Pathfinder(AStar):
|
||||
node = tuple(point)
|
||||
if not self._can_stand_at(node):
|
||||
return False, node
|
||||
if previous is not None and node not in self.neighbors(previous):
|
||||
if (previous is not None and
|
||||
not self._path_edge_is_valid(previous, node)):
|
||||
return False, node
|
||||
previous = node
|
||||
return True, None
|
||||
|
||||
Reference in new issue
Block a user