Handle edge case where aircraft have built in TPGs

This commit is contained in:
zhexu14 2023-04-29 12:03:35 +10:00 committed by Dan Albert
parent b50d82feff
commit aa2a888ed0
4 changed files with 11 additions and 0 deletions

View File

@ -92,6 +92,9 @@ class Loadout:
if self.has_weapon_of_type(WeaponType.TGP):
return
if unit_type.has_built_in_target_pod:
return
new_pylons = dict(self.pylons)
for pylon_number, weapon in self.pylons.items():
if weapon is not None and weapon.weapon_group.type is WeaponType.LGB:

View File

@ -200,6 +200,11 @@ class AircraftType(UnitType[Type[FlyingType]]):
task_priorities: dict[FlightType, int]
# Set to True when aircraft mounts a targeting pod by default i.e. the pod does
# not take up a weapons station. If True, do not replace LGBs with dumb bombs
# when no TGP is mounted on any station.
has_built_in_target_pod: bool
_by_name: ClassVar[dict[str, AircraftType]] = {}
_by_unit_type: ClassVar[dict[type[FlyingType], list[AircraftType]]] = defaultdict(
list
@ -480,6 +485,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
cabin_size=data.get("cabin_size", 10 if aircraft.helicopter else 0),
can_carry_crates=data.get("can_carry_crates", aircraft.helicopter),
task_priorities=task_priorities,
has_built_in_target_pod=data.get("has_built_in_target_pod", False),
)
def __hash__(self) -> int:

View File

@ -19,3 +19,4 @@ variants:
F-117A Nighthawk: {}
tasks:
Strike: 710
has_built_in_target_pod: true

View File

@ -22,3 +22,4 @@ tasks:
OCA/Runway: 630
Strike: 640
TARCAP: 240
has_built_in_target_pod: true