public CountermeasureFiringSolution(ActiveCountermeasure countermeasure, IInterceptableOrdnance threat) { Countermeasure = countermeasure; Threat = threat; }
/// <summary> /// Called when this weapon's firing process against <c>targetFiredOn</c> has begun. /// </summary> /// <remarks>Note: Done this way to match the way I handled it with Weapons, where /// this was a public method called by the fired ordnance.</remarks> /// <param name="threatFiredOn">The target fired on.</param> private void HandleFiringInitiated(IInterceptableOrdnance threatFiredOn) { D.Assert(IsOperational, DebugName); D.Assert(_qualifiedThreats.Contains(threatFiredOn)); _isLoaded = false; AssessReadiness(); }
private bool CheckIfQualified(IInterceptableOrdnance threat) { bool isQualified = InterceptStrengths.Select(intS => intS.Category).Contains(threat.DeliveryVehicleStrength.Category); string isQualMsg = isQualified ? "is qualified" : "is not qualified"; //D.Log(ShowDebugLog, "{0} {1} to intercept {2} which uses a {3} WDV.", Name, isQualMsg, threat.DebugName, threat.DeliveryVehicleStrength.Category.GetValueName()); return isQualified; }
// Note: Unlike Weapons, there is no reason to have a HandleDeclinedToFire() method as CMs on automatic // should always fire on a threat if there is a FiringSolution. /// <summary> /// Called by this countermeasure's RangeMonitor when a IInterceptableOrdnance threat enters or exits its range. /// </summary> /// <param name="threat">The ordnance threat.</param> /// <param name="isInRange">if set to <c>true</c> [is in range].</param> public void HandleThreatInRangeChanged(IInterceptableOrdnance threat, bool isInRange) { //D.Log(ShowDebugLog, "{0} received HandleThreatInRangeChanged. Threat: {1}, InRange: {2}.", DebugName, threat.DebugName, isInRange); if (isInRange) { if (CheckIfQualified(threat)) { D.Assert(!_qualifiedThreats.Contains(threat)); _qualifiedThreats.Add(threat); } } else { // Note: Some threats going out of range may not have been qualified as targets for this CM. // Also, a qualified threat can be destroyed (goes out of range) by other CMs before it is ever added // to this one, so if it is not present, it was never added to this CM because it was immediately destroyed // by other CMs as it was being added to them. if (_qualifiedThreats.Contains(threat)) { _qualifiedThreats.Remove(threat); } } IsAnyThreatInRange = _qualifiedThreats.Any(); }