Merge remote-tracking branch 'upstream/develop_2_3_x' into ground_tasking

This commit is contained in:
walterroach
2020-12-12 12:44:47 -06:00
27 changed files with 173 additions and 206 deletions

View File

@@ -34,6 +34,7 @@ from game.theater.theatergroundobject import (
LhaGroundObject, ShipGroundObject,
)
from game.unitmap import UnitMap
from game.utils import knots_to_kph, kph_to_mps, mps_to_kph
from .radios import RadioFrequency, RadioRegistry
from .runways import RunwayData
from .tacan import TacanBand, TacanChannel, TacanRegistry
@@ -204,10 +205,11 @@ class GenericCarrierGenerator(GenericGroundObjectGenerator):
tacan_callsign = self.tacan_callsign()
icls = next(self.icls_alloc)
if self.control_point.target_position is not None:
brc = self.steam_to_target_position(ship_group)
else:
brc = self.steam_into_wind(ship_group)
# Always steam into the wind, even if the carrier is being moved.
# There are multiple unsimulated hours between turns, so we can
# count those as the time the carrier uses to move and the mission
# time as the recovery window.
brc = self.steam_into_wind(ship_group)
self.activate_beacons(ship_group, tacan, tacan_callsign, icls)
self.add_runway_data(brc or 0, atc, tacan, tacan_callsign, icls)
self._register_unit_group(group, ship_group)
@@ -242,19 +244,19 @@ class GenericCarrierGenerator(GenericGroundObjectGenerator):
return ship
def steam_into_wind(self, group: ShipGroup) -> Optional[int]:
brc = self.m.weather.wind_at_ground.direction + 180
wind = self.game.conditions.weather.wind.at_0m
brc = wind.direction + 180
# Aim for 25kts over the deck.
carrier_speed = knots_to_kph(25) - mps_to_kph(wind.speed)
for attempt in range(5):
point = group.points[0].position.point_from_heading(
brc, 100000 - attempt * 20000)
if self.game.theater.is_in_sea(point):
group.add_waypoint(point)
group.points[0].speed = kph_to_mps(carrier_speed)
group.add_waypoint(point, carrier_speed)
return brc
return None
def steam_to_target_position(self, group: ShipGroup) -> Optional[int]:
group.add_waypoint(self.control_point.target_position)
return group.position.heading_between_point(self.control_point.target_position)
def tacan_callsign(self) -> str:
raise NotImplementedError