mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Push full TGO information in the event stream.
https://github.com/dcs-liberation/dcs_liberation/issues/2263
This commit is contained in:
parent
0fc2e8872d
commit
a20b95bb26
@ -1,6 +1,5 @@
|
|||||||
import { AppDispatch } from "../app/store";
|
import { AppDispatch } from "../app/store";
|
||||||
import { gameUnloaded } from "./actions";
|
import { gameUnloaded } from "./actions";
|
||||||
import backend from "./backend";
|
|
||||||
import Combat from "./combat";
|
import Combat from "./combat";
|
||||||
import { endCombat, newCombat, updateCombat } from "./combatSlice";
|
import { endCombat, newCombat, updateCombat } from "./combatSlice";
|
||||||
import { updateControlPoint } from "./controlPointsSlice";
|
import { updateControlPoint } from "./controlPointsSlice";
|
||||||
@ -48,7 +47,7 @@ interface GameUpdateEvents {
|
|||||||
deselected_flight: boolean;
|
deselected_flight: boolean;
|
||||||
updated_front_lines: FrontLine[];
|
updated_front_lines: FrontLine[];
|
||||||
deleted_front_lines: string[];
|
deleted_front_lines: string[];
|
||||||
updated_tgos: string[];
|
updated_tgos: Tgo[];
|
||||||
updated_control_points: ControlPoint[];
|
updated_control_points: ControlPoint[];
|
||||||
updated_iads: IadsConnection[];
|
updated_iads: IadsConnection[];
|
||||||
deleted_iads: string[];
|
deleted_iads: string[];
|
||||||
@ -131,11 +130,8 @@ export const handleStreamedEvents = (
|
|||||||
dispatch(deleteFrontLine(events.deleted_front_lines));
|
dispatch(deleteFrontLine(events.deleted_front_lines));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const id of events.updated_tgos) {
|
if (events.updated_tgos.length > 0) {
|
||||||
backend.get(`/tgos/${id}`).then((response) => {
|
dispatch(updateTgo(events.updated_tgos));
|
||||||
const tgo = response.data as Tgo;
|
|
||||||
dispatch(updateTgo(tgo));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events.updated_control_points.length > 0) {
|
if (events.updated_control_points.length > 0) {
|
||||||
|
|||||||
@ -15,9 +15,10 @@ export const tgosSlice = createSlice({
|
|||||||
name: "tgos",
|
name: "tgos",
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
updateTgo: (state, action: PayloadAction<Tgo>) => {
|
updateTgo: (state, action: PayloadAction<Tgo[]>) => {
|
||||||
const tgo = action.payload;
|
for (const tgo of action.payload) {
|
||||||
state.tgos[tgo.id] = tgo;
|
state.tgos[tgo.id] = tgo;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ from game.server.flights.models import FlightJs
|
|||||||
from game.server.frontlines.models import FrontLineJs
|
from game.server.frontlines.models import FrontLineJs
|
||||||
from game.server.iadsnetwork.models import IadsConnectionJs
|
from game.server.iadsnetwork.models import IadsConnectionJs
|
||||||
from game.server.leaflet import LeafletPoint
|
from game.server.leaflet import LeafletPoint
|
||||||
|
from game.server.tgos.models import TgoJs
|
||||||
from game.server.mapzones.models import UnculledZoneJs
|
from game.server.mapzones.models import UnculledZoneJs
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -33,7 +34,7 @@ class GameUpdateEventsJs(BaseModel):
|
|||||||
deselected_flight: bool
|
deselected_flight: bool
|
||||||
updated_front_lines: list[FrontLineJs]
|
updated_front_lines: list[FrontLineJs]
|
||||||
deleted_front_lines: set[UUID]
|
deleted_front_lines: set[UUID]
|
||||||
updated_tgos: set[UUID]
|
updated_tgos: list[TgoJs]
|
||||||
updated_control_points: list[ControlPointJs]
|
updated_control_points: list[ControlPointJs]
|
||||||
updated_iads: list[IadsConnectionJs]
|
updated_iads: list[IadsConnectionJs]
|
||||||
deleted_iads: set[UUID]
|
deleted_iads: set[UUID]
|
||||||
@ -88,7 +89,7 @@ class GameUpdateEventsJs(BaseModel):
|
|||||||
FrontLineJs.for_front_line(f) for f in events.updated_front_lines
|
FrontLineJs.for_front_line(f) for f in events.updated_front_lines
|
||||||
],
|
],
|
||||||
deleted_front_lines=events.deleted_front_lines,
|
deleted_front_lines=events.deleted_front_lines,
|
||||||
updated_tgos=events.updated_tgos,
|
updated_tgos=[TgoJs.for_tgo(tgo) for tgo in events.updated_tgos],
|
||||||
updated_control_points=[
|
updated_control_points=[
|
||||||
ControlPointJs.for_control_point(cp)
|
ControlPointJs.for_control_point(cp)
|
||||||
for cp in events.updated_control_points
|
for cp in events.updated_control_points
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class GameUpdateEvents:
|
|||||||
deselected_flight: bool = False
|
deselected_flight: bool = False
|
||||||
updated_front_lines: set[FrontLine] = field(default_factory=set)
|
updated_front_lines: set[FrontLine] = field(default_factory=set)
|
||||||
deleted_front_lines: set[UUID] = field(default_factory=set)
|
deleted_front_lines: set[UUID] = field(default_factory=set)
|
||||||
updated_tgos: set[UUID] = field(default_factory=set)
|
updated_tgos: set[TheaterGroundObject] = field(default_factory=set)
|
||||||
updated_control_points: set[ControlPoint] = field(default_factory=set)
|
updated_control_points: set[ControlPoint] = field(default_factory=set)
|
||||||
updated_iads: set[IadsNetworkNode] = field(default_factory=set)
|
updated_iads: set[IadsNetworkNode] = field(default_factory=set)
|
||||||
deleted_iads_connections: set[UUID] = field(default_factory=set)
|
deleted_iads_connections: set[UUID] = field(default_factory=set)
|
||||||
@ -118,7 +118,7 @@ class GameUpdateEvents:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def update_tgo(self, tgo: TheaterGroundObject) -> GameUpdateEvents:
|
def update_tgo(self, tgo: TheaterGroundObject) -> GameUpdateEvents:
|
||||||
self.updated_tgos.add(tgo.id)
|
self.updated_tgos.add(tgo)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def update_control_point(self, control_point: ControlPoint) -> GameUpdateEvents:
|
def update_control_point(self, control_point: ControlPoint) -> GameUpdateEvents:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user