mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Unfilter the custom waypoint targets.
There doesn't appear to be any reason for us to be poking at implementation details here aside from changing the name from "unit" to "building" for that case. Just iterate over the known strike targets. Making this change uncovered some latent type errors. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2564. (cherry picked from commit 5e7e5e2636c03e5b0da3fccf45b88951a3756059)
This commit is contained in:
parent
b57e30a13c
commit
5f74fd81eb
@ -1,6 +1,5 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Sequence
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Literal, TYPE_CHECKING
|
from typing import Literal, TYPE_CHECKING
|
||||||
@ -12,8 +11,7 @@ from game.theater.theatergroup import TheaterUnit
|
|||||||
from game.utils import Distance, meters
|
from game.utils import Distance, meters
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game.theater import ControlPoint, MissionTarget
|
from game.theater import ControlPoint
|
||||||
|
|
||||||
|
|
||||||
AltitudeReference = Literal["BARO", "RADIO"]
|
AltitudeReference = Literal["BARO", "RADIO"]
|
||||||
|
|
||||||
@ -32,7 +30,7 @@ class FlightWaypoint:
|
|||||||
# having three names. A short and long form is enough.
|
# having three names. A short and long form is enough.
|
||||||
description: str = ""
|
description: str = ""
|
||||||
|
|
||||||
targets: Sequence[MissionTarget | TheaterUnit] = field(default_factory=list)
|
targets: list[TheaterUnit] = field(default_factory=list)
|
||||||
obj_name: str = ""
|
obj_name: str = ""
|
||||||
pretty_name: str = ""
|
pretty_name: str = ""
|
||||||
only_for_player: bool = False
|
only_for_player: bool = False
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
from dcs import Point
|
||||||
from dcs.planes import B_17G, B_52H, Tu_22M3
|
from dcs.planes import B_17G, B_52H, Tu_22M3
|
||||||
from dcs.point import MovingPoint
|
from dcs.point import MovingPoint
|
||||||
from dcs.task import Bombing, OptFormation, WeaponType, Expend
|
from dcs.task import Bombing, Expend, OptFormation, WeaponType
|
||||||
|
|
||||||
from .pydcswaypointbuilder import PydcsWaypointBuilder
|
from .pydcswaypointbuilder import PydcsWaypointBuilder
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ class StrikeIngressBuilder(PydcsWaypointBuilder):
|
|||||||
if not targets:
|
if not targets:
|
||||||
return
|
return
|
||||||
|
|
||||||
center = copy.copy(targets[0].position)
|
center: Point = copy.copy(targets[0].position)
|
||||||
for target in targets[1:]:
|
for target in targets[1:]:
|
||||||
center += target.position
|
center += target.position
|
||||||
center /= len(targets)
|
center /= len(targets)
|
||||||
|
|||||||
@ -7,7 +7,6 @@ from game.missiongenerator.frontlineconflictdescription import (
|
|||||||
FrontLineConflictDescription,
|
FrontLineConflictDescription,
|
||||||
)
|
)
|
||||||
from game.theater.controlpoint import ControlPointType
|
from game.theater.controlpoint import ControlPointType
|
||||||
from game.theater.theatergroundobject import BuildingGroundObject, IadsGroundObject
|
|
||||||
from game.utils import Distance
|
from game.utils import Distance
|
||||||
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox
|
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox
|
||||||
|
|
||||||
@ -81,66 +80,25 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
|||||||
wpt.description = "Frontline"
|
wpt.description = "Frontline"
|
||||||
i = add_model_item(i, model, wpt.pretty_name, wpt)
|
i = add_model_item(i, model, wpt.pretty_name, wpt)
|
||||||
|
|
||||||
if self.include_targets:
|
for tgo in self.game.theater.ground_objects:
|
||||||
for cp in self.game.theater.controlpoints:
|
for target_idx, target in enumerate(tgo.strike_targets):
|
||||||
if (self.include_enemy and not cp.captured) or (
|
wptname = f"[{tgo.obj_name}] : {target.name} #{target_idx}"
|
||||||
self.include_friendly and cp.captured
|
wpt = FlightWaypoint(
|
||||||
):
|
wptname,
|
||||||
for ground_object in cp.ground_objects:
|
FlightWaypointType.CUSTOM,
|
||||||
if not ground_object.is_dead and isinstance(
|
target.position,
|
||||||
ground_object, BuildingGroundObject
|
Distance.from_meters(0),
|
||||||
):
|
)
|
||||||
wpt = FlightWaypoint(
|
wpt.alt_type = "RADIO"
|
||||||
ground_object.waypoint_name,
|
wpt.pretty_name = wptname
|
||||||
FlightWaypointType.CUSTOM,
|
wpt.targets.append(target)
|
||||||
ground_object.position,
|
wpt.obj_name = tgo.obj_name
|
||||||
Distance.from_meters(0),
|
wpt.waypoint_type = FlightWaypointType.CUSTOM
|
||||||
)
|
if tgo.is_friendly(to_player=True):
|
||||||
wpt.alt_type = "RADIO"
|
wpt.description = f"Friendly unit: {target.name}"
|
||||||
wpt.pretty_name = wpt.name
|
else:
|
||||||
wpt.obj_name = ground_object.obj_name
|
wpt.description = f"Enemy unit: {target.name}"
|
||||||
wpt.targets.append(ground_object)
|
i = add_model_item(i, model, wpt.pretty_name, wpt)
|
||||||
if cp.captured:
|
|
||||||
wpt.description = "Friendly Building"
|
|
||||||
else:
|
|
||||||
wpt.description = "Enemy Building"
|
|
||||||
i = add_model_item(i, model, wpt.pretty_name, wpt)
|
|
||||||
|
|
||||||
if self.include_units:
|
|
||||||
for cp in self.game.theater.controlpoints:
|
|
||||||
if (self.include_enemy and not cp.captured) or (
|
|
||||||
self.include_friendly and cp.captured
|
|
||||||
):
|
|
||||||
for ground_object in cp.ground_objects:
|
|
||||||
if not ground_object.is_dead and (
|
|
||||||
isinstance(ground_object, IadsGroundObject)
|
|
||||||
):
|
|
||||||
for g in ground_object.groups:
|
|
||||||
for j, u in enumerate(g.units):
|
|
||||||
wptname = (
|
|
||||||
"["
|
|
||||||
+ str(ground_object.obj_name)
|
|
||||||
+ "] : "
|
|
||||||
+ u.name
|
|
||||||
+ " #"
|
|
||||||
+ str(j)
|
|
||||||
)
|
|
||||||
wpt = FlightWaypoint(
|
|
||||||
wptname,
|
|
||||||
FlightWaypointType.CUSTOM,
|
|
||||||
u.position,
|
|
||||||
Distance.from_meters(0),
|
|
||||||
)
|
|
||||||
wpt.alt_type = "RADIO"
|
|
||||||
wpt.pretty_name = wptname
|
|
||||||
wpt.targets.append(u)
|
|
||||||
wpt.obj_name = ground_object.obj_name
|
|
||||||
wpt.waypoint_type = FlightWaypointType.CUSTOM
|
|
||||||
if cp.captured:
|
|
||||||
wpt.description = "Friendly unit: " + u.name
|
|
||||||
else:
|
|
||||||
wpt.description = "Enemy unit: " + u.name
|
|
||||||
i = add_model_item(i, model, wpt.pretty_name, wpt)
|
|
||||||
|
|
||||||
if self.include_airbases:
|
if self.include_airbases:
|
||||||
for cp in self.game.theater.controlpoints:
|
for cp in self.game.theater.controlpoints:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user