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:
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
|
||||
Reference in New Issue
Block a user