mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Introduce pylon ejector for Sufa mod
Will prevent the user having to restart Retribution
This commit is contained in:
parent
e86fc60b41
commit
533057a0cc
@ -32,7 +32,7 @@ from game.dcs.countries import country_with_name
|
||||
from game.dcs.groundunittype import GroundUnitType
|
||||
from game.dcs.shipunittype import ShipUnitType
|
||||
from game.dcs.unittype import UnitType
|
||||
from pydcs_extensions.f16i_idf.f16i_idf import inject_F16I
|
||||
from pydcs_extensions.f16i_idf.f16i_idf import inject_F16I, eject_F16I
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.theater.start_generator import ModSettings
|
||||
@ -336,6 +336,7 @@ class Faction:
|
||||
self.remove_aircraft("F-16D_52_NS")
|
||||
self.remove_aircraft("F-16D_Barak_30")
|
||||
self.remove_aircraft("F-16D_Barak_40")
|
||||
eject_F16I()
|
||||
else:
|
||||
inject_F16I()
|
||||
if not mod_settings.f22_raptor:
|
||||
|
||||
@ -5,7 +5,7 @@ from dcs.planes import F_16C_50, PlaneType
|
||||
from dcs.weapons_data import Weapons
|
||||
|
||||
from game.modsupport import planemod
|
||||
from pydcs_extensions.pylon_injector import inject_pylon
|
||||
from pydcs_extensions.pylon_injector import inject_pylon, eject_pylon
|
||||
from pydcs_extensions.weapon_injector import inject_weapons
|
||||
|
||||
|
||||
@ -388,7 +388,20 @@ def inject_F16I() -> None:
|
||||
F_16C_50.Pylon14 = Pylon14
|
||||
F_16C_50.Pylon15 = Pylon15
|
||||
F_16C_50.Pylon16 = Pylon16
|
||||
F_16C_50.Pylon16 = Pylon17
|
||||
F_16C_50.Pylon17 = Pylon17
|
||||
|
||||
|
||||
def eject_F16I() -> None:
|
||||
F_16C_50.pylons = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}
|
||||
|
||||
# Injects modified weapons from the IDF Mods Project F-16I Sufa
|
||||
# into pydcs databases via introspection.
|
||||
eject_pylon(F_16C_50.Pylon4, F16IDFPylon4)
|
||||
eject_pylon(F_16C_50.Pylon6, F16IDFPylon6)
|
||||
|
||||
for p in [13, 14, 15, 16, 17]:
|
||||
if hasattr(F_16C_50, f"Pylon{p}"):
|
||||
delattr(F_16C_50, f"Pylon{p}")
|
||||
|
||||
|
||||
@planemod
|
||||
|
||||
@ -15,3 +15,19 @@ def inject_pylon(to_pylon: Any, from_pylon: Any) -> None:
|
||||
continue
|
||||
if isinstance(value, Tuple):
|
||||
setattr(to_pylon, key, value)
|
||||
|
||||
|
||||
def eject_pylon(to_pylon: Any, from_pylon: Any) -> None:
|
||||
"""
|
||||
Eject weapons/ordnance added by mods into the pylons of existing aircraft.
|
||||
This is done to support mods such as the CJS Super Hornet, which modify aircraft
|
||||
that exist in stock DCS. Ornance is ejected pydcs aircraft classes via introspection
|
||||
:param to_pylon: The pydcs pylon class of the target aircraft
|
||||
:param from_pylon: The custom pylon class containing tuples with added weapon info
|
||||
:return: None
|
||||
"""
|
||||
for key, value in from_pylon.__dict__.items():
|
||||
if key.startswith("__"):
|
||||
continue
|
||||
if isinstance(value, Tuple) and hasattr(to_pylon, key):
|
||||
delattr(to_pylon, key)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user