mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Interrupt fast-forward on air defense contact.
https://github.com/dcs-liberation/dcs_liberation/issues/1681
This commit is contained in:
parent
cd0c0f1b01
commit
9839787b6d
@ -134,6 +134,8 @@ class Flight:
|
|||||||
def set_state(self, state: FlightState) -> None:
|
def set_state(self, state: FlightState) -> None:
|
||||||
self.state = state
|
self.state = state
|
||||||
|
|
||||||
def on_game_tick(self, time: datetime, duration: timedelta) -> bool:
|
def on_game_tick(self, time: datetime, duration: timedelta) -> None:
|
||||||
self.state.on_game_tick(time, duration)
|
self.state.on_game_tick(time, duration)
|
||||||
|
|
||||||
|
def should_halt_sim(self) -> bool:
|
||||||
return self.state.should_halt_sim()
|
return self.state.should_halt_sim()
|
||||||
|
|||||||
@ -123,6 +123,15 @@ class InFlight(FlightState):
|
|||||||
"ingress point"
|
"ingress point"
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
threat_zone = self.flight.squadron.coalition.opponent.threat_zone
|
||||||
|
if threat_zone.threatened_by_air_defense(self.estimate_position()):
|
||||||
|
logging.info(
|
||||||
|
f"Interrupting simulation because {self.flight} has encountered enemy "
|
||||||
|
"air defenses"
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -47,7 +47,8 @@ class AircraftSimulation:
|
|||||||
def tick(self) -> bool:
|
def tick(self) -> bool:
|
||||||
interrupt_sim = False
|
interrupt_sim = False
|
||||||
for flight in self.iter_flights():
|
for flight in self.iter_flights():
|
||||||
if flight.on_game_tick(self.time, TICK):
|
flight.on_game_tick(self.time, TICK)
|
||||||
|
if flight.should_halt_sim():
|
||||||
interrupt_sim = True
|
interrupt_sim = True
|
||||||
|
|
||||||
# TODO: Check for SAM or A2A contact.
|
# TODO: Check for SAM or A2A contact.
|
||||||
|
|||||||
@ -104,6 +104,10 @@ class ThreatZones:
|
|||||||
def _threatened_by_air_defense_geom(self, position: BaseGeometry) -> bool:
|
def _threatened_by_air_defense_geom(self, position: BaseGeometry) -> bool:
|
||||||
return self.air_defenses.intersects(position)
|
return self.air_defenses.intersects(position)
|
||||||
|
|
||||||
|
@threatened_by_air_defense.register
|
||||||
|
def _threatened_by_air_defense_dcs_point(self, position: DcsPoint) -> bool:
|
||||||
|
return self.threatened_by_air_defense(self.dcs_to_shapely_point(position))
|
||||||
|
|
||||||
@threatened_by_air_defense.register
|
@threatened_by_air_defense.register
|
||||||
def _threatened_by_air_defense_flight(self, flight: Flight) -> bool:
|
def _threatened_by_air_defense_flight(self, flight: Flight) -> bool:
|
||||||
return self.threatened_by_air_defense(
|
return self.threatened_by_air_defense(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user