mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Show EWRs as detection range, not threat range.
This commit is contained in:
parent
8827f7df34
commit
73998dbde0
@ -26,8 +26,6 @@ from dcs.mapping import point_from_heading
|
|||||||
|
|
||||||
import qt_ui.uiconstants as CONST
|
import qt_ui.uiconstants as CONST
|
||||||
from game import Game, db
|
from game import Game, db
|
||||||
from game.data.aaa_db import AAA_UNITS
|
|
||||||
from game.data.radar_db import UNITS_WITH_RADAR
|
|
||||||
from game.utils import meter_to_feet
|
from game.utils import meter_to_feet
|
||||||
from game.weather import TimeOfDay
|
from game.weather import TimeOfDay
|
||||||
from gen import Conflict
|
from gen import Conflict
|
||||||
@ -41,7 +39,7 @@ from qt_ui.widgets.map.QMapControlPoint import QMapControlPoint
|
|||||||
from qt_ui.widgets.map.QMapGroundObject import QMapGroundObject
|
from qt_ui.widgets.map.QMapGroundObject import QMapGroundObject
|
||||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||||
from theater import ControlPoint, FrontLine
|
from theater import ControlPoint, FrontLine
|
||||||
from theater.theatergroundobject import EwrGroundObject
|
from theater.theatergroundobject import EwrGroundObject, TheaterGroundObject
|
||||||
|
|
||||||
|
|
||||||
class QLiberationMap(QGraphicsView):
|
class QLiberationMap(QGraphicsView):
|
||||||
@ -164,6 +162,21 @@ class QLiberationMap(QGraphicsView):
|
|||||||
self.reload_scene()
|
self.reload_scene()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def aa_ranges(ground_object: TheaterGroundObject) -> Tuple[int, int]:
|
||||||
|
detection_range = 0
|
||||||
|
threat_range = 0
|
||||||
|
for g in ground_object.groups:
|
||||||
|
for u in g.units:
|
||||||
|
unit = db.unit_type_from_name(u.type)
|
||||||
|
if unit is None:
|
||||||
|
logging.error(f"Unknown unit type {u.type}")
|
||||||
|
continue
|
||||||
|
detection_range = max(detection_range,
|
||||||
|
getattr(unit, "detection_range"))
|
||||||
|
threat_range = max(threat_range,
|
||||||
|
getattr(unit, "threat_range"))
|
||||||
|
return detection_range, threat_range
|
||||||
|
|
||||||
def reload_scene(self):
|
def reload_scene(self):
|
||||||
scene = self.scene()
|
scene = self.scene()
|
||||||
@ -223,35 +236,25 @@ class QLiberationMap(QGraphicsView):
|
|||||||
(DisplayOptions.enemy_sam_ranges and not cp.captured))
|
(DisplayOptions.enemy_sam_ranges and not cp.captured))
|
||||||
|
|
||||||
if is_aa and should_display:
|
if is_aa and should_display:
|
||||||
threat_range = 0
|
detection_range, threat_range = self.aa_ranges(
|
||||||
detection_range = 0
|
ground_object
|
||||||
can_fire = False
|
)
|
||||||
if ground_object.groups:
|
if threat_range:
|
||||||
for g in ground_object.groups:
|
|
||||||
for u in g.units:
|
|
||||||
unit = db.unit_type_from_name(u.type)
|
|
||||||
if unit in UNITS_WITH_RADAR or unit in AAA_UNITS:
|
|
||||||
can_fire = True
|
|
||||||
if unit.detection_range and unit.detection_range > detection_range:
|
|
||||||
detection_range = unit.detection_range
|
|
||||||
if unit.threat_range and unit.threat_range > threat_range:
|
|
||||||
threat_range = unit.threat_range
|
|
||||||
if can_fire:
|
|
||||||
threat_pos = self._transform_point(Point(ground_object.position.x+threat_range,
|
threat_pos = self._transform_point(Point(ground_object.position.x+threat_range,
|
||||||
ground_object.position.y+threat_range))
|
ground_object.position.y+threat_range))
|
||||||
detection_pos = self._transform_point(Point(ground_object.position.x+detection_range,
|
|
||||||
ground_object.position.y+detection_range))
|
|
||||||
threat_radius = Point(*go_pos).distance_to_point(Point(*threat_pos))
|
threat_radius = Point(*go_pos).distance_to_point(Point(*threat_pos))
|
||||||
detection_radius = Point(*go_pos).distance_to_point(Point(*detection_pos))
|
|
||||||
|
|
||||||
# Add detection range circle
|
|
||||||
if DisplayOptions.detection_range:
|
|
||||||
scene.addEllipse(go_pos[0] - detection_radius/2 + 7, go_pos[1] - detection_radius/2 + 6,
|
|
||||||
detection_radius, detection_radius, self.detection_pen(cp.captured))
|
|
||||||
|
|
||||||
# Add threat range circle
|
# Add threat range circle
|
||||||
scene.addEllipse(go_pos[0] - threat_radius / 2 + 7, go_pos[1] - threat_radius / 2 + 6,
|
scene.addEllipse(go_pos[0] - threat_radius / 2 + 7, go_pos[1] - threat_radius / 2 + 6,
|
||||||
threat_radius, threat_radius, self.threat_pen(cp.captured))
|
threat_radius, threat_radius, self.threat_pen(cp.captured))
|
||||||
|
if detection_range:
|
||||||
|
# Add detection range circle
|
||||||
|
detection_pos = self._transform_point(Point(ground_object.position.x+detection_range,
|
||||||
|
ground_object.position.y+detection_range))
|
||||||
|
detection_radius = Point(*go_pos).distance_to_point(Point(*detection_pos))
|
||||||
|
if DisplayOptions.detection_range:
|
||||||
|
scene.addEllipse(go_pos[0] - detection_radius/2 + 7, go_pos[1] - detection_radius/2 + 6,
|
||||||
|
detection_radius, detection_radius, self.detection_pen(cp.captured))
|
||||||
added_objects.append(ground_object.obj_name)
|
added_objects.append(ground_object.obj_name)
|
||||||
|
|
||||||
for cp in self.game.theater.enemy_points():
|
for cp in self.game.theater.enemy_points():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user