Implement Event monitoring system
Events are tracked and exported Monitoring of telemetry performance greatly optimized Assignment and threat table tracking fixedmaster
parent
0c7d69d632
commit
17987c2c5f
|
@ -94,10 +94,6 @@ public abstract class Agent : MonoBehaviour {
|
|||
return _isHit;
|
||||
}
|
||||
|
||||
public bool IsMiss() {
|
||||
return _isMiss;
|
||||
}
|
||||
|
||||
public void TerminateAgent() {
|
||||
_flightPhase = FlightPhase.TERMINATED;
|
||||
transform.position = new Vector3(0, 0, 0);
|
||||
|
@ -105,18 +101,17 @@ public abstract class Agent : MonoBehaviour {
|
|||
}
|
||||
|
||||
// Mark the agent as having hit the target or been hit.
|
||||
public void HandleInterceptHit() {
|
||||
public void HandleInterceptHit(Agent otherAgent) {
|
||||
_isHit = true;
|
||||
if (this is Interceptor interceptor && _target is Threat threat) {
|
||||
if (this is Interceptor interceptor && otherAgent is Threat threat) {
|
||||
OnInterceptHit?.Invoke(interceptor, threat);
|
||||
} else if (this is Threat threatAgent && _target is Interceptor interceptorTarget) {
|
||||
} else if (this is Threat threatAgent && otherAgent is Interceptor interceptorTarget) {
|
||||
OnInterceptHit?.Invoke(interceptorTarget, threatAgent);
|
||||
}
|
||||
TerminateAgent();
|
||||
}
|
||||
|
||||
public void HandleInterceptMiss() {
|
||||
_isMiss = true;
|
||||
if (_target != null) {
|
||||
if (this is Interceptor interceptor && _target is Threat threat) {
|
||||
OnInterceptMiss?.Invoke(interceptor, threat);
|
||||
|
|
|
@ -19,7 +19,7 @@ public class IADS : MonoBehaviour {
|
|||
private List<ThreatData> _threatTable = new List<ThreatData>();
|
||||
private Dictionary<Threat, ThreatData> _threatDataMap = new Dictionary<Threat, ThreatData>();
|
||||
|
||||
private List<Interceptor> _assignentQueue = new List<Interceptor>();
|
||||
private List<Interceptor> _assignmentQueue = new List<Interceptor>();
|
||||
|
||||
private void Awake() {
|
||||
if (Instance == null) {
|
||||
|
@ -39,18 +39,18 @@ public class IADS : MonoBehaviour {
|
|||
}
|
||||
|
||||
public void LateUpdate() {
|
||||
if (_assignentQueue.Count > 0) {
|
||||
AssignInterceptorsToThreats(_assignentQueue);
|
||||
_assignentQueue.Clear();
|
||||
if (_assignmentQueue.Count > 0) {
|
||||
AssignInterceptorsToThreats(_assignmentQueue);
|
||||
_assignmentQueue.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestThreatAssignment(List<Interceptor> interceptors) {
|
||||
_assignentQueue.AddRange(interceptors);
|
||||
_assignmentQueue.AddRange(interceptors);
|
||||
}
|
||||
|
||||
public void RequestThreatAssignment(Interceptor interceptor) {
|
||||
_assignentQueue.Add(interceptor);
|
||||
_assignmentQueue.Add(interceptor);
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,7 +140,7 @@ public class IADS : MonoBehaviour {
|
|||
private void RegisterSimulationEnded() {
|
||||
_threatTable.Clear();
|
||||
_threatDataMap.Clear();
|
||||
_assignentQueue.Clear();
|
||||
_assignmentQueue.Clear();
|
||||
}
|
||||
|
||||
}
|
|
@ -87,8 +87,8 @@ public class Interceptor : Agent {
|
|||
// Set green for hit
|
||||
markerObject.GetComponent<Renderer>().material.color = new Color(0, 1, 0, 0.15f);
|
||||
// Mark both this agent and the other agent as hit
|
||||
this.HandleInterceptHit();
|
||||
otherAgent.HandleInterceptHit();
|
||||
this.HandleInterceptHit(otherAgent);
|
||||
otherAgent.HandleInterceptHit(otherAgent);
|
||||
|
||||
} else {
|
||||
// Set red for miss
|
||||
|
|
|
@ -4,7 +4,7 @@ MonoImporter:
|
|||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: -5
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
|
@ -93,8 +93,9 @@ public class SimManager : MonoBehaviour {
|
|||
}
|
||||
|
||||
public void StartSimulation() {
|
||||
InitializeSimulation();
|
||||
OnSimulationStarted?.Invoke();
|
||||
InitializeSimulation();
|
||||
|
||||
}
|
||||
|
||||
public void PauseSimulation() {
|
||||
|
@ -112,6 +113,9 @@ public class SimManager : MonoBehaviour {
|
|||
}
|
||||
|
||||
private void InitializeSimulation() {
|
||||
// Invoke the simulation started event to let listeners
|
||||
// know to invoke their own handler behavior
|
||||
OnSimulationStarted?.Invoke();
|
||||
List<Interceptor> missiles = new List<Interceptor>();
|
||||
// Create missiles based on config
|
||||
foreach (var swarmConfig in simulationConfig.interceptor_swarm_configs) {
|
||||
|
@ -128,10 +132,6 @@ public class SimManager : MonoBehaviour {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Invoke the simulation started event to let listeners
|
||||
// know to invoke their own handler behavior
|
||||
OnSimulationStarted?.Invoke();
|
||||
}
|
||||
|
||||
public void AssignInterceptorsToThreats() {
|
||||
|
@ -306,7 +306,7 @@ public class SimManager : MonoBehaviour {
|
|||
// Check if all missiles have terminated
|
||||
bool allInterceptorsTerminated = true;
|
||||
foreach (var interceptor in _interceptorObjects) {
|
||||
if (interceptor != null && !interceptor.IsHit() && !interceptor.IsMiss()) {
|
||||
if (interceptor != null && interceptor.GetFlightPhase() != Agent.FlightPhase.TERMINATED) {
|
||||
allInterceptorsTerminated = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ MonoImporter:
|
|||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: 100
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
Loading…
Reference in New Issue