dcs_liberation/tests/ato/flightstate/test_actionstate.py
Dan Albert 87441b8939 Formalize waypoint actions.
Create a WaypointAction class that defines the actions taken at a
waypoint. These will often map one-to-one with DCS waypoint actions but
can also be higher level and generate multiple actions. Once everything
has migrated all waypoint-type-specific behaviors of
PydcsWaypointBuilder will be gone, and it'll be easier to keep the sim
behaviors in sync with the mission generator behaviors.

For now only hold has been migrated. This is actually probably the most
complicated action we have (starting with this may have been a mistake,
but it did find all the rough edges quickly) since it affects waypoint
timings and flight position during simulation. That part isn't handled
as neatly as I'd like because the FlightState still has to special case
LOITER points to avoid simulating the wrong waypoint position. At some
point we should probably start tracking real positions in FlightState,
and when we do that will be solved.
2023-08-13 12:43:59 -07:00

30 lines
773 B
Python

from collections.abc import Iterator
from datetime import timedelta, datetime
from dcs.task import Task
from game.ato.flightstate.actionstate import ActionState
from game.flightplan.waypointactions.taskcontext import TaskContext
from game.flightplan.waypointactions.waypointaction import WaypointAction
class TestAction(WaypointAction):
def describe(self) -> str:
return ""
def update_state(
self, state: ActionState, time: datetime, duration: timedelta
) -> None:
pass
def iter_tasks(self, ctx: TaskContext) -> Iterator[Task]:
yield from []
def test_actionstate() -> None:
action = TestAction()
state = ActionState(action)
assert not state.is_finished()
state.finish()
assert state.is_finished()