Merge pull request #127 from DanAlbert/first-waypoint

Add first waypoint to FlightData.
This commit is contained in:
C. Perreau 2020-09-11 20:48:04 +02:00 committed by GitHub
commit e0a39104b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 3 deletions

View File

@ -357,6 +357,10 @@ class AircraftConflictGenerator:
logging.warning(f"Unhandled departure control point: {cp.cptype}")
departure_runway = fallback_runway
# The first waypoint is set automatically by pydcs, so it's not in our
# list. Convert the pydcs MovingPoint to a FlightWaypoint so it shows up
# in our FlightData.
first_point = FlightWaypoint.from_pydcs(group.points[0], flight.from_cp)
self.flights.append(FlightData(
flight_type=flight.flight_type,
units=group.units,
@ -367,7 +371,7 @@ class AircraftConflictGenerator:
arrival=departure_runway,
# TODO: Support for divert airfields.
divert=None,
waypoints=flight.points,
waypoints=[first_point] + flight.points,
intra_flight_channel=channel
))

View File

@ -115,8 +115,6 @@ class BriefingGenerator(MissionInfoGenerator):
self.description += "-" * 50 + "\n"
self.description += f"{flight_unit_name} x {flight.size + 2}\n\n"
departure = flight.departure.airfield_name
self.description += f"#0 -- TAKEOFF : Take off from {departure}\n"
for i, wpt in enumerate(flight.waypoints):
self.description += f"#{i + 1} -- {wpt.name} : {wpt.description}\n"
self.description += f"#{len(flight.waypoints) + 1} -- RTB\n\n"

View File

@ -3,6 +3,8 @@ from typing import List
from game import db
from dcs.unittype import UnitType
from dcs.point import MovingPoint, PointAction
from theater.controlpoint import ControlPoint
class FlightType(Enum):
@ -77,6 +79,33 @@ class FlightWaypoint:
self.data = None
@classmethod
def from_pydcs(cls, point: MovingPoint,
from_cp: ControlPoint) -> "FlightWaypoint":
waypoint = FlightWaypoint(point.position.x, point.position.y,
point.alt)
waypoint.alt_type = point.alt_type
# Other actions exist... but none of them *should* be the first
# waypoint for a flight.
waypoint.waypoint_type = {
PointAction.TurningPoint: FlightWaypointType.NAV,
PointAction.FlyOverPoint: FlightWaypointType.NAV,
PointAction.FromParkingArea: FlightWaypointType.TAKEOFF,
PointAction.FromParkingAreaHot: FlightWaypointType.TAKEOFF,
PointAction.FromRunway: FlightWaypointType.TAKEOFF,
}[point.action]
if waypoint.waypoint_type == FlightWaypointType.NAV:
waypoint.name = "NAV"
waypoint.pretty_name = "Nav"
waypoint.description = "Nav"
else:
waypoint.name = "TAKEOFF"
waypoint.pretty_name = "Takeoff"
waypoint.description = "Takeoff"
waypoint.description = f"Takeoff from {from_cp.name}"
return waypoint
class Flight:
unit_type: UnitType = None
from_cp = None