mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
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.
18 lines
590 B
Python
18 lines
590 B
Python
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
|