public void Unregister(Guid key, IAntenna antenna) { RTLog.Notify("AntennaManager: Unregister({0})", antenna); if (!mLoadedAntennaCache.ContainsKey(key)) { return; } int instance_id = mLoadedAntennaCache[key].FindIndex(x => x == antenna); if (instance_id != -1) { mLoadedAntennaCache[key].RemoveAt(instance_id); if (mLoadedAntennaCache[key].Count == 0) { mLoadedAntennaCache.Remove(key); } OnUnregister(antenna); Vessel vessel = RTUtil.GetVesselById(key); if (vessel != null) { // trigger the onRails on more time // to reregister the antenna as a protoSat this.OnVesselGoOnRails(vessel); } } }
/// <summary> /// Unregisters the specified signal processor. /// </summary> /// <param name="key">The key the signal processor was registered under.</param> /// <param name="spu">The signal processor.</param> public void Unregister(Guid key, ISignalProcessor spu) { RTLog.Notify("SatelliteManager: Unregister({0})", spu); // Return if nothing to unregister. if (!_loadedSpuCache.ContainsKey(key)) { return; } // Find instance of the signal processor. var instanceId = _loadedSpuCache[key].FindIndex(x => x == spu); if (instanceId == -1) { return; } // Remove satellite if no signal processors remain. if (_loadedSpuCache[key].Count == 1) { if (_satelliteCache.ContainsKey(key)) { VesselSatellite sat = _satelliteCache[key]; OnUnregister(sat); _satelliteCache.Remove(key); } _loadedSpuCache[key].RemoveAt(instanceId); _loadedSpuCache.Remove(key); // search vessel by id var vessel = RTUtil.GetVesselById(key); if (vessel != null) { // trigger the onRails on more time // to re-register the satellite as a protoSat OnVesselOnRails(vessel); } } else { _loadedSpuCache[key].RemoveAt(instanceId); } }