mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Reduce fuel for fast-forwarded player flights.
This only has an effect for aircraft for which we have fuel consumption data, but that's fine. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1681
This commit is contained in:
@@ -19,30 +19,30 @@ from dcs.mapping import Point
|
||||
from dcs.unit import Unit
|
||||
from shapely.geometry import Point as ShapelyPoint
|
||||
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.ato.flightwaypoint import FlightWaypoint
|
||||
from game.ato.flightwaypointtype import FlightWaypointType
|
||||
from game.ato.starttype import StartType
|
||||
from game.data.doctrine import Doctrine
|
||||
from game.dcs.aircrafttype import FuelConsumption
|
||||
from game.flightplan import IpZoneGeometry, JoinZoneGeometry, HoldZoneGeometry
|
||||
from game.flightplan import HoldZoneGeometry, IpZoneGeometry, JoinZoneGeometry
|
||||
from game.theater import (
|
||||
Airfield,
|
||||
ConflictTheater,
|
||||
ControlPoint,
|
||||
FrontLine,
|
||||
MissionTarget,
|
||||
NavalControlPoint,
|
||||
SamGroundObject,
|
||||
TheaterGroundObject,
|
||||
NavalControlPoint,
|
||||
ConflictTheater,
|
||||
)
|
||||
from game.theater.theatergroundobject import (
|
||||
BuildingGroundObject,
|
||||
EwrGroundObject,
|
||||
NavalGroundObject,
|
||||
BuildingGroundObject,
|
||||
)
|
||||
from game.utils import Distance, Heading, Speed, feet, meters, nautical_miles, knots
|
||||
from game.utils import Distance, Heading, Speed, feet, knots, meters, nautical_miles
|
||||
from .closestairfields import ObjectiveDistanceCache
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.ato.flightwaypointtype import FlightWaypointType
|
||||
from game.ato.flightwaypoint import FlightWaypoint
|
||||
from .traveltime import GroundSpeed, TravelTime
|
||||
from .waypointbuilder import StrikeTarget, WaypointBuilder
|
||||
|
||||
@@ -126,6 +126,30 @@ class FlightPlan:
|
||||
def speed_between_waypoints(self, a: FlightWaypoint, b: FlightWaypoint) -> Speed:
|
||||
return self.best_speed_between_waypoints(a, b)
|
||||
|
||||
@property
|
||||
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||
raise NotImplementedError
|
||||
|
||||
def fuel_consumption_between_points(
|
||||
self, a: FlightWaypoint, b: FlightWaypoint
|
||||
) -> Optional[float]:
|
||||
ppm = self.fuel_rate_to_between_points(a, b)
|
||||
if ppm is None:
|
||||
return None
|
||||
distance = meters(a.position.distance_to_point(b.position))
|
||||
return distance.nautical_miles * ppm
|
||||
|
||||
def fuel_rate_to_between_points(
|
||||
self, a: FlightWaypoint, b: FlightWaypoint
|
||||
) -> Optional[float]:
|
||||
if self.flight.unit_type.fuel_consumption is None:
|
||||
return None
|
||||
if a.waypoint_type is FlightWaypointType.TAKEOFF:
|
||||
return self.flight.unit_type.fuel_consumption.climb
|
||||
if b in self.combat_speed_waypoints:
|
||||
return self.flight.unit_type.fuel_consumption.combat
|
||||
return self.flight.unit_type.fuel_consumption.cruise
|
||||
|
||||
@property
|
||||
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
||||
"""The waypoint that is associated with the package TOT, or None.
|
||||
@@ -343,9 +367,13 @@ class FormationFlightPlan(LoiterFlightPlan):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def package_speed_waypoints(self) -> Set[FlightWaypoint]:
|
||||
def package_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||
return self.package_speed_waypoints
|
||||
|
||||
@property
|
||||
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
||||
raise NotImplementedError
|
||||
@@ -595,7 +623,7 @@ class StrikeFlightPlan(FormationFlightPlan):
|
||||
yield self.bullseye
|
||||
|
||||
@property
|
||||
def package_speed_waypoints(self) -> Set[FlightWaypoint]:
|
||||
def package_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||
return {
|
||||
self.ingress,
|
||||
self.split,
|
||||
|
||||
Reference in New Issue
Block a user