Don't show repaired TGOs as dead.

We were never resetting the dead state for repaired SAMs. Rather than
tracking that manually, determine liveness from the number of units left
alive.

For building objectives where the group is not assigned to the TGO until
*mission* generation time we still need manual tracking.
This commit is contained in:
Dan Albert 2020-12-26 16:19:41 -08:00
parent a6dc3d2aff
commit d3b1f6110f
3 changed files with 18 additions and 4 deletions

View File

@ -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

View File

@ -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 "

View File

@ -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]: