mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Move has_radar into the TGO.
This commit is contained in:
parent
c53feb5ccb
commit
e46262b021
@ -7,6 +7,9 @@ from dcs.mapping import Point
|
|||||||
from dcs.unit import Unit
|
from dcs.unit import Unit
|
||||||
from dcs.unitgroup import Group
|
from dcs.unitgroup import Group
|
||||||
|
|
||||||
|
from .. import db
|
||||||
|
from ..data.radar_db import UNITS_WITH_RADAR
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .controlpoint import ControlPoint
|
from .controlpoint import ControlPoint
|
||||||
from gen.flights.flight import FlightType
|
from gen.flights.flight import FlightType
|
||||||
@ -144,6 +147,15 @@ class TheaterGroundObject(MissionTarget):
|
|||||||
def might_have_aa(self) -> bool:
|
def might_have_aa(self) -> bool:
|
||||||
return False
|
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):
|
class BuildingGroundObject(TheaterGroundObject):
|
||||||
def __init__(self, name: str, category: str, group_id: int, object_id: int,
|
def __init__(self, name: str, category: str, group_id: int, object_id: int,
|
||||||
|
|||||||
@ -18,8 +18,6 @@ from typing import (
|
|||||||
|
|
||||||
from dcs.unittype import FlyingType
|
from dcs.unittype import FlyingType
|
||||||
|
|
||||||
from game import db
|
|
||||||
from game.data.radar_db import UNITS_WITH_RADAR
|
|
||||||
from game.infos.information import Information
|
from game.infos.information import Information
|
||||||
from game.procurement import AircraftProcurementRequest
|
from game.procurement import AircraftProcurementRequest
|
||||||
from game.theater import (
|
from game.theater import (
|
||||||
@ -36,7 +34,7 @@ from game.theater.theatergroundobject import (
|
|||||||
EwrGroundObject,
|
EwrGroundObject,
|
||||||
NavalGroundObject, VehicleGroupGroundObject,
|
NavalGroundObject, VehicleGroupGroundObject,
|
||||||
)
|
)
|
||||||
from game.utils import Distance, nautical_miles, nautical_miles
|
from game.utils import Distance, nautical_miles
|
||||||
from gen import Conflict
|
from gen import Conflict
|
||||||
from gen.ato import Package
|
from gen.ato import Package
|
||||||
from gen.flights.ai_flight_planner_db import (
|
from gen.flights.ai_flight_planner_db import (
|
||||||
@ -256,7 +254,7 @@ class ObjectiveFinder:
|
|||||||
if ground_object.name in found_targets:
|
if ground_object.name in found_targets:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not self.object_has_radar(ground_object):
|
if not ground_object.has_radar:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# TODO: Yield in order of most threatening.
|
# TODO: Yield in order of most threatening.
|
||||||
@ -358,15 +356,6 @@ class ObjectiveFinder:
|
|||||||
for target, _range in targets:
|
for target, _range in targets:
|
||||||
yield target
|
yield target
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def object_has_radar(ground_object: TheaterGroundObject) -> bool:
|
|
||||||
"""Returns True if the ground object contains a unit with radar."""
|
|
||||||
for group in ground_object.groups:
|
|
||||||
for unit in group.units:
|
|
||||||
if db.unit_type_from_name(unit.type) in UNITS_WITH_RADAR:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def front_lines(self) -> Iterator[FrontLine]:
|
def front_lines(self) -> Iterator[FrontLine]:
|
||||||
"""Iterates over all active front lines in the theater."""
|
"""Iterates over all active front lines in the theater."""
|
||||||
for cp in self.friendly_control_points():
|
for cp in self.friendly_control_points():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user