diff --git a/changelog.md b/changelog.md index de0b1aaa..f9d23bec 100644 --- a/changelog.md +++ b/changelog.md @@ -28,6 +28,7 @@ * **[New Game Wizard]** Removed the "mid game" campaign generator option which is currently broken * **[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 2908d5f3..431de495 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -85,10 +85,13 @@ class TheaterGroundObject(MissionTarget): self.dcs_identifier = dcs_identifier self.airbase_group = airbase_group self.sea_object = sea_object - self.is_dead = False # TODO: There is never more than one group. self.groups: List[Group] = [] + @property + def is_dead(self) -> bool: + return self.alive_unit_count == 0 + @property def units(self) -> List[Unit]: """ @@ -161,6 +164,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: @@ -171,6 +177,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]: