Refactor ground objects and prepare template system

- completly refactored the way TGO handles groups and replaced the usage of the pydcs ground groups (vehicle, ship, static) with an own Group and Unit class.
- this allows us to only take care of dcs group generation during miz generation, where it should have always been.
- We can now have any type of unit (even statics) in the same logic ground group we handle in liberation. this is independent from the dcs group handling. the dcs group will only be genarted when takeoff is pressed.
- Refactored the unitmap and the scenery object handling to adopt to changes that now TGOs can hold all Units we want.
- Cleaned up many many many lines of uneeded hacks to build stuff around dcs groups.
- Removed IDs for TGOs as the names we generate are unique and for liberation to work we need no ids. Unique IDs for dcs will be generated for the units and groups only.
This commit is contained in:
RndName
2022-01-18 09:56:04 +01:00
parent 6baf36c587
commit d154069877
28 changed files with 603 additions and 745 deletions

View File

@@ -46,9 +46,9 @@ from game.theater import (
TheaterGroundObject,
)
from game.theater.theatergroundobject import (
BuildingGroundObject,
EwrGroundObject,
NavalGroundObject,
GroundUnit,
)
from game.typeguard import self_type_guard
from game.utils import Distance, Heading, Speed, feet, knots, meters, nautical_miles
@@ -1086,7 +1086,7 @@ class FlightPlanBuilder:
self,
flight: Flight,
# TODO: Custom targets should be an attribute of the flight.
custom_targets: Optional[List[Unit]] = None,
custom_targets: Optional[List[GroundUnit]] = None,
) -> None:
"""Creates a default flight plan for the given mission."""
if flight not in self.package.flights:
@@ -1106,7 +1106,7 @@ class FlightPlanBuilder:
) from ex
def generate_flight_plan(
self, flight: Flight, custom_targets: Optional[List[Unit]]
self, flight: Flight, custom_targets: Optional[List[GroundUnit]]
) -> FlightPlan:
# TODO: Flesh out mission types.
task = flight.flight_type
@@ -1207,16 +1207,9 @@ class FlightPlanBuilder:
raise InvalidObjectiveLocation(flight.flight_type, location)
targets: List[StrikeTarget] = []
if isinstance(location, BuildingGroundObject):
# A building "group" is implemented as multiple TGOs with the same name.
for building in location.strike_targets:
targets.append(StrikeTarget(building.category, building))
else:
# TODO: Replace with DEAD?
# Strike missions on SEAD targets target units.
for g in location.groups:
for j, u in enumerate(g.units):
targets.append(StrikeTarget(f"{u.type} #{j}", u))
for j, u in enumerate(location.strike_targets):
targets.append(StrikeTarget(f"{u.type} #{j}", u))
return self.strike_flightplan(
flight, location, FlightWaypointType.INGRESS_STRIKE, targets
@@ -1675,7 +1668,7 @@ class FlightPlanBuilder:
)
def generate_dead(
self, flight: Flight, custom_targets: Optional[List[Unit]]
self, flight: Flight, custom_targets: Optional[List[GroundUnit]]
) -> StrikeFlightPlan:
"""Generate a DEAD flight at a given location.
@@ -1745,7 +1738,7 @@ class FlightPlanBuilder:
)
def generate_sead(
self, flight: Flight, custom_targets: Optional[List[Unit]]
self, flight: Flight, custom_targets: Optional[List[GroundUnit]]
) -> StrikeFlightPlan:
"""Generate a SEAD flight at a given location.

View File

@@ -1,5 +1,4 @@
from __future__ import annotations
import logging
import random
from dataclasses import dataclass
@@ -11,12 +10,9 @@ from typing import (
TYPE_CHECKING,
Tuple,
Union,
Any,
)
from dcs.mapping import Point
from dcs.unit import Unit
from dcs.unitgroup import VehicleGroup, ShipGroup
from game.theater import (
ControlPoint,
@@ -32,14 +28,13 @@ if TYPE_CHECKING:
from game.ato.flight import Flight
from game.coalition import Coalition
from game.transfers import MultiGroupTransport
from game.theater.theatergroundobject import GroundUnit, GroundGroup
@dataclass(frozen=True)
class StrikeTarget:
name: str
target: Union[
VehicleGroup, TheaterGroundObject[Any], Unit, ShipGroup, MultiGroupTransport
]
target: Union[TheaterGroundObject, GroundGroup, GroundUnit, MultiGroupTransport]
class WaypointBuilder: