Share belt manager instance accross health manager and bot (#315)
This commit is contained in:
@@ -126,6 +126,9 @@ class Bot:
|
||||
self.machine = GraphMachine(model=self, states=self._states, initial="hero_selection", transitions=self._transitions, queued=True)
|
||||
self.machine.get_graph().draw('my_state_diagram.png', prog='dot')
|
||||
|
||||
def get_belt_manager(self) -> BeltManager:
|
||||
return self._belt_manager
|
||||
|
||||
def get_curr_location(self):
|
||||
return self._curr_loc
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class HealthManager:
|
||||
self._screen = screen
|
||||
self._template_finder = TemplateFinder(screen)
|
||||
self._ui_manager = UiManager(screen, self._template_finder)
|
||||
self._belt_manager = BeltManager(screen, self._template_finder)
|
||||
self._belt_manager = None # must be set with the belt manager form bot.py
|
||||
self._do_monitor = False
|
||||
self._did_chicken = False
|
||||
self._last_rejuv = time.time()
|
||||
@@ -33,6 +33,9 @@ class HealthManager:
|
||||
def stop_monitor(self):
|
||||
self._do_monitor = False
|
||||
|
||||
def set_belt_manager(self, belt_manager: BeltManager):
|
||||
self._belt_manager = belt_manager
|
||||
|
||||
def set_callback(self, callback):
|
||||
self._callback = callback
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ def run_bot(
|
||||
# Register that thread to the death and health manager so they can stop the bot thread if needed
|
||||
death_manager.set_callback(lambda: bot.stop() or kill_thread(bot_thread))
|
||||
health_manager.set_callback(lambda: bot.stop() or kill_thread(bot_thread))
|
||||
health_manager.set_belt_manager(bot.get_belt_manager())
|
||||
do_restart = False
|
||||
keyboard.add_hotkey(config.general["exit_key"], lambda: Logger.info(f'Force Exit') or os._exit(1))
|
||||
keyboard.add_hotkey(config.general['resume_key'], lambda: bot.toggle_pause())
|
||||
|
||||
Reference in New Issue
Block a user