mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Serialize warehouses & support for dynamic slots/cargo
This commit is contained in:
parent
75dd67a145
commit
0d56c271df
@ -10,6 +10,8 @@ from dcs import Mission, Point
|
||||
from dcs.coalition import Coalition
|
||||
from dcs.countries import country_dict
|
||||
from dcs.task import OptReactOnThreat
|
||||
from dcs.terrain import Airport
|
||||
from dcs.unit import Static
|
||||
|
||||
from game.atcdata import AtcData
|
||||
from game.dcs.beacons import Beacons
|
||||
@ -112,8 +114,8 @@ class MissionGenerator:
|
||||
|
||||
self.notify_info_generators()
|
||||
|
||||
# TODO: Shouldn't this be first?
|
||||
namegen.reset_numbers()
|
||||
self.generate_warehouses()
|
||||
self.mission.save(output)
|
||||
|
||||
return self.unit_map
|
||||
@ -347,3 +349,32 @@ class MissionGenerator:
|
||||
self.mission.groundControl.blue_tactical_commander = commanders
|
||||
self.mission.groundControl.blue_jtac = settings.jtac_count
|
||||
self.mission.groundControl.blue_observer = settings.observer_count
|
||||
|
||||
def generate_warehouses(self) -> None:
|
||||
settings = self.game.settings
|
||||
for tmu in self.unit_map.theater_objects.values():
|
||||
if (
|
||||
tmu.theater_unit.is_ship
|
||||
or
|
||||
isinstance(tmu.dcs_unit, Static)
|
||||
and tmu.dcs_unit.category in ["Warehouses", "Heliports"]
|
||||
):
|
||||
# We'll serialize more than is actually necessary
|
||||
# DCS will filter out warehouses as dynamic spawns so no need to worry there
|
||||
# thus, if we serialize a ship as a warehouse that's not supported, DCS will filter it out
|
||||
warehouse = Airport(
|
||||
tmu.theater_unit.position,
|
||||
self.mission.terrain,
|
||||
).dict()
|
||||
warehouse["coalition"] = "blue" if tmu.theater_unit.ground_object.coalition.player else "red"
|
||||
warehouse["dynamicCargo"] = settings.dynamic_cargo
|
||||
if tmu.theater_unit.is_ship or tmu.dcs_unit.category == "Heliports": # type: ignore
|
||||
warehouse["dynamicSpawn"] = settings.dynamic_slots
|
||||
warehouse["allowHotStart"] = settings.dynamic_slots_hot
|
||||
self.mission.warehouses.warehouses[tmu.dcs_unit.id] = warehouse
|
||||
|
||||
# configure dynamic spawn, hot start of DS & dynamic cargo for airfields
|
||||
for ap in self.mission.terrain.airports.values():
|
||||
ap.dynamic_spawn = settings.dynamic_slots
|
||||
ap.allow_hot_start = settings.dynamic_slots_hot
|
||||
ap.dynamic_cargo = settings.dynamic_cargo
|
||||
|
||||
@ -38,6 +38,7 @@ from dcs.task import (
|
||||
FireAtPoint,
|
||||
OptAlarmState,
|
||||
)
|
||||
from dcs.terrain import Airport
|
||||
from dcs.translation import String
|
||||
from dcs.triggers import (
|
||||
Event,
|
||||
@ -843,6 +844,14 @@ class HelipadGenerator:
|
||||
else:
|
||||
self.helipads.append(sg)
|
||||
|
||||
warehouse = Airport(
|
||||
pad.position,
|
||||
self.m.terrain,
|
||||
).dict()
|
||||
warehouse["coalition"] = "blue" if self.cp.coalition.player else "red"
|
||||
# configure dynamic spawn + hot start of DS, plus dynamic cargo?
|
||||
self.m.warehouses.warehouses[pad.id] = warehouse
|
||||
|
||||
# Generate a FARP Ammo and Fuel stack for each pad
|
||||
self.m.static_group(
|
||||
country=country,
|
||||
|
||||
@ -893,6 +893,34 @@ class Settings:
|
||||
" and reapplied at split/racetrack end for applicable flights. "
|
||||
),
|
||||
)
|
||||
dynamic_slots: bool = boolean_option(
|
||||
"Dynamic slots",
|
||||
MISSION_GENERATOR_PAGE,
|
||||
GAMEPLAY_SECTION,
|
||||
default=False,
|
||||
detail=(
|
||||
"Enables dynamic slots. Please note that losses from dynamic slots won't be registered."
|
||||
),
|
||||
)
|
||||
dynamic_slots_hot: bool = boolean_option(
|
||||
"Allow dynamic slot hot start",
|
||||
MISSION_GENERATOR_PAGE,
|
||||
GAMEPLAY_SECTION,
|
||||
default=True,
|
||||
detail=(
|
||||
"Enables hot start for dynamic slots."
|
||||
),
|
||||
)
|
||||
dynamic_cargo: bool = boolean_option(
|
||||
"Dynamic cargo",
|
||||
MISSION_GENERATOR_PAGE,
|
||||
GAMEPLAY_SECTION,
|
||||
default=True,
|
||||
detail=(
|
||||
"Enables dynamic cargo for airfields, ships, FARPs & warehouses."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# Performance
|
||||
perf_smoke_gen: bool = boolean_option(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user