Update pydcs, adapt to new Point APIs.

This is briefly moving us over to my fork of pydcs while we wait for
https://github.com/pydcs/dcs/pull/206 to be merged. The adaptation is
invasive enough that I don't want it lingering for long.
This commit is contained in:
Dan Albert
2022-02-21 18:14:49 -08:00
parent ff12b37431
commit 9e2e4ffa74
29 changed files with 155 additions and 186 deletions

View File

@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
import shapely.ops
from dcs import Point
from shapely.geometry import Point as ShapelyPoint, Polygon, MultiPolygon
from shapely.geometry import MultiPolygon, Point as ShapelyPoint, Polygon
from game.utils import nautical_miles
@@ -29,6 +29,7 @@ class HoldZoneGeometry:
coalition: Coalition,
theater: ConflictTheater,
) -> None:
self._target = target
# Hold points are placed one of two ways. Either approach guarantees:
#
# * Safe hold point.
@@ -105,4 +106,4 @@ class HoldZoneGeometry:
hold, _ = shapely.ops.nearest_points(self.permissible_zones, self.home)
else:
hold, _ = shapely.ops.nearest_points(self.preferred_lines, self.join)
return Point(hold.x, hold.y)
return self._target.new_in_same_map(hold.x, hold.y)

View File

@@ -4,9 +4,9 @@ from typing import TYPE_CHECKING
import shapely.ops
from dcs import Point
from shapely.geometry import Point as ShapelyPoint, MultiPolygon
from shapely.geometry import MultiPolygon, Point as ShapelyPoint
from game.utils import nautical_miles, meters
from game.utils import meters, nautical_miles
if TYPE_CHECKING:
from game.coalition import Coalition
@@ -25,6 +25,7 @@ class IpZoneGeometry:
home: Point,
coalition: Coalition,
) -> None:
self._target = target
self.threat_zone = coalition.opponent.threat_zone.all
self.home = ShapelyPoint(home.x, home.y)
@@ -115,4 +116,4 @@ class IpZoneGeometry:
ip = self._unsafe_ip()
else:
ip = self._safe_ip()
return Point(ip.x, ip.y)
return self._target.new_in_same_map(ip.x, ip.y)

View File

@@ -5,10 +5,10 @@ from typing import TYPE_CHECKING
import shapely.ops
from dcs import Point
from shapely.geometry import (
MultiLineString,
MultiPolygon,
Point as ShapelyPoint,
Polygon,
MultiPolygon,
MultiLineString,
)
from game.utils import nautical_miles
@@ -27,6 +27,7 @@ class JoinZoneGeometry:
def __init__(
self, target: Point, home: Point, ip: Point, coalition: Coalition
) -> None:
self._target = target
# Normal join placement is based on the path from home to the IP. If no path is
# found it means that the target is on a direct path. In that case we instead
# want to enforce that the join point is:
@@ -100,4 +101,4 @@ class JoinZoneGeometry:
join, _ = shapely.ops.nearest_points(self.permissible_zones, self.ip)
else:
join, _ = shapely.ops.nearest_points(self.preferred_lines, self.home)
return Point(join.x, join.y)
return self._target.new_in_same_map(join.x, join.y)