public CountermeasureFiringSolution(ActiveCountermeasure countermeasure, IInterceptableOrdnance threat) { Countermeasure = countermeasure; Threat = threat; }
//private IList<AWeapon> _readyWeaponsInventory = new List<AWeapon>(); //private void Attach(AWeapon weapon) { // D.Assert(weapon.RangeMonitor != null); // var monitor = weapon.RangeMonitor; // if (!_weaponRangeMonitors.Contains(monitor)) { // // only need to record and setup range monitors once. The same monitor can have more than 1 weapon // _weaponRangeMonitors.Add(monitor); // } // weapon.onIsReadyToFireChanged += OnWeaponReadinessChanged; // weapon.onEnemyTargetEnteringRange += OnNewEnemyTargetInRange; // // IsOperational = true is set when item operations commences //} /// <summary> /// Attempts to find a target in range and fire the weapon at it. /// </summary> /// <param name="weapon">The weapon.</param> /// <param name="tgtHint">Optional hint indicating a highly desirable target.</param> //protected void FindTargetAndFire(AWeapon weapon, IElementAttackableTarget tgtHint = null) { // D.Assert(weapon.IsReadyToFire); // IElementAttackableTarget enemyTarget; // if (weapon.TryPickBestTarget(tgtHint, out enemyTarget)) { // InitiateFiringSequence(weapon, enemyTarget); // } // else { // D.Log("{0} did not fire weapon {1}.", DebugName, weapon.Name); // } //} /// <summary> /// Called when there is a change in the readiness to fire status of the indicated weapon. /// Readiness to fire does not mean there is an enemy in range to fire at. /// </summary> /// <param name="weapon">The weapon.</param> //private void OnWeaponReadinessChanged(AWeapon weapon) { // if (weapon.IsReadyToFire && weapon.IsEnemyInRange) { // OnWeaponReadyAndEnemyInRange(weapon); // } // UpdateReadyWeaponsInventory(weapon); //} /// <summary> /// Called when a new, qualified enemy target has come within range /// of the indicated weapon. This event is independent of whether the /// weapon is ready to fire. However, it does mean the weapon is operational. /// </summary> /// <param name="weapon">The weapon.</param> //private void OnNewEnemyTargetInRange(AWeapon weapon) { // if (_readyWeaponsInventory.Contains(weapon)) { // OnWeaponReadyAndEnemyInRange(weapon); // UpdateReadyWeaponsInventory(weapon); // } //} /// <summary> /// Called when [weapon ready and enemy in range]. /// </summary> /// <param name="weapon">The weapon.</param> //private void OnWeaponReadyAndEnemyInRange(AWeapon weapon) { // // the weapon is ready and the enemy is in range // RelayToCurrentState(weapon); //} /// <summary> /// Updates the ready weapons inventory. /// </summary> /// <param name="weapon">The weapon.</param> //private void UpdateReadyWeaponsInventory(AWeapon weapon) { // if (weapon.IsReadyToFire) { // if (!_readyWeaponsInventory.Contains(weapon)) { // _readyWeaponsInventory.Add(weapon); // //D.Log("{0} added Weapon {1} to ReadyWeaponsInventory.", DebugName, weapon.Name); // } // else { // //D.Log("{0} properly avoided adding duplicate Weapon {1} to ReadyWeaponsInventory.", DebugName, weapon.Name); // // this occurs when a weapon attempts to fire but doesn't (usually due to LOS interference) and therefore remains // // IsReadyToFire. If it had fired, it wouldn't be ready and therefore would have been removed below // } // } // else { // if (_readyWeaponsInventory.Contains(weapon)) { // _readyWeaponsInventory.Remove(weapon); // //D.Log("{0} removed Weapon {1} from ReadyWeaponsInventory.", DebugName, weapon.Name); // } // } //} #endregion #endregion #region Active Countermeasures /******************************************************************************************************************** * ActiveCountermeasure target selection and firing handled automatically within ActiveCountermeasure class * Note: For previous approach to firing ActiveCountermeasures, see Weapons Firing Archive above *******************************************************************************************************************/ /// <summary> /// Attaches this active countermeasure and its monitor to this item. /// </summary> /// <param name="activeCM">The cm.</param> private void Attach(ActiveCountermeasure activeCM) { D.AssertNotNull(activeCM.RangeMonitor); var monitor = activeCM.RangeMonitor; if (!CountermeasureRangeMonitors.Contains(monitor)) { // only need to record and setup range monitors once. The same monitor can have more than 1 weapon CountermeasureRangeMonitors.Add(monitor); } }