private void UpdateValues(string mode) { if (!_kerbnets.ContainsKey(mode)) { return; } KerbNetStorage storage = _kerbnets[mode]; switch (_settings.setting) { case 0: default: _currentMinFoV = _bestMinFoV; _currentMaxFoV = _bestMaxFoV; _currentAnomaly = _bestAnomaly; break; case 1: _currentMinFoV = storage.BestMinFoV; _currentMaxFoV = storage.BestMaxFoV; _currentAnomaly = storage.BestAnomalyChance; break; case 2: _currentMinFoV = storage.MinFoV; _currentMaxFoV = storage.MaxFoV; _currentAnomaly = storage.BestAnomalyChance; break; } _currentPart = storage.CurrentPart; _currentInterface = storage.Accessor; }
private void ScanVessel() { _kerbnets.Clear(); var accessors = _activeVessel.FindPartModulesImplementing <IAccessKerbNet>(); MonoBehaviour.print("[KerbNet Controller] Scanning Vessel [" + _activeVessel.vesselName + "]... Found [" + accessors.Count + "] KerbNet Parts"); for (int i = accessors.Count - 1; i >= 0; i--) { IAccessKerbNet access = accessors[i]; if (access == null) { return; } List <string> modes = access.GetKerbNetDisplayModes(); for (int j = modes.Count - 1; j >= 0; j--) { string mode = modes[j]; if (_kerbnets.ContainsKey(mode)) { KerbNetStorage storage = _kerbnets[mode]; float min = access.GetKerbNetMinimumFoV(); if (min < storage.BestMinFoV) { storage.BestMinFoV = min; } float max = access.GetKerbNetMaximumFoV(); if (max > storage.BestMaxFoV) { storage.BestMaxFoV = max; } float anom = access.GetKerbNetAnomalyChance(); if (anom > storage.BestAnomalyChance) { storage.BestAnomalyChance = anom; } if (max - min > storage.WidestRange) { storage.WidestRange = max - min; storage.MinFoV = min; storage.MaxFoV = max; storage.CurrentPart = access.GetKerbNetPart(); storage.Accessor = access; } if (min < _bestMinFoV) { _bestMinFoV = min; } if (max > _bestMaxFoV) { _bestMaxFoV = max; } if (anom > _bestAnomaly) { _bestAnomaly = anom; } if (mode == "Resources") { UpdateResourceModes(storage); } } else { KerbNetStorage storage = new KerbNetStorage(mode); storage.MinFoV = access.GetKerbNetMinimumFoV(); storage.BestMinFoV = storage.MinFoV; storage.MaxFoV = access.GetKerbNetMaximumFoV(); storage.BestMaxFoV = storage.MaxFoV;; storage.BestAnomalyChance = access.GetKerbNetAnomalyChance(); storage.WidestRange = storage.MaxFoV - storage.MinFoV; storage.CurrentPart = access.GetKerbNetPart(); storage.Accessor = access; if (storage.MinFoV < _bestMinFoV) { _bestMinFoV = storage.MinFoV; } if (storage.MaxFoV > _bestMaxFoV) { _bestMaxFoV = storage.MaxFoV; } if (storage.BestAnomalyChance > _bestAnomaly) { _bestAnomaly = storage.BestAnomalyChance; } if (mode == "Resources") { _kerbnets.Add(mode, storage); AddResourceModes(storage); } else { _kerbnets.Add(mode, storage); } } } } }