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:
parent
b124c6cc61
commit
6a5097659b
@ -31,6 +31,7 @@
|
|||||||
* **[Mission Generation]** Ability to choose whether player flights can spawn on the sixpack or not
|
* **[Mission Generation]** Ability to choose whether player flights can spawn on the sixpack or not
|
||||||
* **[Options]** New options in Mission Generator section: Limit AI radio callouts & Suppress AI radio callouts.
|
* **[Options]** New options in Mission Generator section: Limit AI radio callouts & Suppress AI radio callouts.
|
||||||
* **[Options]** New option to use the combat landing flag in the landing waypoint task for helicopters.
|
* **[Options]** New option to use the combat landing flag in the landing waypoint task for helicopters.
|
||||||
|
* **[UI/UX]** Sync package waypoints when primary flight's waypoints are updated and recreate other flights within the package to ensure JOIN, INGRESS & SPLIT are synced
|
||||||
|
|
||||||
## Fixes
|
## Fixes
|
||||||
* **[UI/UX]** A-10A flights can be edited again
|
* **[UI/UX]** A-10A flights can be edited again
|
||||||
|
|||||||
@ -19,7 +19,7 @@ if TYPE_CHECKING:
|
|||||||
from game.coalition import Coalition
|
from game.coalition import Coalition
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass
|
||||||
class PackageWaypoints:
|
class PackageWaypoints:
|
||||||
join: Point
|
join: Point
|
||||||
ingress: Point
|
ingress: Point
|
||||||
@ -51,10 +51,8 @@ class PackageWaypoints:
|
|||||||
ingress_point_shapely.x, ingress_point_shapely.y
|
ingress_point_shapely.x, ingress_point_shapely.y
|
||||||
)
|
)
|
||||||
|
|
||||||
hdg = package.target.position.heading_between_point(ingress_point)
|
tgt_point = package.target.position
|
||||||
# Generate a waypoint randomly between 7 & 9 NM
|
initial_point = PackageWaypoints.get_initial_point(ingress_point, tgt_point)
|
||||||
dist = nautical_miles(random.random() * 2 + 7).meters
|
|
||||||
initial_point = package.target.position.point_from_heading(hdg, dist)
|
|
||||||
|
|
||||||
join_point = JoinZoneGeometry(
|
join_point = JoinZoneGeometry(
|
||||||
package.target.position,
|
package.target.position,
|
||||||
@ -79,3 +77,11 @@ class PackageWaypoints:
|
|||||||
WaypointBuilder.perturb(join_point),
|
WaypointBuilder.perturb(join_point),
|
||||||
refuel_point,
|
refuel_point,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_initial_point(ingress_point: Point, tgt_point: Point) -> Point:
|
||||||
|
hdg = tgt_point.heading_between_point(ingress_point)
|
||||||
|
# Generate a waypoint randomly between 7 & 9 NM
|
||||||
|
dist = nautical_miles(random.random() * 2 + 7).meters
|
||||||
|
initial_point = tgt_point.point_from_heading(hdg, dist)
|
||||||
|
return initial_point
|
||||||
|
|||||||
@ -78,5 +78,32 @@ def set_position(
|
|||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail=f"Could not find PackageModel owning {flight}",
|
detail=f"Could not find PackageModel owning {flight}",
|
||||||
)
|
)
|
||||||
|
events = GameUpdateEvents()
|
||||||
|
update_package_waypoints_if_primary_flight(waypoint, flight, events)
|
||||||
package_model.update_tot()
|
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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user