| | 1 | | using System.Collections.Generic; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | [System.Serializable] |
| | 5 | | public enum ThreatStatus { UNASSIGNED, ASSIGNED, DESTROYED } |
| | 6 | | [System.Serializable] |
| | 7 | | public class ThreatData { |
| | 8 | | public Threat Threat; |
| | 9 | | [SerializeField] |
| | 10 | | private ThreatStatus _status; |
| | 11 | |
|
| 7 | 12 | | public int assignedInterceptorCount = 0; |
| | 13 | | public ThreatStatus Status { |
| 0 | 14 | | get { return _status; } |
| | 15 | | } |
| | 16 | | public string ThreatID; |
| | 17 | | [SerializeField] |
| | 18 | | private List<Interceptor> _assignedInterceptors; // Changed from property to field |
| | 19 | |
|
| 0 | 20 | | public void AssignInterceptor(Interceptor interceptor) { |
| 0 | 21 | | if (Status == ThreatStatus.DESTROYED) { |
| 0 | 22 | | Debug.LogError( |
| | 23 | | $"AssignInterceptor: Threat {ThreatID} is destroyed, cannot assign interceptor"); |
| 0 | 24 | | return; |
| | 25 | | } |
| 0 | 26 | | _status = ThreatStatus.ASSIGNED; |
| 0 | 27 | | _assignedInterceptors.Add(interceptor); |
| 0 | 28 | | assignedInterceptorCount++; |
| 0 | 29 | | } |
| | 30 | |
|
| 0 | 31 | | public void RemoveInterceptor(Interceptor interceptor) { |
| 0 | 32 | | _assignedInterceptors.Remove(interceptor); |
| 0 | 33 | | if (_assignedInterceptors.Count == 0) { |
| 0 | 34 | | _status = ThreatStatus.UNASSIGNED; |
| 0 | 35 | | } |
| 0 | 36 | | assignedInterceptorCount--; |
| 0 | 37 | | } |
| | 38 | |
|
| 0 | 39 | | public void MarkDestroyed() { |
| 0 | 40 | | _status = ThreatStatus.DESTROYED; |
| 0 | 41 | | } |
| | 42 | | // Constructor remains the same |
| 14 | 43 | | public ThreatData(Threat threat, string threatID) { |
| 7 | 44 | | Threat = threat; |
| 7 | 45 | | _status = ThreatStatus.UNASSIGNED; |
| 7 | 46 | | ThreatID = threatID; |
| 7 | 47 | | _assignedInterceptors = new List<Interceptor>(); // Initialize the list |
| 7 | 48 | | } |
| | 49 | | } |