dcs-retribution/game/ato/flightmember.py
Raffson 64d60e5ccf
Datalink support + pydcs update
Support for 2.9.10.4160, though without Iraq, but finally there's some basic support for datalink...
2024-12-16 03:08:40 +01:00

50 lines
1.6 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional
from game.ato.loadouts import Loadout
from game.lasercodes import LaserCode
if TYPE_CHECKING:
from game.squadrons import Pilot
class FlightMember:
def __init__(self, pilot: Pilot | None, loadout: Loadout) -> None:
self.pilot = pilot
self.loadout = loadout
self.use_custom_loadout = False
self.tgp_laser_code: LaserCode | None = None
self.weapon_laser_code: LaserCode | None = None
self.properties: dict[str, bool | float | int | str] = {}
self.livery: Optional[str] = None
self.use_livery_set: bool = True
def __setstate__(self, state: dict[str, Any]) -> None:
new_state = FlightMember(state["pilot"], state["loadout"])
new_state.__dict__.update(state)
self.__dict__.update(new_state.__dict__)
def assign_tgp_laser_code(self, code: LaserCode) -> None:
if self.tgp_laser_code is not None:
raise RuntimeError(
f"{self.pilot} already has already been assigned laser code "
f"{self.tgp_laser_code}"
)
self.tgp_laser_code = code
def release_tgp_laser_code(self) -> None:
if self.tgp_laser_code is None:
raise RuntimeError(f"{self.pilot} has no assigned laser code")
if self.weapon_laser_code == self.tgp_laser_code:
self.weapon_laser_code = None
self.tgp_laser_code.release()
self.tgp_laser_code = None
@property
def is_player(self) -> bool:
if self.pilot is None:
return False
return self.pilot.player