mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Pick runways and ascent/descent based on headwind.
This commit is contained in:
@@ -132,7 +132,7 @@ class FlightPlanBuilder:
|
||||
if not isinstance(location, TheaterGroundObject):
|
||||
raise InvalidObjectiveLocation(flight.flight_type, location)
|
||||
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.ascent(flight.from_cp)
|
||||
builder.hold(self._hold_point(flight))
|
||||
builder.join(self.package.waypoints.join)
|
||||
@@ -222,7 +222,7 @@ class FlightPlanBuilder:
|
||||
)
|
||||
start = end.point_from_heading(heading - 180, diameter)
|
||||
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.ascent(flight.from_cp)
|
||||
builder.race_track(start, end, patrol_alt)
|
||||
builder.rtb(flight.from_cp)
|
||||
@@ -264,7 +264,7 @@ class FlightPlanBuilder:
|
||||
orbit1p = orbit_center.point_from_heading(heading + 180, radius)
|
||||
|
||||
# Create points
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.ascent(flight.from_cp)
|
||||
builder.hold(self._hold_point(flight))
|
||||
builder.join(self.package.waypoints.join)
|
||||
@@ -290,7 +290,7 @@ class FlightPlanBuilder:
|
||||
if custom_targets is None:
|
||||
custom_targets = []
|
||||
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.ascent(flight.from_cp)
|
||||
builder.hold(self._hold_point(flight))
|
||||
builder.join(self.package.waypoints.join)
|
||||
@@ -328,7 +328,7 @@ class FlightPlanBuilder:
|
||||
def generate_escort(self, flight: Flight) -> None:
|
||||
assert self.package.waypoints is not None
|
||||
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.ascent(flight.from_cp)
|
||||
builder.hold(self._hold_point(flight))
|
||||
builder.join(self.package.waypoints.join)
|
||||
@@ -361,7 +361,7 @@ class FlightPlanBuilder:
|
||||
center = ingress.point_from_heading(heading, distance / 2)
|
||||
egress = ingress.point_from_heading(heading, distance)
|
||||
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.ascent(flight.from_cp, is_helo)
|
||||
builder.hold(self._hold_point(flight))
|
||||
builder.join(self.package.waypoints.join)
|
||||
@@ -382,7 +382,7 @@ class FlightPlanBuilder:
|
||||
flight: The flight to generate the descend point for.
|
||||
departure: Departure airfield or carrier.
|
||||
"""
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.ascent(departure)
|
||||
return builder.build()[0]
|
||||
|
||||
@@ -394,7 +394,7 @@ class FlightPlanBuilder:
|
||||
flight: The flight to generate the descend point for.
|
||||
arrival: Arrival airfield or carrier.
|
||||
"""
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.descent(arrival)
|
||||
return builder.build()[0]
|
||||
|
||||
@@ -406,7 +406,7 @@ class FlightPlanBuilder:
|
||||
flight: The flight to generate the landing waypoint for.
|
||||
arrival: Arrival airfield or carrier.
|
||||
"""
|
||||
builder = WaypointBuilder(flight, self.doctrine)
|
||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||
builder.land(arrival)
|
||||
return builder.build()[0]
|
||||
|
||||
|
||||
@@ -7,12 +7,16 @@ from dcs.unit import Unit
|
||||
|
||||
from game.data.doctrine import Doctrine
|
||||
from game.utils import nm_to_meter
|
||||
from game.weather import Conditions
|
||||
from theater import ControlPoint, MissionTarget, TheaterGroundObject
|
||||
from .flight import Flight, FlightWaypoint, FlightWaypointType
|
||||
from ..runways import RunwayAssigner
|
||||
|
||||
|
||||
class WaypointBuilder:
|
||||
def __init__(self, flight: Flight, doctrine: Doctrine) -> None:
|
||||
def __init__(self, conditions: Conditions, flight: Flight,
|
||||
doctrine: Doctrine) -> None:
|
||||
self.conditions = conditions
|
||||
self.flight = flight
|
||||
self.doctrine = doctrine
|
||||
self.waypoints: List[FlightWaypoint] = []
|
||||
@@ -28,8 +32,7 @@ class WaypointBuilder:
|
||||
departure: Departure airfield or carrier.
|
||||
is_helo: True if the flight is a helicopter.
|
||||
"""
|
||||
# TODO: Pick runway based on wind direction.
|
||||
heading = departure.heading
|
||||
heading = RunwayAssigner(self.conditions).takeoff_heading(departure)
|
||||
position = departure.position.point_from_heading(
|
||||
heading, nm_to_meter(5)
|
||||
)
|
||||
@@ -52,9 +55,8 @@ class WaypointBuilder:
|
||||
arrival: Arrival airfield or carrier.
|
||||
is_helo: True if the flight is a helicopter.
|
||||
"""
|
||||
# TODO: Pick runway based on wind direction.
|
||||
# ControlPoint.heading is the departure heading.
|
||||
heading = (arrival.heading + 180) % 360
|
||||
landing_heading = RunwayAssigner(self.conditions).landing_heading(arrival)
|
||||
heading = (landing_heading + 180) % 360
|
||||
position = arrival.position.point_from_heading(
|
||||
heading, nm_to_meter(5)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user