Move has_radar into the TGO.

This commit is contained in:
Dan Albert
2020-12-22 12:47:40 -08:00
parent c53feb5ccb
commit e46262b021
2 changed files with 14 additions and 13 deletions

View File

@@ -7,6 +7,9 @@ from dcs.mapping import Point
from dcs.unit import Unit
from dcs.unitgroup import Group
from .. import db
from ..data.radar_db import UNITS_WITH_RADAR
if TYPE_CHECKING:
from .controlpoint import ControlPoint
from gen.flights.flight import FlightType
@@ -144,6 +147,15 @@ class TheaterGroundObject(MissionTarget):
def might_have_aa(self) -> bool:
return False
@property
def has_radar(self) -> bool:
"""Returns True if the ground object contains a unit with radar."""
for group in self.groups:
for unit in group.units:
if db.unit_type_from_name(unit.type) in UNITS_WITH_RADAR:
return True
return False
class BuildingGroundObject(TheaterGroundObject):
def __init__(self, name: str, category: str, group_id: int, object_id: int,