diff --git a/changelog.md b/changelog.md index ded88a57..47edf277 100644 --- a/changelog.md +++ b/changelog.md @@ -34,6 +34,7 @@ Saves from 2.3 are not compatible with 2.4. * **[Units]** Fixed SPG_Stryker_M1128_MGS not being in db * **[Mission Generator]** Empty navy groups will no longer be generated * **[Flight Planner]** Fixed not being able to plan packages against opfor carriers +* **[UI]** Repaired SAMs no longer show as dead. # 2.3.2 diff --git a/game/event/event.py b/game/event/event.py index 4ecd5329..79b68430 100644 --- a/game/event/event.py +++ b/game/event/event.py @@ -152,12 +152,10 @@ class Event: loss.group.units.remove(loss.unit) loss.group.units_losts.append(loss.unit) - if not loss.ground_object.alive_unit_count: - loss.ground_object.is_dead = True def commit_building_losses(self, debriefing: Debriefing) -> None: for loss in debriefing.building_losses: - loss.ground_object.is_dead = True + loss.ground_object.kill() self.game.informations.append(Information( "Building destroyed", f"{loss.ground_object.dcs_identifier} has been destroyed at " diff --git a/game/theater/theatergroundobject.py b/game/theater/theatergroundobject.py index 1322510b..701f8c9a 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -90,9 +90,12 @@ class TheaterGroundObject(MissionTarget): self.dcs_identifier = dcs_identifier self.airbase_group = airbase_group self.sea_object = sea_object - self.is_dead = False self.groups: List[Group] = [] + @property + def is_dead(self) -> bool: + return self.alive_unit_count == 0 + @property def units(self) -> List[Unit]: """ @@ -205,6 +208,9 @@ class BuildingGroundObject(TheaterGroundObject): sea_object=False ) self.object_id = object_id + # Other TGOs track deadness based on the number of alive units, but + # buildings don't have groups assigned to the TGO. + self._dead = False @property def group_name(self) -> str: @@ -215,6 +221,15 @@ class BuildingGroundObject(TheaterGroundObject): def waypoint_name(self) -> str: return f"{super().waypoint_name} #{self.object_id}" + @property + def is_dead(self) -> bool: + if not hasattr(self, "_dead"): + self._dead = False + return self._dead + + def kill(self) -> None: + self._dead = True + class NavalGroundObject(TheaterGroundObject): def mission_types(self, for_player: bool) -> Iterator[FlightType]: