From 34111cfc67b93dbe5cac0deb789cab17dd9b055f Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 4 Mar 2022 00:29:31 -0800 Subject: [PATCH] Update all TGOs on capture. We need to update all TGOs, not just the cleared ones, because the captured buildings need to update their icon to show the new color. --- game/theater/controlpoint.py | 11 ++++++++--- game/theater/theatergroundobject.py | 4 +--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index 741d5f0b..bb620679 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -730,11 +730,11 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC): for squadron in self.squadrons: self._retreat_squadron(game, squadron) - def depopulate_uncapturable_tgos(self, events: GameUpdateEvents) -> None: + def depopulate_uncapturable_tgos(self) -> None: # TODO Rework this. for tgo in self.connected_objectives: if not tgo.capturable: - tgo.clear(events) + tgo.clear() # TODO: Should be Airbase specific. def capture(self, game: Game, events: GameUpdateEvents, for_player: bool) -> None: @@ -742,7 +742,12 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC): self.ground_unit_orders.refund_all(self.coalition) self.retreat_ground_units(game) self.retreat_air_units(game) - self.depopulate_uncapturable_tgos(events) + self.depopulate_uncapturable_tgos() + + # All the attached TGOs have either been depopulated or captured. Tell the UI to + # update their state. + for tgo in self.connected_objectives: + events.update_tgo(tgo) self._coalition = new_coalition self.base.set_strength_to_minimum() diff --git a/game/theater/theatergroundobject.py b/game/theater/theatergroundobject.py index 67207dd6..aa431cb4 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -23,7 +23,6 @@ from ..data.radar_db import LAUNCHER_TRACKER_PAIRS, TELARS, TRACK_RADARS from ..utils import Distance, Heading, meters if TYPE_CHECKING: - from game.sim import GameUpdateEvents from .theatergroup import TheaterUnit, TheaterGroup from .controlpoint import ControlPoint from ..ato.flighttype import FlightType @@ -215,9 +214,8 @@ class TheaterGroundObject(MissionTarget, SidcDescribable, ABC): def mark_locations(self) -> Iterator[Point]: yield self.position - def clear(self, events: GameUpdateEvents) -> None: + def clear(self) -> None: self.groups = [] - events.update_tgo(self) @property def capturable(self) -> bool: