From ebedc02a0a8b9a6785033b42eb0b6da5df4d3a6b Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 6 Sep 2020 03:15:17 -0700 Subject: [PATCH] Add first waypoint to FlightData. The first waypoint is automatically added by pydcs, so it's not actually in our waypoint list from the flight planner. Import is from the group so it shows up in the kneeboard. --- gen/aircraft.py | 6 +++++- gen/briefinggen.py | 2 -- gen/flights/flight.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index 82062b6e..4ae1a80a 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -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 )) diff --git a/gen/briefinggen.py b/gen/briefinggen.py index 0b494ac5..91d16de3 100644 --- a/gen/briefinggen.py +++ b/gen/briefinggen.py @@ -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" diff --git a/gen/flights/flight.py b/gen/flights/flight.py index 6e2522f5..d00b4783 100644 --- a/gen/flights/flight.py +++ b/gen/flights/flight.py @@ -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