Пример #1
0
 /// <summary>
 /// Tries to get firing solutions on all the qualified threats in range. Returns <c>true</c> if one or more
 /// firing solutions were found, <c>false</c> otherwise. 
 /// Note: In this version, for each qualified threat, there is NO chance that the CM can't 'bear' on the threat, resulting in no firing solution.
 /// </summary>
 /// <param name="firingSolutions">The firing solutions.</param>
 /// <returns></returns>
 private bool TryGetFiringSolutions(out IList<CountermeasureFiringSolution> firingSolutions) {
     int threatCount = _qualifiedThreats.Count;
     D.Assert(threatCount > Constants.Zero);
     firingSolutions = new List<CountermeasureFiringSolution>(threatCount);
     foreach (var threat in _qualifiedThreats) {
         CountermeasureFiringSolution firingSolution = new CountermeasureFiringSolution(this, threat);
         firingSolutions.Add(firingSolution);
     }
     return firingSolutions.Any();
 }
Пример #2
0
        // Copy Constructor makes no sense when a RangeMonitor must be attached

        /*****************************************************************************************************************************************
        * This countermeasure does not need to track Owner changes. When the owner of the item with this countermeasure changes, the countermeasure's 
        * RangeMonitor drops and then reacquires all detectedItems. As a result, all reacquired items are categorized correctly. 
        * When the owner of an item detected by this countermeasure changes, the Monitor re-categorizes the detectedItem into the right list 
        * taking appropriate action as a result.
        *****************************************************************************************************************************************/

        /**********************************************************************************************************************************************
        * ParentDeath Note: No need to track it as the parent element will turn off the activate state of all equipment when it initiates dying.
        *********************************************************************************************************************************************/

        /// <summary>
        /// Fires this countermeasure using the provided firingSolution which attempts to intercept an incoming threat.
        /// </summary>
        /// <param name="firingSolution">The firing solution.</param>
        /// <returns></returns>
        private bool Fire(CountermeasureFiringSolution firingSolution) {
            var threat = firingSolution.Threat;
            HandleFiringInitiated(threat);

            //D.Log(ShowDebugLog, "{0} is firing on {1}. Qualified Threats = {2}.", DebugName, threat.DebugName, _qualifiedThreats.Select(t => t.DebugName).Concatenate());
            bool isThreatHit = false;
            float hitChance = InterceptAccuracy;
            if (RandomExtended.Chance(hitChance)) {
                isThreatHit = true;
                var threatWdvCategory = threat.DeliveryVehicleStrength.Category;
                WDVStrength interceptStrength = GetInterceptStrength(threatWdvCategory);
                threat.TakeHit(interceptStrength);
            }
            HandleFiringComplete();
            return isThreatHit;
        }