mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Allow user-made custom injected weapons setup
This commit is contained in:
parent
da75f41b01
commit
53122ff149
@ -17,6 +17,7 @@ from dcs.weapons_data import weapon_ids
|
|||||||
from game.data.units import UnitClass
|
from game.data.units import UnitClass
|
||||||
from game.dcs.unitproperty import UnitProperty
|
from game.dcs.unitproperty import UnitProperty
|
||||||
from game.dcs.unittype import UnitType
|
from game.dcs.unittype import UnitType
|
||||||
|
from game.persistency import user_custom_weapon_injections_dir
|
||||||
from game.radio.channels import (
|
from game.radio.channels import (
|
||||||
ApacheChannelNamer,
|
ApacheChannelNamer,
|
||||||
ChannelNamer,
|
ChannelNamer,
|
||||||
@ -465,6 +466,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
task_priorities[FlightType.SEAD_SWEEP] = task_priorities[FlightType.SEAD]
|
task_priorities[FlightType.SEAD_SWEEP] = task_priorities[FlightType.SEAD]
|
||||||
|
|
||||||
cls._custom_weapon_injections(aircraft, data)
|
cls._custom_weapon_injections(aircraft, data)
|
||||||
|
cls._user_weapon_injections(aircraft)
|
||||||
|
|
||||||
for variant in data.get("variants", [aircraft.id]):
|
for variant in data.get("variants", [aircraft.id]):
|
||||||
yield AircraftType(
|
yield AircraftType(
|
||||||
@ -522,5 +524,14 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
][0]
|
][0]
|
||||||
setattr(pylon, w, (pylon_number, weapon))
|
setattr(pylon, w, (pylon_number, weapon))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _user_weapon_injections(aircraft):
|
||||||
|
data_path = user_custom_weapon_injections_dir() / f"{aircraft.id}.yaml"
|
||||||
|
if not data_path.exists():
|
||||||
|
return
|
||||||
|
with data_path.open(encoding="utf-8") as data_file:
|
||||||
|
data = yaml.safe_load(data_file)
|
||||||
|
AircraftType._custom_weapon_injections(aircraft, data)
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
return hash(self.name)
|
return hash(self.name)
|
||||||
|
|||||||
@ -87,6 +87,10 @@ def payloads_dir(backup: bool = False) -> Path:
|
|||||||
return payloads
|
return payloads
|
||||||
|
|
||||||
|
|
||||||
|
def user_custom_weapon_injections_dir() -> Path:
|
||||||
|
return base_path() / "Retribution" / "WeaponInjections"
|
||||||
|
|
||||||
|
|
||||||
def save_dir() -> Path:
|
def save_dir() -> Path:
|
||||||
return base_path() / "Retribution" / "Saves"
|
return base_path() / "Retribution" / "Saves"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user