Added separate base images for carriers

Forrestal, Supercarrier (CVN-75), Kuznetsov, Kuznetsov (2017/Supercarrier) and Type 071 Yuzhao.

Resolves #1292
This commit is contained in:
MetalStormGhost 2021-11-23 16:37:02 +02:00 committed by RndName
parent 759b934184
commit 4b89220a7b
No known key found for this signature in database
GPG Key ID: 5EF516FD9537F7C0
16 changed files with 90 additions and 48 deletions

View File

@ -17,15 +17,7 @@ from dcs.action import DoScript, SceneryDestructionZone
from dcs.condition import MapObjectIsDead from dcs.condition import MapObjectIsDead
from dcs.country import Country from dcs.country import Country
from dcs.point import StaticPoint from dcs.point import StaticPoint
from dcs.ships import (
CVN_71,
CVN_72,
CVN_73,
CVN_75,
CV_1143_5,
KUZNECOW,
Stennis,
)
from dcs.statics import Fortification from dcs.statics import Fortification
from dcs.task import ( from dcs.task import (
ActivateBeaconCommand, ActivateBeaconCommand,
@ -361,9 +353,14 @@ class GenericCarrierGenerator(GroundObjectGenerator):
# Set Carrier Specific Options # Set Carrier Specific Options
if g_id == 0: if g_id == 0:
# Correct unit type for the carrier. # Get Correct unit type for the carrier.
# This is only used for the super carrier setting # This will upgrade to super carrier if option is enabled
ship_group.units[0].type = self.get_carrier_type(group).id carrier_type = self.carrier_type
if carrier_type is None:
raise RuntimeError(
f"Error generating carrier group for {self.control_point.name}"
)
ship_group.units[0].type = carrier_type.id
tacan = self.tacan_registry.alloc_for_band( tacan = self.tacan_registry.alloc_for_band(
TacanBand.X, TacanUsage.TransmitReceive TacanBand.X, TacanUsage.TransmitReceive
) )
@ -374,11 +371,9 @@ class GenericCarrierGenerator(GroundObjectGenerator):
brc or Heading.from_degrees(0), atc, tacan, tacan_callsign, icls brc or Heading.from_degrees(0), atc, tacan, tacan_callsign, icls
) )
def get_carrier_type(self, group: TheaterGroup) -> Type[ShipType]: @property
carrier_type = group.units[0].type def carrier_type(self) -> Optional[Type[ShipType]]:
if issubclass(carrier_type, ShipType): return self.control_point.get_carrier_group_type()
return carrier_type
raise RuntimeError(f"First unit of TGO {group.name} is no Ship")
def steam_into_wind(self, group: ShipGroup) -> Optional[Heading]: def steam_into_wind(self, group: ShipGroup) -> Optional[Heading]:
wind = self.game.conditions.weather.wind.at_0m wind = self.game.conditions.weather.wind.at_0m
@ -445,32 +440,6 @@ class GenericCarrierGenerator(GroundObjectGenerator):
class CarrierGenerator(GenericCarrierGenerator): class CarrierGenerator(GenericCarrierGenerator):
"""Generator for CV(N) groups.""" """Generator for CV(N) groups."""
def get_carrier_type(self, group: TheaterGroup) -> Type[ShipType]:
unit_type = super().get_carrier_type(group)
if self.game.settings.supercarrier:
unit_type = self.upgrade_to_supercarrier(unit_type, self.control_point.name)
return unit_type
@staticmethod
def upgrade_to_supercarrier(unit: Type[ShipType], name: str) -> Type[ShipType]:
if unit == Stennis:
if name == "CVN-71 Theodore Roosevelt":
return CVN_71
elif name == "CVN-72 Abraham Lincoln":
return CVN_72
elif name == "CVN-73 George Washington":
return CVN_73
elif name == "CVN-75 Harry S. Truman":
return CVN_75
elif name == "Carrier Strike Group 8":
return CVN_75
else:
return CVN_71
elif unit == KUZNECOW:
return CV_1143_5
else:
return unit
def tacan_callsign(self) -> str: def tacan_callsign(self) -> str:
# TODO: Assign these properly. # TODO: Assign these properly.
return random.choice( return random.choice(

View File

@ -21,13 +21,26 @@ from typing import (
Set, Set,
TYPE_CHECKING, TYPE_CHECKING,
Tuple, Tuple,
Type,
) )
from uuid import UUID from uuid import UUID
from dcs.mapping import Point from dcs.mapping import Point
from dcs.ships import Forrestal, KUZNECOW, LHA_Tarawa, Stennis, Type_071
from dcs.terrain.terrain import Airport, ParkingSlot from dcs.terrain.terrain import Airport, ParkingSlot
from dcs.unitgroup import ShipGroup, StaticGroup from dcs.unitgroup import ShipGroup, StaticGroup
from dcs.unittype import ShipType
from dcs.ships import (
CVN_71,
CVN_72,
CVN_73,
CVN_75,
CV_1143_5,
KUZNECOW,
Stennis,
Forrestal,
LHA_Tarawa,
Type_071,
)
from game.ato.closestairfields import ObjectiveDistanceCache from game.ato.closestairfields import ObjectiveDistanceCache
from game.ground_forces.combat_stance import CombatStance from game.ground_forces.combat_stance import CombatStance
@ -612,6 +625,60 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC):
return group.group_name return group.group_name
return None return None
def get_carrier_group_type(
self, always_supercarrier: bool = False
) -> Optional[Type[ShipType]]:
"""
Get the carrier group type if the airbase is a carrier. Arguments:
always_supercarrier: True if should always return the supercarrier type, False if should only
return the supercarrier type when the supercarrier option is enabled in settings.
:return: Carrier group type
"""
if self.cptype in [
ControlPointType.AIRCRAFT_CARRIER_GROUP,
ControlPointType.LHA_GROUP,
]:
for g in self.ground_objects:
for group in g.groups:
u = group.units[0]
carrier_type = u.type
if (
u.unit_type
and u.unit_type.unit_class
in [
UnitClass.AIRCRAFT_CARRIER,
UnitClass.HELICOPTER_CARRIER,
]
and issubclass(carrier_type, ShipType)
):
if (
self.coalition.game.settings.supercarrier
or always_supercarrier
):
return self.upgrade_to_supercarrier(carrier_type, self.name)
return carrier_type
return None
@staticmethod
def upgrade_to_supercarrier(unit: Type[ShipType], name: str) -> Type[ShipType]:
if unit == Stennis:
if name == "CVN-71 Theodore Roosevelt":
return CVN_71
elif name == "CVN-72 Abraham Lincoln":
return CVN_72
elif name == "CVN-73 George Washington":
return CVN_73
elif name == "CVN-75 Harry S. Truman":
return CVN_75
elif name == "Carrier Strike Group 8":
return CVN_75
else:
return CVN_71
elif unit == KUZNECOW:
return CV_1143_5
else:
return unit
# TODO: Should be Airbase specific. # TODO: Should be Airbase specific.
def is_connected(self, to: ControlPoint) -> bool: def is_connected(self, to: ControlPoint) -> bool:
return to in self.connected_points return to in self.connected_points

