mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Move NavMesh out of MapModel.
This commit is contained in:
1
game/server/navmesh/__init__.py
Normal file
1
game/server/navmesh/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .routes import router
|
||||
10
game/server/navmesh/models.py
Normal file
10
game/server/navmesh/models.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from game.server.leaflet import LeafletPoly
|
||||
|
||||
|
||||
class NavMeshPolyJs(BaseModel):
|
||||
poly: LeafletPoly
|
||||
threatened: bool
|
||||
20
game/server/navmesh/routes.py
Normal file
20
game/server/navmesh/routes.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from game import Game
|
||||
from game.server import GameContext
|
||||
from .models import NavMeshPolyJs
|
||||
from ..leaflet import ShapelyUtil
|
||||
|
||||
router: APIRouter = APIRouter(prefix="/navmesh")
|
||||
|
||||
|
||||
@router.get("/", response_model=list[NavMeshPolyJs])
|
||||
def get(for_player: bool, game: Game = Depends(GameContext.get)) -> list[NavMeshPolyJs]:
|
||||
mesh = game.coalition_for(for_player).nav_mesh
|
||||
return [
|
||||
NavMeshPolyJs(
|
||||
poly=ShapelyUtil.poly_to_leaflet(p.poly, game.theater),
|
||||
threatened=p.threatened,
|
||||
)
|
||||
for p in mesh.polys
|
||||
]
|
||||
Reference in New Issue
Block a user