mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Add livery selection for predefined squadrons.
https://github.com/dcs-liberation/dcs_liberation/issues/276
This commit is contained in:
parent
ac4a7441e9
commit
f36757b650
@ -43,6 +43,7 @@ class Squadron:
|
|||||||
country: str
|
country: str
|
||||||
role: str
|
role: str
|
||||||
aircraft: Type[FlyingType]
|
aircraft: Type[FlyingType]
|
||||||
|
livery: Optional[str]
|
||||||
mission_types: Tuple[FlightType, ...]
|
mission_types: Tuple[FlightType, ...]
|
||||||
pilots: List[Pilot]
|
pilots: List[Pilot]
|
||||||
available_pilots: List[Pilot] = field(init=False, hash=False, compare=False)
|
available_pilots: List[Pilot] = field(init=False, hash=False, compare=False)
|
||||||
@ -117,6 +118,7 @@ class Squadron:
|
|||||||
country=data["country"],
|
country=data["country"],
|
||||||
role=data["role"],
|
role=data["role"],
|
||||||
aircraft=unit_type,
|
aircraft=unit_type,
|
||||||
|
livery=data.get("livery"),
|
||||||
mission_types=tuple(FlightType.from_name(n) for n in data["mission_types"]),
|
mission_types=tuple(FlightType.from_name(n) for n in data["mission_types"]),
|
||||||
pilots=[Pilot(n) for n in data.get("pilots", [])],
|
pilots=[Pilot(n) for n in data.get("pilots", [])],
|
||||||
game=game,
|
game=game,
|
||||||
@ -200,6 +202,7 @@ class AirWing:
|
|||||||
country=game.country_for(player),
|
country=game.country_for(player),
|
||||||
role="Flying Squadron",
|
role="Flying Squadron",
|
||||||
aircraft=aircraft,
|
aircraft=aircraft,
|
||||||
|
livery=None,
|
||||||
mission_types=tuple(FlightType),
|
mission_types=tuple(FlightType),
|
||||||
pilots=[],
|
pilots=[],
|
||||||
game=game,
|
game=game,
|
||||||
|
|||||||
@ -761,6 +761,36 @@ class AircraftConflictGenerator:
|
|||||||
else:
|
else:
|
||||||
unit.set_player()
|
unit.set_player()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def livery_from_db(flight: Flight) -> Optional[str]:
|
||||||
|
return db.PLANE_LIVERY_OVERRIDES.get(flight.unit_type)
|
||||||
|
|
||||||
|
def livery_from_faction(self, flight: Flight) -> Optional[str]:
|
||||||
|
faction = self.game.faction_for(player=flight.departure.captured)
|
||||||
|
if (choices := faction.liveries_overrides.get(flight.unit_type)) is not None:
|
||||||
|
return random.choice(choices)
|
||||||
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def livery_from_squadron(flight: Flight) -> Optional[str]:
|
||||||
|
return flight.squadron.livery
|
||||||
|
|
||||||
|
def livery_for(self, flight: Flight) -> Optional[str]:
|
||||||
|
if (livery := self.livery_from_squadron(flight)) is not None:
|
||||||
|
return livery
|
||||||
|
if (livery := self.livery_from_faction(flight)) is not None:
|
||||||
|
return livery
|
||||||
|
if (livery := self.livery_from_db(flight)) is not None:
|
||||||
|
return livery
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _setup_livery(self, flight: Flight, group: FlyingGroup) -> None:
|
||||||
|
livery = self.livery_for(flight)
|
||||||
|
if livery is None:
|
||||||
|
return
|
||||||
|
for unit in group.units:
|
||||||
|
unit.livery_id = livery
|
||||||
|
|
||||||
def _setup_group(
|
def _setup_group(
|
||||||
self,
|
self,
|
||||||
group: FlyingGroup,
|
group: FlyingGroup,
|
||||||
@ -771,21 +801,7 @@ class AircraftConflictGenerator:
|
|||||||
unit_type = group.units[0].unit_type
|
unit_type = group.units[0].unit_type
|
||||||
|
|
||||||
self._setup_payload(flight, group)
|
self._setup_payload(flight, group)
|
||||||
|
self._setup_livery(flight, group)
|
||||||
if unit_type in db.PLANE_LIVERY_OVERRIDES:
|
|
||||||
for unit_instance in group.units:
|
|
||||||
unit_instance.livery_id = db.PLANE_LIVERY_OVERRIDES[unit_type]
|
|
||||||
|
|
||||||
# Override livery by faction file data
|
|
||||||
if flight.from_cp.captured:
|
|
||||||
faction = self.game.player_faction
|
|
||||||
else:
|
|
||||||
faction = self.game.enemy_faction
|
|
||||||
|
|
||||||
if unit_type in faction.liveries_overrides:
|
|
||||||
livery = random.choice(faction.liveries_overrides[unit_type])
|
|
||||||
for unit_instance in group.units:
|
|
||||||
unit_instance.livery_id = livery
|
|
||||||
|
|
||||||
for unit, pilot in zip(group.units, flight.pilots):
|
for unit, pilot in zip(group.units, flight.pilots):
|
||||||
player = pilot is not None and pilot.player
|
player = pilot is not None and pilot.player
|
||||||
@ -815,7 +831,7 @@ class AircraftConflictGenerator:
|
|||||||
self.flights.append(
|
self.flights.append(
|
||||||
FlightData(
|
FlightData(
|
||||||
package=package,
|
package=package,
|
||||||
country=faction.country,
|
country=self.game.faction_for(player=flight.departure.captured).country,
|
||||||
flight_type=flight.flight_type,
|
flight_type=flight.flight_type,
|
||||||
units=group.units,
|
units=group.units,
|
||||||
size=len(group.units),
|
size=len(group.units),
|
||||||
|
|||||||
@ -4,6 +4,7 @@ nickname: Stingers
|
|||||||
country: USA
|
country: USA
|
||||||
role: Strike Fighter
|
role: Strike Fighter
|
||||||
aircraft: FA-18C_hornet
|
aircraft: FA-18C_hornet
|
||||||
|
livery: VFA-113
|
||||||
mission_types:
|
mission_types:
|
||||||
- Anti-ship
|
- Anti-ship
|
||||||
- BAI
|
- BAI
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user