using System; using System.Collections.Generic; using System.Collections; using UnityEngine; using System.Linq; using System.Diagnostics.Contracts; // The assignment class is an interface for assigning a threat to each interceptor. public interface IAssignment { // Assignment item type. // The first element corresponds to the interceptor index, and the second element // corresponds to the threat index. public struct AssignmentItem { public Interceptor Interceptor; public Threat Threat; public AssignmentItem(Interceptor interceptor, Threat threat) { Interceptor = interceptor; Threat = threat; } } // A list containing the interceptor-target assignments. // Assign a target to each interceptor that has not been assigned a target yet. [Pure] public abstract IEnumerable Assign(in IReadOnlyList interceptors, in IReadOnlyList threatTable); // Get the list of assignable interceptor indices. [Pure] protected static List GetAssignableInterceptors(in IReadOnlyList interceptors) { return interceptors.Where(interceptor => interceptor.IsAssignable()).ToList(); } // Get the list of active threats. [Pure] protected static List GetActiveThreats(in IReadOnlyList threats) { return threats.Where(t => t.Status != ThreatStatus.DESTROYED).ToList(); } }