mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Refactor Templates to Layouts, Review and Cleanup
- Fix tgogenerator - Fix UI for ForceGroup and Layouts - Fix ammo depot handling - Split bigger files in smaller meaningful files (TGO, layouts, forces) - Renamed Template to Layout - Renamed GroundGroup to TheaterGroup and GroundUnit to TheaterUnit - Reorganize Layouts and UnitGroups to a ArmedForces class and ForceGroup similar to the AirWing and Squadron - Reworded the UnitClass, GroupRole, GroupTask (adopted to PEP8) and reworked the connection from Role and Task - added comments - added missing unit classes - added temp workaround for missing classes - add repariable property to TheaterUnit - Review and Cleanup Added serialization for loaded templates Loading the templates from the .miz files takes a lot of computation time and in the future there will be more templates added to the system. Therefore a local pickle serialization for the loaded templates was re-added: - The pickle will be created the first time the TemplateLoader will be accessed - Pickle is stored in Liberation SaveDir - Added UI option to (re-)import templates
This commit is contained in:
@@ -1,63 +1,69 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class GroupRole(Enum):
|
||||
Unknow = "Unknown"
|
||||
AntiAir = "AntiAir"
|
||||
Building = "Building"
|
||||
Naval = "Naval"
|
||||
GroundForce = "GroundForce"
|
||||
Defenses = "Defenses"
|
||||
Air = "Air"
|
||||
"""Role of a ForceGroup within the ArmedForces"""
|
||||
|
||||
AIR_DEFENSE = "AntiAir"
|
||||
BUILDING = "Building"
|
||||
DEFENSES = "Defenses"
|
||||
GROUND_FORCE = "GroundForce"
|
||||
NAVAL = "Naval"
|
||||
|
||||
@property
|
||||
def tasks(self) -> list[GroupTask]:
|
||||
return [task for task in GroupTask if task.role == self]
|
||||
|
||||
|
||||
class GroupTask(Enum):
|
||||
EWR = "EarlyWarningRadar"
|
||||
AAA = "AAA"
|
||||
SHORAD = "SHORAD"
|
||||
MERAD = "MERAD"
|
||||
LORAD = "LORAD"
|
||||
AircraftCarrier = "AircraftCarrier"
|
||||
HelicopterCarrier = "HelicopterCarrier"
|
||||
Navy = "Navy"
|
||||
BaseDefense = "BaseDefense" # Ground
|
||||
FrontLine = "FrontLine"
|
||||
Air = "Air"
|
||||
Missile = "Missile"
|
||||
Coastal = "Coastal"
|
||||
Factory = "Factory"
|
||||
Ammo = "Ammo"
|
||||
Oil = "Oil"
|
||||
FOB = "FOB"
|
||||
StrikeTarget = "StrikeTarget"
|
||||
Comms = "Comms"
|
||||
Power = "Power"
|
||||
"""Specific Tasking of a ForceGroup"""
|
||||
|
||||
def __init__(self, description: str, role: GroupRole):
|
||||
self.description = description
|
||||
self.role = role
|
||||
|
||||
ROLE_TASKINGS: dict[GroupRole, list[GroupTask]] = {
|
||||
GroupRole.Unknow: [], # No Tasking
|
||||
GroupRole.AntiAir: [
|
||||
GroupTask.EWR,
|
||||
GroupTask.AAA,
|
||||
GroupTask.SHORAD,
|
||||
GroupTask.MERAD,
|
||||
GroupTask.LORAD,
|
||||
],
|
||||
GroupRole.GroundForce: [GroupTask.BaseDefense, GroupTask.FrontLine],
|
||||
GroupRole.Naval: [
|
||||
GroupTask.AircraftCarrier,
|
||||
GroupTask.HelicopterCarrier,
|
||||
GroupTask.Navy,
|
||||
],
|
||||
GroupRole.Building: [
|
||||
GroupTask.Factory,
|
||||
GroupTask.Ammo,
|
||||
GroupTask.Oil,
|
||||
GroupTask.FOB,
|
||||
GroupTask.StrikeTarget,
|
||||
GroupTask.Comms,
|
||||
GroupTask.Power,
|
||||
],
|
||||
GroupRole.Defenses: [GroupTask.Missile, GroupTask.Coastal],
|
||||
GroupRole.Air: [GroupTask.Air],
|
||||
}
|
||||
@classmethod
|
||||
def by_description(cls, description: str) -> GroupTask:
|
||||
for task in GroupTask:
|
||||
if task.description == description:
|
||||
return task
|
||||
raise RuntimeError(f"GroupTask with description {description} does not exist")
|
||||
|
||||
# ANTI AIR
|
||||
AAA = ("AAA", GroupRole.AIR_DEFENSE)
|
||||
EARLY_WARNING_RADAR = ("EarlyWarningRadar", GroupRole.AIR_DEFENSE)
|
||||
LORAD = ("LORAD", GroupRole.AIR_DEFENSE)
|
||||
MERAD = ("MERAD", GroupRole.AIR_DEFENSE)
|
||||
SHORAD = ("SHORAD", GroupRole.AIR_DEFENSE)
|
||||
|
||||
# NAVAL
|
||||
AIRCRAFT_CARRIER = ("AircraftCarrier", GroupRole.NAVAL)
|
||||
HELICOPTER_CARRIER = ("HelicopterCarrier", GroupRole.NAVAL)
|
||||
NAVY = ("Navy", GroupRole.NAVAL)
|
||||
|
||||
# GROUND FORCES
|
||||
BASE_DEFENSE = ("BaseDefense", GroupRole.GROUND_FORCE)
|
||||
FRONT_LINE = ("FrontLine", GroupRole.GROUND_FORCE)
|
||||
|
||||
# DEFENSES
|
||||
COASTAL = ("Coastal", GroupRole.DEFENSES)
|
||||
MISSILE = ("Missile", GroupRole.DEFENSES)
|
||||
|
||||
# BUILDINGS
|
||||
ALLY_CAMP = ("AllyCamp", GroupRole.BUILDING)
|
||||
AMMO = ("Ammo", GroupRole.BUILDING)
|
||||
COMMS = ("Comms", GroupRole.BUILDING)
|
||||
DERRICK = ("Derrick", GroupRole.BUILDING)
|
||||
FACTORY = ("Factory", GroupRole.BUILDING)
|
||||
FARP = ("Farp", GroupRole.BUILDING)
|
||||
FOB = ("FOB", GroupRole.BUILDING)
|
||||
FUEL = ("Fuel", GroupRole.BUILDING)
|
||||
OFFSHORE_STRIKE_TARGET = ("OffShoreStrikeTarget", GroupRole.BUILDING)
|
||||
OIL = ("Oil", GroupRole.BUILDING)
|
||||
POWER = ("Power", GroupRole.BUILDING)
|
||||
STRIKE_TARGET = ("StrikeTarget", GroupRole.BUILDING)
|
||||
VILLAGE = ("Village", GroupRole.BUILDING)
|
||||
WARE = ("Ware", GroupRole.BUILDING)
|
||||
WW2_BUNKER = ("WW2Bunker", GroupRole.BUILDING)
|
||||
|
||||
Reference in New Issue
Block a user