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.country import Country
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.task import (
ActivateBeaconCommand,
@ -361,9 +353,14 @@ class GenericCarrierGenerator(GroundObjectGenerator):
# Set Carrier Specific Options
if g_id == 0:
# Correct unit type for the carrier.
# This is only used for the super carrier setting
ship_group.units[0].type = self.get_carrier_type(group).id
# Get Correct unit type for the carrier.
# This will upgrade to super carrier if option is enabled
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(
TacanBand.X, TacanUsage.TransmitReceive
)
@ -374,11 +371,9 @@ class GenericCarrierGenerator(GroundObjectGenerator):
brc or Heading.from_degrees(0), atc, tacan, tacan_callsign, icls
)
def get_carrier_type(self, group: TheaterGroup) -> Type[ShipType]:
carrier_type = group.units[0].type
if issubclass(carrier_type, ShipType):
return carrier_type
raise RuntimeError(f"First unit of TGO {group.name} is no Ship")
@property
def carrier_type(self) -> Optional[Type[ShipType]]:
return self.control_point.get_carrier_group_type()
def steam_into_wind(self, group: ShipGroup) -> Optional[Heading]:
wind = self.game.conditions.weather.wind.at_0m
@ -445,32 +440,6 @@ class GenericCarrierGenerator(GroundObjectGenerator):
class CarrierGenerator(GenericCarrierGenerator):
"""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:
# TODO: Assign these properly.
return random.choice(

View File

@ -21,13 +21,26 @@ from typing import (
Set,
TYPE_CHECKING,
Tuple,
Type,
)
from uuid import UUID
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.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.ground_forces.combat_stance import CombatStance
@ -612,6 +625,60 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC):
return group.group_name
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.
def is_connected(self, to: ControlPoint) -> bool:
return to in self.connected_points

View File

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

View File

@ -9,6 +9,7 @@ from PySide2.QtWidgets import (
QVBoxLayout,
QWidget,
)
from dcs.ships import Stennis, KUZNECOW
from game import Game
from game.ato.flighttype import FlightType
@ -240,10 +241,12 @@ class QBaseMenu2(QDialog):
GameUpdateSignal.get_instance().updateGame(self.game_model.game)
def get_base_image(self):
if self.cp.cptype == ControlPointType.AIRCRAFT_CARRIER_GROUP:
return "./resources/ui/carrier.png"
elif self.cp.cptype == ControlPointType.LHA_GROUP:
return "./resources/ui/lha.png"
if (
self.cp.cptype == ControlPointType.AIRCRAFT_CARRIER_GROUP
or self.cp.cptype == ControlPointType.LHA_GROUP
):
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:
return "./resources/ui/heliport.png"
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