mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Ignore range when manually using auto-create
This commit is contained in:
parent
15218d0241
commit
eb6afbdf02
@ -38,7 +38,7 @@ class PackageBuilder:
|
||||
self.laser_code_registry = laser_code_registry
|
||||
self.start_type = start_type
|
||||
|
||||
def plan_flight(self, plan: ProposedFlight) -> bool:
|
||||
def plan_flight(self, plan: ProposedFlight, ignore_range: bool) -> bool:
|
||||
"""Allocates aircraft for the given flight and adds them to the package.
|
||||
|
||||
If no suitable aircraft are available, False is returned. If the failed
|
||||
@ -55,6 +55,7 @@ class PackageBuilder:
|
||||
heli,
|
||||
this_turn=True,
|
||||
preferred_type=plan.preferred_type,
|
||||
ignore_range=ignore_range,
|
||||
)
|
||||
if squadron is None:
|
||||
return False
|
||||
|
||||
@ -81,8 +81,9 @@ class PackageFulfiller:
|
||||
builder: PackageBuilder,
|
||||
missing_types: Set[FlightType],
|
||||
purchase_multiplier: int,
|
||||
ignore_range: bool = False,
|
||||
) -> None:
|
||||
if not builder.plan_flight(flight):
|
||||
if not builder.plan_flight(flight, ignore_range):
|
||||
pf = builder.package.primary_flight
|
||||
heli = pf.is_helo if pf else False
|
||||
missing_types.add(flight.task)
|
||||
@ -138,6 +139,7 @@ class PackageFulfiller:
|
||||
purchase_multiplier: int,
|
||||
now: datetime,
|
||||
tracer: MultiEventTracer,
|
||||
ignore_range: bool = False,
|
||||
) -> Optional[Package]:
|
||||
"""Allocates aircraft for a proposed mission and adds it to the ATO."""
|
||||
builder = PackageBuilder(
|
||||
@ -175,6 +177,7 @@ class PackageFulfiller:
|
||||
builder,
|
||||
missing_types,
|
||||
purchase_multiplier,
|
||||
ignore_range,
|
||||
)
|
||||
|
||||
if missing_types:
|
||||
|
||||
@ -52,6 +52,7 @@ class AirWing:
|
||||
heli: bool,
|
||||
this_turn: bool,
|
||||
preferred_type: Optional[AircraftType] = None,
|
||||
ignore_range: bool = False,
|
||||
) -> list[Squadron]:
|
||||
airfield_cache = ObjectiveDistanceCache.get_closest_airfields(location)
|
||||
best_aircraft = AircraftType.priority_list_for_task(task)
|
||||
@ -68,7 +69,7 @@ class AirWing:
|
||||
]
|
||||
for squadron in squadrons:
|
||||
if squadron.can_auto_assign_mission(
|
||||
location, task, size, heli, this_turn
|
||||
location, task, size, heli, this_turn, ignore_range
|
||||
):
|
||||
capable_at_base.append(squadron)
|
||||
if squadron.aircraft not in best_aircraft:
|
||||
@ -100,9 +101,10 @@ class AirWing:
|
||||
heli: bool,
|
||||
this_turn: bool,
|
||||
preferred_type: Optional[AircraftType] = None,
|
||||
ignore_range: bool = False,
|
||||
) -> Optional[Squadron]:
|
||||
for squadron in self.best_squadrons_for(
|
||||
location, task, size, heli, this_turn, preferred_type
|
||||
location, task, size, heli, this_turn, preferred_type, ignore_range
|
||||
):
|
||||
return squadron
|
||||
return None
|
||||
|
||||
@ -281,6 +281,7 @@ class Squadron:
|
||||
size: int,
|
||||
heli: bool,
|
||||
this_turn: bool,
|
||||
ignore_range: bool = False,
|
||||
) -> bool:
|
||||
if (
|
||||
self.location.cptype.name in ["FOB", "FARP"]
|
||||
@ -304,6 +305,9 @@ class Squadron:
|
||||
if heli and task == FlightType.REFUELING:
|
||||
return False
|
||||
|
||||
if ignore_range:
|
||||
return True
|
||||
|
||||
distance_to_target = meters(location.distance_to(self.location))
|
||||
return distance_to_target <= self.aircraft.max_mission_range
|
||||
|
||||
|
||||
@ -223,7 +223,7 @@ class QAutoCreateDialog(QDialog):
|
||||
self.game.settings,
|
||||
)
|
||||
now = self.package_model.game_model.sim_controller.current_time_in_sim
|
||||
package = pff.plan_mission(pm, 1, now, tracer)
|
||||
package = pff.plan_mission(pm, 1, now, tracer, ignore_range=True)
|
||||
if package:
|
||||
package.set_tot_asap(now)
|
||||
self.package = package
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user