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 UpdateResourceModes(KerbNetStorage store) { if (ResourceMap.Instance == null) { return; } List <string> resources = ResourceMap.Instance.FetchAllResourceNames(HarvestTypes.Planetary); for (int i = resources.Count - 1; i >= 0; i--) { string s = resources[i]; if (string.IsNullOrEmpty(s)) { continue; } if (!_kerbnets.ContainsKey(s)) { continue; } KerbNetStorage storage = _kerbnets[s]; storage.WidestRange = store.WidestRange; storage.MinFoV = store.MinFoV; storage.MaxFoV = store.MaxFoV; storage.BestAnomalyChance = store.BestAnomalyChance; storage.BestMaxFoV = store.BestMaxFoV; storage.BestMinFoV = store.BestMinFoV; storage.CurrentPart = store.CurrentPart; storage.Accessor = store.Accessor;; } }
private void AddResourceModes(KerbNetStorage store) { if (ResourceMap.Instance == null) { return; } List <string> resources = ResourceMap.Instance.FetchAllResourceNames(HarvestTypes.Planetary); for (int i = resources.Count - 1; i >= 0; i--) { string s = resources[i]; if (string.IsNullOrEmpty(s)) { continue; } if (!_kerbnets.ContainsKey(s)) { _kerbnets.Add(s, store); } } }
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); } } } } }