mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Draw aircraft locations in the new map.
https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
selectFlight,
|
||||
unregisterFlight,
|
||||
updateFlight,
|
||||
updateFlightPosition,
|
||||
} from "./flightsSlice";
|
||||
import {
|
||||
addFrontLine,
|
||||
@@ -48,6 +49,12 @@ export const handleStreamedEvents = (
|
||||
dispatch: AppDispatch,
|
||||
events: GameUpdateEvents
|
||||
) => {
|
||||
for (const [id, position] of Object.entries(
|
||||
events.updated_flight_positions
|
||||
)) {
|
||||
dispatch(updateFlightPosition([id, position]));
|
||||
}
|
||||
|
||||
for (const flight of events.new_flights) {
|
||||
dispatch(registerFlight(flight));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { LatLng } from "leaflet";
|
||||
export interface Flight {
|
||||
id: string;
|
||||
blue: boolean;
|
||||
position: LatLng;
|
||||
position: LatLng | null;
|
||||
sidc: string;
|
||||
waypoints: Waypoint[] | null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { RootState } from "../app/store";
|
||||
import { Flight } from "./flight";
|
||||
import { PayloadAction, createSlice } from "@reduxjs/toolkit";
|
||||
import { LatLng } from "leaflet";
|
||||
|
||||
interface FlightsState {
|
||||
blue: { [id: string]: Flight };
|
||||
@@ -55,6 +56,11 @@ export const flightsSlice = createSlice({
|
||||
const id = action.payload;
|
||||
state.selected = state.blue[id];
|
||||
},
|
||||
updateFlightPosition: (state, action: PayloadAction<[string, LatLng]>) => {
|
||||
const [id, position] = action.payload;
|
||||
const ato = id in state.blue ? state.blue : state.red;
|
||||
ato[id].position = position;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -65,6 +71,7 @@ export const {
|
||||
updateFlight,
|
||||
deselectFlight,
|
||||
selectFlight,
|
||||
updateFlightPosition,
|
||||
} = flightsSlice.actions;
|
||||
|
||||
export const selectFlights = (state: RootState) => state.flights;
|
||||
|
||||
Reference in New Issue
Block a user