Convert to new unit APIs, remove old APIs.

There are probably plenty of raw ints around that never used the old
conversion APIs, but we'll just need to fix those when we see them.

Fixes https://github.com/Khopa/dcs_liberation/issues/558
This commit is contained in:
Dan Albert
2020-12-19 21:18:18 -08:00
parent 113947b9f0
commit 2ac818dcdd
18 changed files with 224 additions and 253 deletions

View File

@@ -2,6 +2,7 @@
from typing import Dict, Iterator, List, Optional
from game.theater import ConflictTheater, ControlPoint, MissionTarget
from game.utils import Distance
class ClosestAirfields:
@@ -14,14 +15,14 @@ class ClosestAirfields:
all_control_points, key=lambda c: self.target.distance_to(c)
)
def airfields_within(self, meters: int) -> Iterator[ControlPoint]:
def airfields_within(self, distance: Distance) -> Iterator[ControlPoint]:
"""Iterates over all airfields within the given range of the target.
Note that this iterates over *all* airfields, not just friendly
airfields.
"""
for cp in self.closest_airfields:
if cp.distance_to(self.target) < meters:
if cp.distance_to(self.target) < distance.meters:
yield cp
else:
break