| | | 1 | | /// A radar track file or an IADS (Integrated Air Defense System) track file is a digital record |
| | | 2 | | /// that continuously updates and stores information about a detected object (aircraft, missile, |
| | | 3 | | /// drone, etc.) as it moves through a monitored area. |
| | | 4 | | /// |
| | | 5 | | /// These files are maintained by radar systems and air defense networks to track and classify |
| | | 6 | | /// targets in real-time. |
| | | 7 | | /// |
| | | 8 | | /// In an Integrated Air Defense System (IADS), track files are shared and fused from multiple |
| | | 9 | | /// radar and sensor sources. These files enable coordinated tracking and engagement of threats. |
| | | 10 | | |
| | | 11 | | using UnityEngine; |
| | | 12 | | using System.Collections.Generic; |
| | | 13 | | |
| | | 14 | | public enum TrackStatus { UNASSIGNED, ASSIGNED, DESTROYED } |
| | | 15 | | |
| | | 16 | | [System.Serializable] |
| | | 17 | | public abstract class TrackFileData { |
| | | 18 | | public Agent Agent { get; protected set; } |
| | | 19 | | [SerializeField] |
| | | 20 | | protected TrackStatus _status; |
| | | 21 | | public string TrackID { get; protected set; } |
| | | 22 | | |
| | | 23 | | public TrackStatus Status => _status; |
| | | 24 | | |
| | | 25 | | protected TrackFileData(Agent agent, string trackID) { |
| | | 26 | | Agent = agent; |
| | | 27 | | _status = TrackStatus.UNASSIGNED; |
| | | 28 | | TrackID = trackID; |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | public virtual void MarkDestroyed() { |
| | | 32 | | _status = TrackStatus.DESTROYED; |
| | | 33 | | } |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | [System.Serializable] |
| | | 37 | | public class ThreatData : TrackFileData { |
| | | 38 | | [SerializeField] |
| | 1 | 39 | | private List<Interceptor> _assignedInterceptors = new List<Interceptor>(); |
| | | 40 | | |
| | 3 | 41 | | public ThreatData(Threat threat, string trackID) : base(threat, trackID) {} |
| | | 42 | | |
| | | 43 | | public int AssignedInterceptorCount { |
| | 0 | 44 | | get { return _assignedInterceptors.Count; } |
| | | 45 | | } |
| | | 46 | | |
| | 0 | 47 | | public void AssignInterceptor(Interceptor interceptor) { |
| | 0 | 48 | | if (Status == TrackStatus.DESTROYED) { |
| | 0 | 49 | | Debug.LogError( |
| | | 50 | | $"AssignInterceptor: Track {TrackID} is destroyed, cannot assign interceptor."); |
| | 0 | 51 | | return; |
| | | 52 | | } |
| | 0 | 53 | | _status = TrackStatus.ASSIGNED; |
| | 0 | 54 | | _assignedInterceptors.Add(interceptor); |
| | 0 | 55 | | } |
| | 0 | 56 | | public void RemoveInterceptor(Interceptor interceptor) { |
| | 0 | 57 | | if (_assignedInterceptors.Contains(interceptor)) { |
| | 0 | 58 | | _assignedInterceptors.Remove(interceptor); |
| | 0 | 59 | | if (_assignedInterceptors.Count == 0) { |
| | 0 | 60 | | _status = TrackStatus.UNASSIGNED; |
| | 0 | 61 | | } |
| | 0 | 62 | | } |
| | 0 | 63 | | } |
| | | 64 | | |
| | 0 | 65 | | public override void MarkDestroyed() { |
| | 0 | 66 | | base.MarkDestroyed(); |
| | 0 | 67 | | _assignedInterceptors.Clear(); |
| | 0 | 68 | | } |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | [System.Serializable] |
| | | 72 | | public class InterceptorData : TrackFileData { |
| | | 73 | | [SerializeField] |
| | | 74 | | private List<Threat> _assignedThreats = new List<Threat>(); |
| | | 75 | | |
| | | 76 | | public InterceptorData(Interceptor interceptor, string interceptorID) |
| | | 77 | | : base(interceptor, interceptorID) {} |
| | | 78 | | |
| | | 79 | | public void AssignThreat(Threat threat) { |
| | | 80 | | if (_status == TrackStatus.DESTROYED) { |
| | | 81 | | Debug.LogError($"AssignThreat: Interceptor {TrackID} is destroyed, cannot assign threat."); |
| | | 82 | | return; |
| | | 83 | | } |
| | | 84 | | _status = TrackStatus.ASSIGNED; |
| | | 85 | | _assignedThreats.Add(threat); |
| | | 86 | | } |
| | | 87 | | |
| | | 88 | | public void RemoveThreat(Threat threat) { |
| | | 89 | | _assignedThreats.Remove(threat); |
| | | 90 | | if (_assignedThreats.Count == 0) { |
| | | 91 | | _status = TrackStatus.UNASSIGNED; |
| | | 92 | | } |
| | | 93 | | } |
| | | 94 | | |
| | | 95 | | public override void MarkDestroyed() { |
| | | 96 | | base.MarkDestroyed(); |
| | | 97 | | _assignedThreats.Clear(); |
| | | 98 | | } |
| | | 99 | | } |