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
|
import logging
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from functools import cached_property
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
from dcs.mapping import Point
|
from dcs.mapping import Point
|
||||||
@ -17,17 +18,20 @@ FRONTLINE_LENGTH = 80000
|
|||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class FrontLineBounds:
|
class FrontLineBounds:
|
||||||
left_position: Point
|
left_position: Point
|
||||||
heading_from_left_to_right: Heading
|
right_position: Point
|
||||||
length: int
|
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
|
def length(self) -> int:
|
||||||
|
return int(self.left_position.distance_to_point(self.right_position))
|
||||||
|
|
||||||
|
@cached_property
|
||||||
def center(self) -> Point:
|
def center(self) -> Point:
|
||||||
return (self.left_position + self.right_position) / 2
|
return (self.left_position + self.right_position) / 2
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def right_position(self) -> Point:
|
def heading_from_left_to_right(self) -> Heading:
|
||||||
return self.left_position.point_from_heading(
|
return Heading(
|
||||||
self.heading_from_left_to_right.degrees, self.length
|
int(self.left_position.heading_between_point(self.right_position))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -85,8 +89,7 @@ class FrontLineConflictDescription:
|
|||||||
right_position = cls.extend_ground_position(
|
right_position = cls.extend_ground_position(
|
||||||
center_position, int(FRONTLINE_LENGTH / 2), right_heading, theater
|
center_position, int(FRONTLINE_LENGTH / 2), right_heading, theater
|
||||||
)
|
)
|
||||||
distance = int(left_position.distance_to_point(right_position))
|
return FrontLineBounds(left_position, right_position)
|
||||||
return FrontLineBounds(left_position, right_heading, distance)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def frontline_cas_conflict(
|
def frontline_cas_conflict(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user