mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Cleanup helipad creation and heli spawn
This commit is contained in:
parent
6f8c30ec81
commit
ad0d3412fb
@ -50,7 +50,7 @@ class AircraftGenerator:
|
||||
laser_code_registry: LaserCodeRegistry,
|
||||
unit_map: UnitMap,
|
||||
air_support: AirSupport,
|
||||
helipads: dict[ControlPoint, list[StaticGroup]],
|
||||
helipads: dict[ControlPoint, StaticGroup],
|
||||
) -> None:
|
||||
self.mission = mission
|
||||
self.settings = settings
|
||||
|
||||
@ -44,7 +44,7 @@ class FlightGroupSpawner:
|
||||
flight: Flight,
|
||||
country: Country,
|
||||
mission: Mission,
|
||||
helipads: dict[ControlPoint, list[StaticGroup]],
|
||||
helipads: dict[ControlPoint, StaticGroup],
|
||||
) -> None:
|
||||
self.flight = flight
|
||||
self.country = country
|
||||
@ -230,30 +230,17 @@ class FlightGroupSpawner:
|
||||
|
||||
def _generate_at_cp_helipad(self, name: str, cp: ControlPoint) -> FlyingGroup[Any]:
|
||||
try:
|
||||
# helipad = self.helipads[cp][0]
|
||||
helipad = self.helipads[cp].pop()
|
||||
helipad = self.helipads[cp]
|
||||
except IndexError as ex:
|
||||
raise NoParkingSlotError(f"Not enough helipads available at {cp}") from ex
|
||||
raise NoParkingSlotError()
|
||||
|
||||
group = self._generate_at_group(name, helipad)
|
||||
|
||||
# Note : A bit dirty, need better support in pydcs
|
||||
group.points[0].action = PointAction.FromParkingArea
|
||||
group.points[0].type = "TakeOffParking"
|
||||
group.units[0].heading = helipad.units[0].heading
|
||||
if self.start_type is not StartType.COLD:
|
||||
group.points[0].action = PointAction.FromParkingArea
|
||||
group.points[0].type = "TakeOffParkingHot"
|
||||
|
||||
for i in range(self.flight.count - 1):
|
||||
try:
|
||||
helipad = self.helipads[cp].pop()
|
||||
except IndexError as ex:
|
||||
raise NoParkingSlotError(
|
||||
f"Not enough helipads available at {cp}"
|
||||
) from ex
|
||||
group.units[1 + i].position = copy.copy(helipad.position)
|
||||
group.units[1 + i].heading = helipad.units[0].heading
|
||||
for i in range(self.flight.count):
|
||||
group.units[i].position = helipad.units[i].position
|
||||
group.units[i].heading = helipad.units[i].heading
|
||||
return group
|
||||
|
||||
def dcs_start_type(self) -> DcsStartType:
|
||||
|
||||
@ -36,7 +36,7 @@ from dcs.task import (
|
||||
)
|
||||
from dcs.translation import String
|
||||
from dcs.triggers import Event, TriggerOnce, TriggerStart, TriggerZone
|
||||
from dcs.unit import Unit
|
||||
from dcs.unit import Unit, InvisibleFARP
|
||||
from dcs.unitgroup import MovingGroup, ShipGroup, StaticGroup, VehicleGroup
|
||||
from dcs.unittype import ShipType, VehicleType
|
||||
from dcs.vehicles import vehicle_map
|
||||
@ -524,7 +524,12 @@ class HelipadGenerator:
|
||||
self.game = game
|
||||
self.radio_registry = radio_registry
|
||||
self.tacan_registry = tacan_registry
|
||||
self.helipads: list[StaticGroup] = []
|
||||
self.helipads = self.m.farp(
|
||||
self.m.country(self.game.neutral_country.name),
|
||||
self.cp.name + "_helipad",
|
||||
self.cp.position,
|
||||
farp_type="InvisibleFARP",
|
||||
)
|
||||
|
||||
def generate(self) -> None:
|
||||
# This gets called for every control point, so we don't want to add an empty group (causes DCS mission editor to crash)
|
||||
@ -532,19 +537,20 @@ class HelipadGenerator:
|
||||
return
|
||||
# Note: Helipad are generated as neutral object in order not to interfer with
|
||||
# capture triggers
|
||||
neutral_country = self.m.country(self.game.neutral_country.name)
|
||||
country = self.m.country(self.game.coalition_for(self.cp.captured).country_name)
|
||||
|
||||
for i, helipad in enumerate(self.cp.helipads):
|
||||
heading = helipad.heading.degrees
|
||||
name_i = self.cp.name + "_helipad" + "_" + str(i)
|
||||
pad = self.m.farp(
|
||||
neutral_country,
|
||||
name_i,
|
||||
helipad,
|
||||
heading=heading,
|
||||
farp_type="InvisibleFARP",
|
||||
)
|
||||
self.helipads.append(pad)
|
||||
if i == 0:
|
||||
pad = self.helipads.units[0]
|
||||
else:
|
||||
# Create a new Helipad Unit
|
||||
pad = InvisibleFARP(self.m.terrain, unit_id=self.m.next_unit_id())
|
||||
self.helipads.add_unit(pad)
|
||||
pad.name = name_i
|
||||
pad.position = helipad
|
||||
pad.heading = heading
|
||||
# Generate a FARP Ammo and Fuel stack for each pad
|
||||
self.m.static_group(
|
||||
country=country,
|
||||
@ -595,7 +601,7 @@ class TgoGenerator:
|
||||
self.unit_map = unit_map
|
||||
self.icls_alloc = iter(range(1, 21))
|
||||
self.runways: Dict[str, RunwayData] = {}
|
||||
self.helipads: dict[ControlPoint, list[StaticGroup]] = defaultdict(list)
|
||||
self.helipads: dict[ControlPoint, StaticGroup] = {}
|
||||
|
||||
def generate(self) -> None:
|
||||
for cp in self.game.theater.controlpoints:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user