mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
During package planning we don't care about the details of the flight plan, just the layout (to check if the layout is threatened and we need escorts). Splitting these will allow us to reduce the amount of work that must be done in each loop of the planning phase, potentially caching attempted flight plans between loops.
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
import logging
|
|
|
|
from dcs.point import MovingPoint
|
|
from dcs.task import EngageTargets, EngageTargetsInZone, Targets
|
|
|
|
from game.ato.flightplans.cas import CasFlightPlan
|
|
from game.utils import nautical_miles
|
|
from .pydcswaypointbuilder import PydcsWaypointBuilder
|
|
|
|
|
|
class CasIngressBuilder(PydcsWaypointBuilder):
|
|
def add_tasks(self, waypoint: MovingPoint) -> None:
|
|
if isinstance(self.flight.flight_plan, CasFlightPlan):
|
|
waypoint.add_task(
|
|
EngageTargetsInZone(
|
|
position=self.flight.flight_plan.layout.target.position,
|
|
radius=int(self.flight.flight_plan.engagement_distance.meters),
|
|
targets=[
|
|
Targets.All.GroundUnits.GroundVehicles,
|
|
Targets.All.GroundUnits.AirDefence.AAA,
|
|
Targets.All.GroundUnits.Infantry,
|
|
],
|
|
)
|
|
)
|
|
else:
|
|
logging.error("No CAS waypoint found. Falling back to search and engage")
|
|
waypoint.add_task(
|
|
EngageTargets(
|
|
max_distance=int(nautical_miles(10).meters),
|
|
targets=[
|
|
Targets.All.GroundUnits.GroundVehicles,
|
|
Targets.All.GroundUnits.AirDefence.AAA,
|
|
Targets.All.GroundUnits.Infantry,
|
|
],
|
|
)
|
|
)
|