From a5418e3c7c82710b0d73a6aa92bdeadb378f10d1 Mon Sep 17 00:00:00 2001 From: Michael Kennedy <34204085+mlists@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:47:28 +1100 Subject: [PATCH] Add a has_just_fired check that auto can poll --- controllers/shooter.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/controllers/shooter.py b/controllers/shooter.py index 0c2cbbbc..bb57d441 100644 --- a/controllers/shooter.py +++ b/controllers/shooter.py @@ -11,7 +11,14 @@ class Shooter(StateMachine): should_fire = will_reset_to(False) SHOOTING_TIME_DURATION = 3 + def __init__(self) -> None: + self.just_fired = False + + def has_just_fired(self) -> bool: + return self.just_fired + def shoot(self) -> None: + """Engage the state machine to attempt a shot, needs to be called repeatedly""" self.should_fire = True self.engage() @@ -30,6 +37,7 @@ def update_ranging(self) -> None: @default_state def idle(self) -> None: """Run ranging whenever we are not doing anything else""" + self.just_fired = False self.update_ranging() if self.should_fire: self.next_state("acquiring") @@ -69,5 +77,6 @@ def shooting(self) -> None: @state def resetting(self) -> None: + self.just_fired = True self.shooter_component.stop_injection() self.done()