From 274f689f704169faa7839bf292ef5d1e40b0800d Mon Sep 17 00:00:00 2001 From: RndName Date: Tue, 22 Mar 2022 19:42:45 +0100 Subject: [PATCH] Fix Heading to conflict calculation --- game/armedforces/forcegroup.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/game/armedforces/forcegroup.py b/game/armedforces/forcegroup.py index c9ac092b..15c17685 100644 --- a/game/armedforces/forcegroup.py +++ b/game/armedforces/forcegroup.py @@ -16,7 +16,7 @@ from game.dcs.helpers import static_type_from_name from game.dcs.shipunittype import ShipUnitType from game.dcs.unittype import UnitType from game.layout import LAYOUTS -from game.layout.layout import AntiAirLayout, TgoLayout, TgoLayoutGroup +from game.layout.layout import TgoLayout, TgoLayoutGroup from game.point_with_heading import PointWithHeading from game.theater.theatergroup import TheaterGroup @@ -243,6 +243,11 @@ class ForceGroup: ) ) + # A layout has to be created with an orientation of 0 deg. + # Therefore the the clockwise rotation angle is always the heading of the + # groundobject without any calculation needed + rotation = ground_object.heading + # Assign UniqueID, name and align relative to ground_object for unit in units: unit.id = game.next_unit_id() @@ -250,20 +255,16 @@ class ForceGroup: unit.position = PointWithHeading.from_point( ground_object.position + unit.position, # Align heading to GroundObject defined by the campaign designer - unit.position.heading + ground_object.heading, + unit.position.heading + rotation, ) - if ( - isinstance(self, AntiAirLayout) - and unit.unit_type - and unit.unit_type.dcs_unit_type in UNITS_WITH_RADAR - ): + if unit.unit_type and unit.unit_type.dcs_unit_type in UNITS_WITH_RADAR: # Head Radars towards the center of the conflict unit.position.heading = ( game.theater.heading_to_conflict_from(unit.position) or unit.position.heading ) # Rotate unit around the center to align the orientation of the group - unit.position.rotate(ground_object.position, ground_object.heading) + unit.position.rotate(ground_object.position, rotation) @classmethod def _load_all(cls) -> None: