mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Ability to set callsigns
This commit is contained in:
@@ -14,7 +14,9 @@ from .flightmembers import FlightMembers
|
||||
from .flightroster import FlightRoster
|
||||
from .flightstate import FlightState, Navigating, Uninitialized
|
||||
from .flightstate.killed import Killed
|
||||
from .flighttype import FlightType
|
||||
from .loadouts import Weapon
|
||||
from ..radio.CallsignContainer import CallsignContainer
|
||||
from ..radio.RadioFrequencyContainer import RadioFrequencyContainer
|
||||
from ..radio.TacanContainer import TacanContainer
|
||||
from ..radio.radios import RadioFrequency
|
||||
@@ -36,7 +38,6 @@ if TYPE_CHECKING:
|
||||
from game.data.weapons import WeaponType
|
||||
from .flightmember import FlightMember
|
||||
from .flightplans.flightplan import FlightPlan
|
||||
from .flighttype import FlightType
|
||||
from .flightwaypoint import FlightWaypoint
|
||||
from .package import Package
|
||||
from .starttype import StartType
|
||||
@@ -44,7 +45,9 @@ if TYPE_CHECKING:
|
||||
F18_TGP_PYLON: int = 4
|
||||
|
||||
|
||||
class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
||||
class Flight(
|
||||
SidcDescribable, RadioFrequencyContainer, TacanContainer, CallsignContainer
|
||||
):
|
||||
def __init__(
|
||||
self,
|
||||
package: Package,
|
||||
@@ -58,7 +61,7 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
||||
roster: Optional[FlightRoster] = None,
|
||||
frequency: Optional[RadioFrequency] = None,
|
||||
channel: Optional[TacanChannel] = None,
|
||||
callsign: Optional[str] = None,
|
||||
callsign_tcn: Optional[str] = None,
|
||||
claim_inv: bool = True,
|
||||
) -> None:
|
||||
self.id = uuid.uuid4()
|
||||
@@ -81,7 +84,7 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
||||
self.frequency = frequency
|
||||
if self.unit_type.dcs_unit_type.tacan:
|
||||
self.tacan = channel
|
||||
self.tcn_name = callsign
|
||||
self.tcn_name = callsign_tcn
|
||||
|
||||
self.initialize_fuel()
|
||||
self.use_same_loadout_for_all_members = True
|
||||
@@ -120,6 +123,22 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def available_callsigns(self) -> List[str]:
|
||||
callsigns = set()
|
||||
dcs_unit = self.squadron.aircraft.dcs_unit_type
|
||||
category = dcs_unit.category
|
||||
category = "Air" if category == "Interceptor" else category
|
||||
for name in self.squadron.coalition.faction.country.callsign[category]:
|
||||
callsigns.add(name)
|
||||
if hasattr(dcs_unit, "callnames"):
|
||||
country_name = self.squadron.coalition.faction.country.name
|
||||
for c in dcs_unit.callnames:
|
||||
if "Combined Joint Task Forces" in country_name or c == country_name:
|
||||
for name in dcs_unit.callnames[c]:
|
||||
callsigns.add(name)
|
||||
return sorted(callsigns)
|
||||
|
||||
@property
|
||||
def flight_plan(self) -> FlightPlan[Any]:
|
||||
return self._flight_plan_builder.get_or_build()
|
||||
|
||||
@@ -266,6 +266,8 @@ class FlightGroupSpawner:
|
||||
start_type=self._start_type_at_airfield(airfield),
|
||||
group_size=self.flight.count,
|
||||
parking_slots=None,
|
||||
callsign_name=self.flight.callsign.name if self.flight.callsign else None,
|
||||
callsign_nr=self.flight.callsign.nr if self.flight.callsign else None,
|
||||
)
|
||||
|
||||
def _generate_over_departure(
|
||||
@@ -299,6 +301,8 @@ class FlightGroupSpawner:
|
||||
speed=speed.kph,
|
||||
maintask=None,
|
||||
group_size=self.flight.count,
|
||||
callsign_name=self.flight.callsign.name if self.flight.callsign else None,
|
||||
callsign_nr=self.flight.callsign.nr if self.flight.callsign else None,
|
||||
)
|
||||
|
||||
group.points[0].alt_type = alt_type
|
||||
@@ -315,6 +319,8 @@ class FlightGroupSpawner:
|
||||
maintask=None,
|
||||
start_type=self._start_type_at_group(at),
|
||||
group_size=self.flight.count,
|
||||
callsign_name=self.flight.callsign.name if self.flight.callsign else None,
|
||||
callsign_nr=self.flight.callsign.nr if self.flight.callsign else None,
|
||||
)
|
||||
|
||||
def _generate_at_cp_helipad(
|
||||
|
||||
20
game/radio/CallsignContainer.py
Normal file
20
game/radio/CallsignContainer.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from abc import abstractmethod
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
class Callsign:
|
||||
name: Optional[str] = None
|
||||
nr: Optional[int] = None
|
||||
|
||||
def __init__(self, name: Optional[str], nr: int) -> None:
|
||||
self.name = name
|
||||
self.nr = nr
|
||||
|
||||
|
||||
class CallsignContainer:
|
||||
callsign: Optional[Callsign] = None
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def available_callsigns(self) -> List[str]:
|
||||
...
|
||||
Reference in New Issue
Block a user