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

@@ -1305,7 +1305,7 @@ class FlightPlanBuilder:
for group in location.groups:
if group.units:
targets.append(
StrikeTarget(f"{group.name} at {location.name}", group)
StrikeTarget(f"{group.group_name} at {location.name}", group)
)
elif isinstance(location, Convoy):
targets.append(StrikeTarget(location.name, location))
@@ -1318,7 +1318,7 @@ class FlightPlanBuilder:
@staticmethod
def anti_ship_targets_for_tgo(tgo: NavalGroundObject) -> List[StrikeTarget]:
return [StrikeTarget(f"{g.name} at {tgo.name}", g) for g in tgo.groups]
return [StrikeTarget(f"{g.group_name} at {tgo.name}", g) for g in tgo.groups]
def generate_anti_ship(self, flight: Flight) -> StrikeFlightPlan:
"""Generates an anti-ship flight plan.

View File

@@ -5,7 +5,7 @@ import random
from enum import Enum
from typing import Dict, List, TYPE_CHECKING
from game.data.groundunitclass import GroundUnitClass
from game.data.units import UnitClass
from game.dcs.groundunittype import GroundUnitType
from game.theater import ControlPoint
from gen.ground_forces.combat_stance import CombatStance
@@ -100,28 +100,28 @@ class GroundPlanner:
# Create combat groups and assign them randomly to each enemy CP
for unit_type in self.cp.base.armor:
unit_class = unit_type.unit_class
if unit_class is GroundUnitClass.Tank:
if unit_class is UnitClass.Tank:
collection = self.tank_groups
role = CombatGroupRole.TANK
elif unit_class is GroundUnitClass.Apc:
elif unit_class is UnitClass.Apc:
collection = self.apc_group
role = CombatGroupRole.APC
elif unit_class is GroundUnitClass.Artillery:
elif unit_class is UnitClass.Artillery:
collection = self.art_group
role = CombatGroupRole.ARTILLERY
elif unit_class is GroundUnitClass.Ifv:
elif unit_class is UnitClass.Ifv:
collection = self.ifv_group
role = CombatGroupRole.IFV
elif unit_class is GroundUnitClass.Logistics:
elif unit_class is UnitClass.Logistics:
collection = self.logi_groups
role = CombatGroupRole.LOGI
elif unit_class is GroundUnitClass.Atgm:
elif unit_class is UnitClass.Atgm:
collection = self.atgm_group
role = CombatGroupRole.ATGM
elif unit_class is GroundUnitClass.Shorads:
elif unit_class is UnitClass.SHORAD:
collection = self.shorad_groups
role = CombatGroupRole.SHORAD
elif unit_class is GroundUnitClass.Recon:
elif unit_class is UnitClass.Recon:
collection = self.recon_groups
role = CombatGroupRole.RECON
else:

File diff suppressed because it is too large Load Diff