Decoupling and generalization of templates

Improvement for factions and templates which will allow decoupling of the templates from the actual units
- Implement UnitGroup class which matches unit_types and possible templates as the needed abstraction layer for decoupling.
- Refactor UnitType, Add ShipUnitType and all ships we currently use
- Remove serialized template.json and migrated to multiple yaml templates (one for each template) and multiple .miz
- Reorganized a lot of templates and started with generalization of many types (AAA, Flak, SHORAD, Navy)
- Fixed a lot of bugs from the previous reworks (group name generation, strike targets...)
- Reorganized the faction file completly. removed redundant lists, added presets for complex groups / families of units like sams
- Reworked the building template handling. Some templates are unused like "village"
- Reworked how groups from templates can be merged again for the dcs group creation (e.g. the skynet plugin requires them to be in the same group)
- Allow to define alternative tasks
This commit is contained in:
RndName
2022-01-29 00:42:58 +01:00
parent daf4704fe7
commit 60c8c80480
27 changed files with 1481 additions and 958 deletions

View File

@@ -48,6 +48,7 @@ from .theatergroundobject import (
GroundUnit,
)
from ..ato.starttype import StartType
from ..data.units import UnitClass
from ..dcs.aircrafttype import AircraftType
from ..dcs.groundunittype import GroundUnitType
from ..utils import nautical_miles
@@ -521,20 +522,13 @@ class ControlPoint(MissionTarget, ABC):
ControlPointType.LHA_GROUP,
]:
for g in self.ground_objects:
if isinstance(g, CarrierGroundObject):
for group in g.groups:
for u in group.units:
if unit_type_from_name(u.type) in [
Forrestal,
Stennis,
KUZNECOW,
]:
return group.name
elif isinstance(g, LhaGroundObject):
for group in g.groups:
for u in group.units:
if unit_type_from_name(u.type) in [LHA_Tarawa]:
return group.name
for group in g.groups:
for u in group.units:
if u.unit_type and u.unit_type.unit_class in [
UnitClass.AircraftCarrier,
UnitClass.HelicopterCarrier,
]:
return group.group_name
return None
# TODO: Should be Airbase specific.
@@ -668,6 +662,7 @@ class ControlPoint(MissionTarget, ABC):
self._retreat_squadron(game, squadron)
def depopulate_uncapturable_tgos(self) -> None:
# TODO Rework this.
for tgo in self.connected_objectives:
if not tgo.capturable:
tgo.clear()