Allow factions to specify their cargo ship type.

https://github.com/dcs-liberation/dcs_liberation/issues/3039
This commit is contained in:
Dan Albert
2023-06-26 21:30:44 -07:00
committed by Raffson
parent d3b0ae30eb
commit a343bdef23
3 changed files with 13 additions and 4 deletions

View File

@@ -45,6 +45,9 @@ class Faction:
#: choose the default locale.
locales: Optional[List[str]]
# The unit type to spawn for cargo shipping.
cargo_ship: ShipUnitType
# Country used by this faction
country: Country
@@ -194,7 +197,11 @@ class Faction:
"country ID"
) from ex
faction = Faction(locales=json.get("locales"), country=country)
faction = Faction(
locales=json.get("locales"),
country=country,
cargo_ship=ShipUnitType.named(json.get("cargo_ship", "Handy Wind"))
)
faction.name = json.get("name", "")
if not faction.name:

View File

@@ -4,7 +4,6 @@ import itertools
from typing import TYPE_CHECKING
from dcs import Mission
from dcs.ships import HandyWind
from dcs.unitgroup import ShipGroup
from game.transfers import CargoShip
@@ -30,15 +29,16 @@ class CargoShipGenerator:
self.generate_cargo_ship(ship)
def generate_cargo_ship(self, ship: CargoShip) -> ShipGroup:
coalition = self.game.coalition_for(ship.player_owned)
waypoints = ship.route
country = self.game.coalition_for(ship.player_owned).faction.country
country = coalition.faction.country
country = self.mission.country(country.name)
group = self.mission.ship_group(
country,
ship.name,
HandyWind,
coalition.faction.cargo_ship.dcs_unit_type,
position=waypoints[0],
group_size=1,
)