mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Make FrontLineBounds actually a bounds container.
This commit is contained in:
parent
ba7b3aa473
commit
13f0dd8b01
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from functools import cached_property
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from dcs.mapping import Point
|
||||
@ -17,17 +18,20 @@ FRONTLINE_LENGTH = 80000
|
||||
@dataclass(frozen=True)
|
||||
class FrontLineBounds:
|
||||
left_position: Point
|
||||
heading_from_left_to_right: Heading
|
||||
length: int
|
||||
right_position: Point
|
||||
|
||||
@property
|
||||
@cached_property
|
||||
def length(self) -> int:
|
||||
return int(self.left_position.distance_to_point(self.right_position))
|
||||
|
||||
@cached_property
|
||||
def center(self) -> Point:
|
||||
return (self.left_position + self.right_position) / 2
|
||||
|
||||
@property
|
||||
def right_position(self) -> Point:
|
||||
return self.left_position.point_from_heading(
|
||||
self.heading_from_left_to_right.degrees, self.length
|
||||
@cached_property
|
||||
def heading_from_left_to_right(self) -> Heading:
|
||||
return Heading(
|
||||
int(self.left_position.heading_between_point(self.right_position))
|
||||
)
|
||||
|
||||
|
||||
@ -85,8 +89,7 @@ class FrontLineConflictDescription:
|
||||
right_position = cls.extend_ground_position(
|
||||
center_position, int(FRONTLINE_LENGTH / 2), right_heading, theater
|
||||
)
|
||||
distance = int(left_position.distance_to_point(right_position))
|
||||
return FrontLineBounds(left_position, right_heading, distance)
|
||||
return FrontLineBounds(left_position, right_position)
|
||||
|
||||
@classmethod
|
||||
def frontline_cas_conflict(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user