mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Sync package wpts when primary flight's wpts change
Also recreates all other flight-plans in the package to ensure JOIN, INGRESS & SPLIT are updated
This commit is contained in:
@@ -78,5 +78,32 @@ def set_position(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Could not find PackageModel owning {flight}",
|
||||
)
|
||||
events = GameUpdateEvents()
|
||||
update_package_waypoints_if_primary_flight(waypoint, flight, events)
|
||||
package_model.update_tot()
|
||||
EventStream.put_nowait(GameUpdateEvents().update_flight(flight))
|
||||
EventStream.put_nowait(events.update_flight(flight))
|
||||
|
||||
|
||||
def update_package_waypoints_if_primary_flight(
|
||||
waypoint: FlightWaypoint,
|
||||
flight: Flight,
|
||||
events: GameUpdateEvents,
|
||||
) -> None:
|
||||
wpts = flight.package.waypoints
|
||||
if flight is flight.package.primary_flight and wpts:
|
||||
if waypoint.waypoint_type is FlightWaypointType.JOIN:
|
||||
wpts.join = waypoint.position
|
||||
elif waypoint.waypoint_type is FlightWaypointType.SPLIT:
|
||||
wpts.split = waypoint.position
|
||||
elif waypoint.waypoint_type is FlightWaypointType.REFUEL:
|
||||
wpts.refuel = waypoint.position
|
||||
elif "INGRESS" in waypoint.waypoint_type.name:
|
||||
wpts.ingress = waypoint.position
|
||||
wpts.initial = wpts.get_initial_point(
|
||||
waypoint.position, flight.package.target.position
|
||||
)
|
||||
for f in flight.package.flights:
|
||||
if f is flight:
|
||||
continue
|
||||
f.recreate_flight_plan()
|
||||
events.update_flight(f)
|
||||
|
||||
Reference in New Issue
Block a user