mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Inject mod plane weapons into pydcs.
Adds a simple injector that iterates over attrs of an input class and injects things that look like custom weapons into pydcs's weapons classes. Also updated all current mod aircraft configs to perform the injection.
This commit is contained in:
parent
372bf9d97f
commit
c163e2c981
@ -4,6 +4,8 @@ from dcs import task
|
||||
from dcs.planes import PlaneType
|
||||
from dcs.weapons_data import Weapons
|
||||
|
||||
from pydcs_extensions.weapon_injector import inject_weapons
|
||||
|
||||
|
||||
class WeaponsA4EC:
|
||||
AN_M57__2__TER_ = {
|
||||
@ -432,6 +434,9 @@ class WeaponsA4EC:
|
||||
}
|
||||
|
||||
|
||||
inject_weapons(WeaponsA4EC)
|
||||
|
||||
|
||||
class A_4E_C(PlaneType):
|
||||
id = "A-4E-C"
|
||||
flyable = True
|
||||
|
||||
@ -2,16 +2,17 @@ from enum import Enum
|
||||
|
||||
from dcs import task
|
||||
from dcs.planes import PlaneType
|
||||
from dcs.weapons_data import Weapons, weapon_ids
|
||||
from dcs.weapons_data import Weapons
|
||||
|
||||
from pydcs_extensions.weapon_injector import inject_weapons
|
||||
|
||||
|
||||
class F22AWeapons:
|
||||
AIM_9XX = {"clsid": "{AIM-9XX}", "name": "AIM-9XX", "weight": 85}
|
||||
AIM_120D = {"clsid": "{AIM-120D}", "name": "AIM-120D", "weight": 152}
|
||||
Weapons.AIM_9XX = AIM_9XX
|
||||
Weapons.AIM_120D = AIM_120D
|
||||
weapon_ids["{AIM-9XX}"] = AIM_9XX
|
||||
weapon_ids["{AIM-120D}"] = AIM_120D
|
||||
|
||||
|
||||
inject_weapons(F22AWeapons)
|
||||
|
||||
|
||||
class F_22A(PlaneType):
|
||||
|
||||
@ -4,6 +4,8 @@ from dcs import task
|
||||
from dcs.planes import PlaneType
|
||||
from dcs.weapons_data import Weapons
|
||||
|
||||
from pydcs_extensions.weapon_injector import inject_weapons
|
||||
|
||||
|
||||
class HerculesWeapons:
|
||||
GAU_23A_Chain_Gun__30mm_ = {
|
||||
@ -679,6 +681,9 @@ class HerculesWeapons:
|
||||
}
|
||||
|
||||
|
||||
inject_weapons(HerculesWeapons)
|
||||
|
||||
|
||||
class Hercules(PlaneType):
|
||||
id = "Hercules"
|
||||
flyable = True
|
||||
|
||||
@ -4,6 +4,8 @@ from dcs import task
|
||||
from dcs.planes import PlaneType
|
||||
from dcs.weapons_data import Weapons
|
||||
|
||||
from pydcs_extensions.weapon_injector import inject_weapons
|
||||
|
||||
|
||||
class MB_339PAN_Weapons:
|
||||
ARF8M3_TP = {"clsid": "{ARF8M3_TP}", "name": "ARF8M3 TP", "weight": None}
|
||||
@ -107,6 +109,9 @@ class MB_339PAN_Weapons:
|
||||
}
|
||||
|
||||
|
||||
inject_weapons(MB_339PAN_Weapons)
|
||||
|
||||
|
||||
class MB_339PAN(PlaneType):
|
||||
id = "MB-339PAN"
|
||||
flyable = True
|
||||
|
||||
@ -4,6 +4,8 @@ from dcs import task
|
||||
from dcs.planes import PlaneType
|
||||
from dcs.weapons_data import Weapons
|
||||
|
||||
from pydcs_extensions.weapon_injector import inject_weapons
|
||||
|
||||
|
||||
class Su57Weapons:
|
||||
Kh_59MK2 = {"clsid": "{KH_59MK2}", "name": "Kh-59MK2", "weight": None}
|
||||
@ -18,6 +20,9 @@ class Su57Weapons:
|
||||
}
|
||||
|
||||
|
||||
inject_weapons(Su57Weapons)
|
||||
|
||||
|
||||
class Su_57(PlaneType):
|
||||
id = "Su-57"
|
||||
flyable = True
|
||||
|
||||
17
pydcs_extensions/weapon_injector.py
Normal file
17
pydcs_extensions/weapon_injector.py
Normal file
@ -0,0 +1,17 @@
|
||||
from typing import List, Any
|
||||
|
||||
from dcs.weapons_data import Weapons, weapon_ids
|
||||
|
||||
|
||||
def inject_weapons(weapon_class: Any) -> None:
|
||||
"""
|
||||
Inject custom weapons from mods into pydcs weapons databases via introspection
|
||||
:param weapon_class: The custom weapons class containing dictionaries with weapon info
|
||||
:return: None
|
||||
"""
|
||||
for key, value in weapon_class.__dict__.items():
|
||||
if key.startswith("__"):
|
||||
continue
|
||||
if isinstance(value, dict) and value.get("clsid"):
|
||||
setattr(Weapons, key, value)
|
||||
weapon_ids[value["clsid"]] = value
|
||||
Loading…
x
Reference in New Issue
Block a user