mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Remove aa_ranges in favor of using the TGO data.
This commit is contained in:
@@ -157,12 +157,11 @@ class TheaterGroundObject(MissionTarget):
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def threat_range(self) -> Distance:
|
||||
def _max_range_of_type(self, range_type: str) -> Distance:
|
||||
if not self.might_have_aa:
|
||||
return meters(0)
|
||||
|
||||
threat_range = meters(0)
|
||||
max_range = meters(0)
|
||||
for group in self.groups:
|
||||
for u in group.units:
|
||||
unit = db.unit_type_from_name(u.type)
|
||||
@@ -170,12 +169,20 @@ class TheaterGroundObject(MissionTarget):
|
||||
logging.error(f"Unknown unit type {u.type}")
|
||||
continue
|
||||
|
||||
# Some units in pydcs have threat_range defined, but explicitly
|
||||
# set to None.
|
||||
unit_threat_range = getattr(unit, "threat_range", None)
|
||||
if unit_threat_range is not None:
|
||||
threat_range = max(threat_range, meters(unit_threat_range))
|
||||
return threat_range
|
||||
# Some units in pydcs have detection_range/threat_range defined,
|
||||
# but explicitly set to None.
|
||||
unit_range = getattr(unit, range_type, None)
|
||||
if unit_range is not None:
|
||||
max_range = max(max_range, meters(unit_range))
|
||||
return max_range
|
||||
|
||||
@property
|
||||
def detection_range(self) -> Distance:
|
||||
return self._max_range_of_type("detection_range")
|
||||
|
||||
@property
|
||||
def threat_range(self) -> Distance:
|
||||
return self._max_range_of_type("threat_range")
|
||||
|
||||
|
||||
class BuildingGroundObject(TheaterGroundObject):
|
||||
|
||||
@@ -72,6 +72,9 @@ class Distance:
|
||||
def __floordiv__(self, other: Union[float, int]) -> Distance:
|
||||
return meters(self.meters // other)
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
return not math.isclose(self.meters, 0.0)
|
||||
|
||||
|
||||
def feet(value: float) -> Distance:
|
||||
return Distance.from_feet(value)
|
||||
@@ -154,6 +157,9 @@ class Speed:
|
||||
def __floordiv__(self, other: Union[float, int]) -> Speed:
|
||||
return kph(self.kph // other)
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
return not math.isclose(self.kph, 0.0)
|
||||
|
||||
|
||||
def knots(value: float) -> Speed:
|
||||
return Speed.from_knots(value)
|
||||
|
||||
Reference in New Issue
Block a user