View File

@ -3,10 +3,13 @@ from __future__ import annotations
import itertools import itertools
import uuid import uuid
from abc import ABC from abc import ABC
from typing import Type
from typing import Any, Iterator, List, Optional, TYPE_CHECKING from typing import Any, Iterator, List, Optional, TYPE_CHECKING
from dcs.mapping import Point from dcs.mapping import Point
from dcs.unittype import VehicleType from dcs.unittype import VehicleType
from dcs.unittype import ShipType
from shapely.geometry import Point as ShapelyPoint from shapely.geometry import Point as ShapelyPoint
from game.sidc import ( from game.sidc import (

View File

@ -9,6 +9,7 @@ from PySide2.QtWidgets import (
QVBoxLayout, QVBoxLayout,
QWidget, QWidget,
) )
from dcs.ships import Stennis, KUZNECOW
from game import Game from game import Game
from game.ato.flighttype import FlightType from game.ato.flighttype import FlightType
@ -240,10 +241,12 @@ class QBaseMenu2(QDialog):
GameUpdateSignal.get_instance().updateGame(self.game_model.game) GameUpdateSignal.get_instance().updateGame(self.game_model.game)
def get_base_image(self): def get_base_image(self):
if self.cp.cptype == ControlPointType.AIRCRAFT_CARRIER_GROUP: if (
return "./resources/ui/carrier.png" self.cp.cptype == ControlPointType.AIRCRAFT_CARRIER_GROUP
elif self.cp.cptype == ControlPointType.LHA_GROUP: or self.cp.cptype == ControlPointType.LHA_GROUP
return "./resources/ui/lha.png" ):
carrier_type = self.cp.get_carrier_group_type(always_supercarrier=True)
return f"./resources/ui/units/ships/{carrier_type.id}.png"
elif self.cp.cptype == ControlPointType.FOB and self.cp.has_helipads: elif self.cp.cptype == ControlPointType.FOB and self.cp.has_helipads:
return "./resources/ui/heliport.png" return "./resources/ui/heliport.png"
elif self.cp.cptype == ControlPointType.FOB: elif self.cp.cptype == ControlPointType.FOB:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB