mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Refactor ground objects and prepare template system
- completly refactored the way TGO handles groups and replaced the usage of the pydcs ground groups (vehicle, ship, static) with an own Group and Unit class. - this allows us to only take care of dcs group generation during miz generation, where it should have always been. - We can now have any type of unit (even statics) in the same logic ground group we handle in liberation. this is independent from the dcs group handling. the dcs group will only be genarted when takeoff is pressed. - Refactored the unitmap and the scenery object handling to adopt to changes that now TGOs can hold all Units we want. - Cleaned up many many many lines of uneeded hacks to build stuff around dcs groups. - Removed IDs for TGOs as the names we generate are unique and for liberation to work we need no ids. Unique IDs for dcs will be generated for the units and groups only.
This commit is contained in:
@@ -11,9 +11,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class DefendingSam(FrozenCombat):
|
||||
def __init__(
|
||||
self, flight: Flight, air_defenses: list[TheaterGroundObject[Any]]
|
||||
) -> None:
|
||||
def __init__(self, flight: Flight, air_defenses: list[TheaterGroundObject]) -> None:
|
||||
super().__init__()
|
||||
self.flight = flight
|
||||
self.air_defenses = air_defenses
|
||||
|
||||
@@ -17,7 +17,7 @@ class SamEngagementZones:
|
||||
def __init__(
|
||||
self,
|
||||
threat_zones: ThreatPoly,
|
||||
individual_zones: list[tuple[TheaterGroundObject[Any], ThreatPoly]],
|
||||
individual_zones: list[tuple[TheaterGroundObject, ThreatPoly]],
|
||||
) -> None:
|
||||
self.threat_zones = threat_zones
|
||||
self.individual_zones = individual_zones
|
||||
@@ -25,9 +25,7 @@ class SamEngagementZones:
|
||||
def covers(self, position: Point) -> bool:
|
||||
return self.threat_zones.intersects(dcs_to_shapely_point(position))
|
||||
|
||||
def iter_threatening_sams(
|
||||
self, position: Point
|
||||
) -> Iterator[TheaterGroundObject[Any]]:
|
||||
def iter_threatening_sams(self, position: Point) -> Iterator[TheaterGroundObject]:
|
||||
for tgo, zone in self.individual_zones:
|
||||
if zone.intersects(dcs_to_shapely_point(position)):
|
||||
yield tgo
|
||||
@@ -44,7 +42,7 @@ class SamEngagementZones:
|
||||
return SamEngagementZones(unary_union(commit_regions), individual_zones)
|
||||
|
||||
@classmethod
|
||||
def threat_region(cls, tgo: TheaterGroundObject[Any]) -> Optional[ThreatPoly]:
|
||||
def threat_region(cls, tgo: TheaterGroundObject) -> Optional[ThreatPoly]:
|
||||
threat_range = tgo.max_threat_range()
|
||||
if threat_range <= meters(0):
|
||||
return None
|
||||
|
||||
@@ -29,8 +29,7 @@ class MissionResultsProcessor:
|
||||
self.commit_convoy_losses(debriefing)
|
||||
self.commit_cargo_ship_losses(debriefing)
|
||||
self.commit_airlift_losses(debriefing)
|
||||
self.commit_ground_object_losses(debriefing)
|
||||
self.commit_building_losses(debriefing)
|
||||
self.commit_ground_losses(debriefing)
|
||||
self.commit_damaged_runways(debriefing)
|
||||
self.commit_captures(debriefing)
|
||||
self.commit_front_line_battle_impact(debriefing)
|
||||
@@ -131,23 +130,11 @@ class MissionResultsProcessor:
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def commit_ground_object_losses(debriefing: Debriefing) -> None:
|
||||
for loss in debriefing.ground_object_losses:
|
||||
# TODO: This should be stored in the TGO, not in the pydcs Group.
|
||||
if not hasattr(loss.group, "units_losts"):
|
||||
loss.group.units_losts = [] # type: ignore
|
||||
|
||||
loss.group.units.remove(loss.unit)
|
||||
loss.group.units_losts.append(loss.unit) # type: ignore
|
||||
|
||||
def commit_building_losses(self, debriefing: Debriefing) -> None:
|
||||
for loss in debriefing.building_losses:
|
||||
loss.ground_object.kill()
|
||||
self.game.message(
|
||||
"Building destroyed",
|
||||
f"{loss.ground_object.dcs_identifier} has been destroyed at "
|
||||
f"location {loss.ground_object.obj_name}",
|
||||
)
|
||||
def commit_ground_losses(debriefing: Debriefing) -> None:
|
||||
for ground_object_loss in debriefing.ground_object_losses:
|
||||
ground_object_loss.ground_unit.kill()
|
||||
for scenery_object_loss in debriefing.scenery_object_losses:
|
||||
scenery_object_loss.ground_unit.kill()
|
||||
|
||||
@staticmethod
|
||||
def commit_damaged_runways(debriefing: Debriefing) -> None:
|
||||
|
||||
Reference in New Issue
Block a user