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.
This commit is contained in:
Dan Albert 2022-03-04 00:29:31 -08:00
parent fef123c2d4
commit 34111cfc67
2 changed files with 9 additions and 6 deletions

View File

@ -730,11 +730,11 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC):
for squadron in self.squadrons: for squadron in self.squadrons:
self._retreat_squadron(game, squadron) self._retreat_squadron(game, squadron)
def depopulate_uncapturable_tgos(self, events: GameUpdateEvents) -> None: def depopulate_uncapturable_tgos(self) -> None:
# TODO Rework this. # TODO Rework this.
for tgo in self.connected_objectives: for tgo in self.connected_objectives:
if not tgo.capturable: if not tgo.capturable:
tgo.clear(events) tgo.clear()
# TODO: Should be Airbase specific. # TODO: Should be Airbase specific.
def capture(self, game: Game, events: GameUpdateEvents, for_player: bool) -> None: 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.ground_unit_orders.refund_all(self.coalition)
self.retreat_ground_units(game) self.retreat_ground_units(game)
self.retreat_air_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._coalition = new_coalition
self.base.set_strength_to_minimum() self.base.set_strength_to_minimum()

View File

@ -23,7 +23,6 @@ from ..data.radar_db import LAUNCHER_TRACKER_PAIRS, TELARS, TRACK_RADARS
from ..utils import Distance, Heading, meters from ..utils import Distance, Heading, meters
if TYPE_CHECKING: if TYPE_CHECKING:
from game.sim import GameUpdateEvents
from .theatergroup import TheaterUnit, TheaterGroup from .theatergroup import TheaterUnit, TheaterGroup
from .controlpoint import ControlPoint from .controlpoint import ControlPoint
from ..ato.flighttype import FlightType from ..ato.flighttype import FlightType
@ -215,9 +214,8 @@ class TheaterGroundObject(MissionTarget, SidcDescribable, ABC):
def mark_locations(self) -> Iterator[Point]: def mark_locations(self) -> Iterator[Point]:
yield self.position yield self.position
def clear(self, events: GameUpdateEvents) -> None: def clear(self) -> None:
self.groups = [] self.groups = []
events.update_tgo(self)
@property @property
def capturable(self) -> bool: def capturable(self) -> bool: