/// <summary> /// Ensure the given mining laser is armed with a crystal appropriate for the given target, if such crystal is available. /// </summary> /// <param name="miningLaser"></param> /// <param name="target"></param> /// <returns>True if the loaded charge was modified, otherwise false.</returns> private bool EnsureMiningLaserIsArmedForTarget(EVE.ISXEVE.Interfaces.IModule miningLaser, IEntityWrapper target) { var methodName = "EnsureMiningLaserIsArmedForTarget"; LogTrace(methodName, "Module: {0}, Target: {1}", miningLaser.ID, target.ID); if (miningLaser.ToItem.GroupID != (int)GroupIDs.FrequencyMiningLaser) { return(false); } if (miningLaser.IsActive) { return(false); } //Get the best possible mining crystal, including the crystal loaded var bestMiningCrystal = _ship.GetBestMiningCrystal(target, miningLaser); if (bestMiningCrystal == null) { return(false); } if (!ShouldMiningLaserChangeToCrystal(miningLaser, bestMiningCrystal)) { return(false); } //Get a matching reference from the module's available ammo var availableAmmo = miningLaser.GetAvailableAmmo(); if (availableAmmo == null) { return(false); } //If the charge isn't available, there's nothing more to do if (availableAmmo.All(item => item.ID != bestMiningCrystal.ID)) { return(false); } LogMessage(methodName, LogSeverityTypes.Standard, "Changing the loaded crystal of module \"{0}\" ({1}) to \"{2}\".", miningLaser.ToItem.Name, miningLaser.ID, bestMiningCrystal.Name); miningLaser.ChangeAmmo(bestMiningCrystal.ID, 1); return(true); }