mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Implement advanced skynet functions
- factor out own class for the iadsnetwork within the conflicttheater - This class will handle all Skynet related things - no specific group_name handling necessary in future - make iadsbuilding own TGO class because SAM & EWRs are Vehicle Groups. IADS Elements dont have any groups attached. - added command center, connection node and power source as Ground objects which can be added by the campaign designer - adjust lua generator to support new iads units - parse the campaign yaml to get the iads network information - use the range as fallback if no yaml information was found - complete rewrite of the skynet lua script - allow destruction of iads network to be persistent over all rounds - modified the presetlocation handling: the wrapper PresetLocation for PointWithHeading now stores the original name from the campaign miz to have the ability to process campaign yaml configurations based on the ground unit - Implementation of the UI representation for the IADS Network - Give user the option to enable or disable advanced iads - Extended the layout system: Implement Sub task handling to support PD
This commit is contained in:
@@ -14,6 +14,7 @@ from . import (
|
||||
supplyroutes,
|
||||
tgos,
|
||||
waypoints,
|
||||
iadsnetwork,
|
||||
)
|
||||
from .settings import ServerSettings
|
||||
|
||||
@@ -30,6 +31,7 @@ app.include_router(qt.router)
|
||||
app.include_router(supplyroutes.router)
|
||||
app.include_router(tgos.router)
|
||||
app.include_router(waypoints.router)
|
||||
app.include_router(iadsnetwork.router)
|
||||
|
||||
|
||||
origins = []
|
||||
|
||||
@@ -12,6 +12,7 @@ from game.server.mapzones.models import ThreatZoneContainerJs
|
||||
from game.server.navmesh.models import NavMeshesJs
|
||||
from game.server.supplyroutes.models import SupplyRouteJs
|
||||
from game.server.tgos.models import TgoJs
|
||||
from game.server.iadsnetwork.models import IadsConnectionJs, IadsNetworkJs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game import Game
|
||||
@@ -23,6 +24,7 @@ class GameJs(BaseModel):
|
||||
supply_routes: list[SupplyRouteJs]
|
||||
front_lines: list[FrontLineJs]
|
||||
flights: list[FlightJs]
|
||||
iads_network: IadsNetworkJs
|
||||
threat_zones: ThreatZoneContainerJs
|
||||
navmeshes: NavMeshesJs
|
||||
map_center: LeafletPoint | None
|
||||
@@ -38,6 +40,7 @@ class GameJs(BaseModel):
|
||||
supply_routes=SupplyRouteJs.all_in_game(game),
|
||||
front_lines=FrontLineJs.all_in_game(game),
|
||||
flights=FlightJs.all_in_game(game, with_waypoints=True),
|
||||
iads_network=IadsNetworkJs.from_network(game.theater.iads_network),
|
||||
threat_zones=ThreatZoneContainerJs.for_game(game),
|
||||
navmeshes=NavMeshesJs.from_game(game),
|
||||
map_center=game.theater.terrain.map_view_default.position.latlng(),
|
||||
|
||||
1
game/server/iadsnetwork/__init__.py
Normal file
1
game/server/iadsnetwork/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .routes import router
|
||||
76
game/server/iadsnetwork/models.py
Normal file
76
game/server/iadsnetwork/models.py
Normal file
@@ -0,0 +1,76 @@
|
||||
from __future__ import annotations
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from game.server.leaflet import LeafletPoint
|
||||
from game.theater.iadsnetwork.iadsnetwork import IadsNetworkNode, IadsNetwork
|
||||
from game.theater.theatergroundobject import TheaterGroundObject
|
||||
|
||||
|
||||
class IadsConnectionJs(BaseModel):
|
||||
id: UUID
|
||||
points: list[LeafletPoint]
|
||||
node: UUID
|
||||
connected: UUID
|
||||
active: bool
|
||||
blue: bool
|
||||
is_power: bool
|
||||
|
||||
class Config:
|
||||
title = "IadsConnection"
|
||||
|
||||
@staticmethod
|
||||
def connections_for_tgo(
|
||||
tgo_id: UUID, network: IadsNetwork
|
||||
) -> list[IadsConnectionJs]:
|
||||
for node in network.nodes:
|
||||
if node.group.ground_object.id == tgo_id:
|
||||
return IadsConnectionJs.connections_for_node(node)
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def connections_for_node(network_node: IadsNetworkNode) -> list[IadsConnectionJs]:
|
||||
iads_connections = []
|
||||
tgo = network_node.group.ground_object
|
||||
for id, connection in network_node.connections.items():
|
||||
if connection.ground_object.is_friendly(True) != tgo.is_friendly(True):
|
||||
continue # Skip connections which are not from same coalition
|
||||
iads_connections.append(
|
||||
IadsConnectionJs(
|
||||
id=id,
|
||||
points=[
|
||||
tgo.position.latlng(),
|
||||
connection.ground_object.position.latlng(),
|
||||
],
|
||||
node=tgo.id,
|
||||
connected=connection.ground_object.id,
|
||||
active=(
|
||||
tgo.alive_unit_count > 0
|
||||
and connection.ground_object.alive_unit_count > 0
|
||||
),
|
||||
blue=tgo.is_friendly(True),
|
||||
is_power="power"
|
||||
in [tgo.category, connection.ground_object.category],
|
||||
)
|
||||
)
|
||||
return iads_connections
|
||||
|
||||
|
||||
class IadsNetworkJs(BaseModel):
|
||||
advanced: bool
|
||||
connections: list[IadsConnectionJs]
|
||||
|
||||
class Config:
|
||||
title = "IadsNetwork"
|
||||
|
||||
@staticmethod
|
||||
def from_network(network: IadsNetwork) -> IadsNetworkJs:
|
||||
iads_connections = []
|
||||
for connection in network.nodes:
|
||||
if not connection.group.iads_role.participate:
|
||||
continue # Skip
|
||||
iads_connections.extend(IadsConnectionJs.connections_for_node(connection))
|
||||
return IadsNetworkJs(
|
||||
advanced=network.advanced_iads, connections=iads_connections
|
||||
)
|
||||
26
game/server/iadsnetwork/routes.py
Normal file
26
game/server/iadsnetwork/routes.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from uuid import UUID
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from game import Game
|
||||
from .models import IadsConnectionJs, IadsNetworkJs
|
||||
from ..dependencies import GameContext
|
||||
|
||||
router: APIRouter = APIRouter(prefix="/iads-network")
|
||||
|
||||
|
||||
@router.get("/", operation_id="get_iads_network", response_model=IadsNetworkJs)
|
||||
def get_iads_network(
|
||||
game: Game = Depends(GameContext.require),
|
||||
) -> IadsNetworkJs:
|
||||
return IadsNetworkJs.from_network(game.theater.iads_network)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/for-tgo/{tgo_id}",
|
||||
operation_id="get_iads_connections_for_tgo",
|
||||
response_model=list[IadsConnectionJs],
|
||||
)
|
||||
def get_iads_connections_for_tgo(
|
||||
tgo_id: UUID, game: Game = Depends(GameContext.require)
|
||||
) -> list[IadsConnectionJs]:
|
||||
return IadsConnectionJs.connections_for_tgo(tgo_id, game.theater.iads_network)
|
||||
Reference in New Issue
Block a user