Move FlightJs out of MapModel.

This commit is contained in:
Dan Albert
2022-02-22 20:40:58 -08:00
parent ad0d3412fb
commit 45e76e12b6
18 changed files with 333 additions and 326 deletions

View File

@@ -17,8 +17,13 @@ class AirTaskingOrder:
def remove_package(self, package: Package) -> None:
"""Removes a package from the ATO."""
# Remove all the flights individually so the database gets updated.
for flight in list(package.flights):
package.remove_flight(flight)
self.packages.remove(package)
def clear(self) -> None:
"""Removes all packages from the ATO."""
self.packages.clear()
# Remove all packages individually so the database gets updated.
for package in self.packages:
self.remove_package(package)

View File

@@ -22,7 +22,7 @@ class Navigating(InFlight):
self, events: GameUpdateEvents, time: datetime, duration: timedelta
) -> None:
super().on_game_tick(events, time, duration)
events.update_flight(self.flight, self.estimate_position())
events.update_flight_position(self.flight, self.estimate_position())
def progress(self) -> float:
return (

View File

@@ -129,6 +129,9 @@ class Package:
"""Removes a flight from the package."""
self.flights.remove(flight)
self._db.remove(flight.id)
flight.return_pilots_and_aircraft()
if flight.cargo is not None:
flight.cargo.transport = None
if not self.flights:
self.waypoints = None