Handle IADS updates properly.

This adds the missing events in the backend, and handles them properly in the front end.
This commit is contained in:
Raffson
2022-06-30 03:58:49 +02:00
committed by GitHub
parent 5f071a6138
commit 27dff95df5
7 changed files with 47 additions and 14 deletions

View File

@@ -843,7 +843,7 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC):
tgo, VehicleGroupGroundObject
):
if isinstance(tgo, IadsGroundObject):
game.theater.iads_network.update_tgo(tgo)
game.theater.iads_network.update_tgo(tgo, events)
conflict_heading = game.theater.heading_to_conflict_from(tgo.position)
tgo.rotate(conflict_heading or tgo.heading)
if not tgo.is_control_point:

View File

@@ -18,6 +18,7 @@ from game.theater.theatergroup import IadsGroundGroup
if TYPE_CHECKING:
from game.game import Game
from game.sim import GameUpdateEvents
class IadsNetworkException(Exception):
@@ -133,19 +134,21 @@ class IadsNetwork:
skynet_nodes.append(skynet_node)
return skynet_nodes
def update_tgo(self, tgo: TheaterGroundObject) -> None:
def update_tgo(self, tgo: TheaterGroundObject, events: GameUpdateEvents) -> None:
"""Update the IADS Network for the given TGO"""
# Remove existing nodes for the given tgo
for cn in self.nodes:
if cn.group.ground_object == tgo:
self.nodes.remove(cn)
for cID in cn.connections:
events.delete_iads_connection(cID)
# Create a new node for the tgo
node = self.node_for_tgo(tgo)
if node is None:
# Not participating
return
# TODO Add the connections or calculate them..
events.update_iads_node(node)
def node_for_group(self, group: IadsGroundGroup) -> IadsNetworkNode:
"""Get existing node from the iads network or create a new node"""