Add patrol prepare route support

This commit is contained in:
王鹏
2026-04-29 23:15:10 +08:00
parent 12ce30d2df
commit a9e162f00e
3 changed files with 90 additions and 12 deletions

View File

@@ -278,7 +278,7 @@ class CoordinatePatrol:
return
def navigate_to_point(self, state, target_pos, arrival_threshold=None):
def navigate_to_point(self, state, target_pos, arrival_threshold=None, stop_on_arrival=True):
"""
优化版:平滑导航,支持边走边转。
"""
@@ -309,11 +309,12 @@ class CoordinatePatrol:
# 2. 距离判断
dist = self.get_distance(current_pos, target_pos)
if dist < threshold:
# 到点后停止前进:松开 W避免到达后仍持续向前移动
# (该函数被 death/logistics 等模块用于“到点就交互/停止”。)
# 到点后默认停止前进,供 death/logistics 等“到点就交互/停止”的流程复用。
# 准备路线可传 stop_on_arrival=False实现平滑过点。
pydirectinput.keyUp("a")
pydirectinput.keyUp("d")
pydirectinput.keyUp("w")
if stop_on_arrival:
pydirectinput.keyUp("w")
self.reset_stuck()
return True