mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Streamlining
This commit is contained in:
@@ -111,11 +111,14 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
||||
is_f18 = self.squadron.aircraft.dcs_unit_type.id == FA_18C_hornet.id
|
||||
on_land = not self.squadron.location.is_fleet
|
||||
if on_land and is_f18 and self.coalition.game.settings.atflir_autoswap:
|
||||
self.loadout.pylons[F18_TGP_PYLON] = Weapon.with_clsid(
|
||||
str(
|
||||
FA_18C_hornet.Pylon4.AN_AAQ_28_LITENING___Targeting_Pod_[1]["clsid"]
|
||||
for fm in self.roster.members:
|
||||
fm.loadout.pylons[F18_TGP_PYLON] = Weapon.with_clsid(
|
||||
str(
|
||||
FA_18C_hornet.Pylon4.AN_AAQ_28_LITENING___Targeting_Pod_[1][
|
||||
"clsid"
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def flight_plan(self) -> FlightPlan[Any]:
|
||||
|
||||
@@ -10,7 +10,7 @@ from .loadouts import Loadout
|
||||
from ..data.weapons import Weapon
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.squadrons import Pilot
|
||||
from game.squadrons import Pilot, Squadron
|
||||
from .flight import Flight
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@ class FlightMembers(IFlightRoster):
|
||||
self.members: list[FlightMember] = []
|
||||
self.resize(initial_size)
|
||||
|
||||
@property
|
||||
def squadron(self) -> Squadron:
|
||||
return self.flight.squadron
|
||||
|
||||
@staticmethod
|
||||
def from_roster(flight: Flight, roster: FlightRoster) -> FlightMembers:
|
||||
members = FlightMembers(flight)
|
||||
loadout = Loadout.default_for(flight)
|
||||
if flight.squadron.aircraft.name == "F-15I Ra'am":
|
||||
loadout.pylons[16] = Weapon.with_clsid(
|
||||
"{IDF_MODS_PROJECT_F-15I_Raam_Dome}"
|
||||
)
|
||||
loadout.pylons[16] = Weapon.with_clsid("{IDF_MODS_PROJECT_F-15I_Raam_Dome}")
|
||||
members.members = [FlightMember(p, loadout) for p in roster.pilots]
|
||||
return members
|
||||
|
||||
@@ -61,9 +63,7 @@ class FlightMembers(IFlightRoster):
|
||||
else:
|
||||
loadout = Loadout.default_for(self.flight)
|
||||
if self.flight.squadron.aircraft.name == "F-15I Ra'am":
|
||||
loadout.pylons[16] = Weapon.with_clsid(
|
||||
"{IDF_MODS_PROJECT_F-15I_Raam_Dome}"
|
||||
)
|
||||
loadout.pylons[16] = Weapon.with_clsid("{IDF_MODS_PROJECT_F-15I_Raam_Dome}")
|
||||
for _ in range(new_size - self.max_size):
|
||||
member = FlightMember(self.flight.squadron.claim_available_pilot(), loadout)
|
||||
member.use_custom_loadout = loadout.is_custom
|
||||
|
||||
@@ -11,10 +11,14 @@ if TYPE_CHECKING:
|
||||
|
||||
class FlightRoster(IFlightRoster):
|
||||
def __init__(self, squadron: Squadron, initial_size: int = 0) -> None:
|
||||
self.squadron = squadron
|
||||
self._squadron = squadron
|
||||
self.pilots: list[Optional[Pilot]] = []
|
||||
self.resize(initial_size)
|
||||
|
||||
@property
|
||||
def squadron(self) -> Squadron:
|
||||
return self._squadron
|
||||
|
||||
def iter_pilots(self) -> Iterator[Pilot | None]:
|
||||
yield from self.pilots
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from abc import ABC, abstractmethod
|
||||
from typing import Optional, TYPE_CHECKING, Iterator
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.squadrons import Pilot
|
||||
from game.squadrons import Pilot, Squadron
|
||||
|
||||
|
||||
class IFlightRoster(ABC):
|
||||
@@ -16,6 +16,11 @@ class IFlightRoster(ABC):
|
||||
def pilot_at(self, idx: int) -> Pilot | None:
|
||||
...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def squadron(self) -> Squadron:
|
||||
...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def max_size(self) -> int:
|
||||
|
||||
@@ -275,7 +275,7 @@ class AircraftGenerator:
|
||||
or flight.client_count
|
||||
and (
|
||||
not self.need_ecm
|
||||
or flight.loadout.has_weapon_of_type(WeaponType.JAMMER)
|
||||
or flight.any_member_has_weapon_of_type(WeaponType.JAMMER)
|
||||
)
|
||||
):
|
||||
self.ewrj_package_dict[id(flight.package)].append(group)
|
||||
|
||||
@@ -149,7 +149,7 @@ class FlightGroupSpawner:
|
||||
raise RuntimeError(
|
||||
f"Cannot spawn fixed-wing aircraft at {cp} because of insufficient ground spawn slots."
|
||||
)
|
||||
pilot_count = len(self.flight.roster.pilots)
|
||||
pilot_count = len(self.flight.roster.members)
|
||||
if (
|
||||
not is_heli
|
||||
and self.flight.roster.player_count != pilot_count
|
||||
|
||||
Reference in New Issue
Block a user