mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Partial implementation of TGO display.
No threat/detection circles yet. https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
@@ -8,6 +8,7 @@ from . import (
|
||||
flights,
|
||||
mapzones,
|
||||
navmesh,
|
||||
tgos,
|
||||
waypoints,
|
||||
)
|
||||
from .security import ApiKeyManager
|
||||
@@ -24,6 +25,7 @@ app.include_router(eventstream.router)
|
||||
app.include_router(flights.router)
|
||||
app.include_router(mapzones.router)
|
||||
app.include_router(navmesh.router)
|
||||
app.include_router(tgos.router)
|
||||
app.include_router(waypoints.router)
|
||||
|
||||
|
||||
|
||||
1
game/server/tgos/__init__.py
Normal file
1
game/server/tgos/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .routes import router
|
||||
40
game/server/tgos/models.py
Normal file
40
game/server/tgos/models.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from game.server.leaflet import LeafletPoint
|
||||
from game.theater import TheaterGroundObject
|
||||
|
||||
|
||||
class TgoJs(BaseModel):
|
||||
name: str
|
||||
control_point_name: str
|
||||
category: str
|
||||
blue: bool
|
||||
position: LeafletPoint
|
||||
units: list[str]
|
||||
threat_ranges: list[float]
|
||||
detection_ranges: list[float]
|
||||
dead: bool
|
||||
sidc: str
|
||||
|
||||
@staticmethod
|
||||
def for_tgo(tgo: TheaterGroundObject) -> TgoJs:
|
||||
if not tgo.might_have_aa:
|
||||
threat_ranges = []
|
||||
detection_ranges = []
|
||||
else:
|
||||
threat_ranges = [tgo.threat_range(group).meters for group in tgo.groups]
|
||||
detection_ranges = [tgo.threat_range(group).meters for group in tgo.groups]
|
||||
return TgoJs(
|
||||
name=tgo.name,
|
||||
control_point_name=tgo.control_point.name,
|
||||
category=tgo.category,
|
||||
blue=tgo.control_point.captured,
|
||||
position=tgo.position.latlng(),
|
||||
units=[unit.display_name for unit in tgo.units],
|
||||
threat_ranges=threat_ranges,
|
||||
detection_ranges=detection_ranges,
|
||||
dead=tgo.is_dead,
|
||||
sidc=str(tgo.sidc()),
|
||||
)
|
||||
17
game/server/tgos/routes.py
Normal file
17
game/server/tgos/routes.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from game import Game
|
||||
from .models import TgoJs
|
||||
from ..dependencies import GameContext
|
||||
|
||||
router: APIRouter = APIRouter(prefix="/tgos")
|
||||
|
||||
|
||||
@router.get("/")
|
||||
def list_tgos(game: Game = Depends(GameContext.get)) -> list[TgoJs]:
|
||||
tgos = []
|
||||
for control_point in game.theater.controlpoints:
|
||||
for tgo in control_point.connected_objectives:
|
||||
if not tgo.is_control_point:
|
||||
tgos.append(TgoJs.for_tgo(tgo))
|
||||
return tgos
|
||||
Reference in New Issue
Block a user