public bool RemovePlanet(APlanetoidData data) { PlanetoidCategory pType = data.Category; bool isRemoved = _composition[pType].Remove(data); if (_composition[pType].Count == Constants.Zero) { _composition.Remove(pType); } return isRemoved; }
public bool AddPlanet(APlanetoidData data) { PlanetoidCategory pType = data.Category; if (!_composition.ContainsKey(pType)) { _composition.Add(pType, new List<APlanetoidData>()); } if (_composition[pType].Contains(data)) { return false; } _composition[pType].Add(data); return true; }
public bool RemovePlanetoid(APlanetoidData data) { bool isRemoved = _allPlanetoidData.Remove(data); if (!isRemoved) { D.Warn("Attempting to remove {0}.{1} that is not present.", data.FullName, typeof(APlanetoidData)); return false; } UnsubscribeToPlanetoidDataValueChanges(data); RecalcAllProperties(); return true; }
public void AddPlanetoid(APlanetoidData data) { _allPlanetoidData.Add(data); SubscribeToPlanetoidDataValueChanges(data); RecalcAllProperties(); }
private void UnsubscribeToPlanetoidDataValueChanges(APlanetoidData data) { _planetoidSubscribers[data].ForAll<IDisposable>(d => d.Dispose()); _planetoidSubscribers.Remove(data); }
private void SubscribeToPlanetoidDataValueChanges(APlanetoidData data) { if (!_planetoidSubscribers.ContainsKey(data)) { _planetoidSubscribers.Add(data, new List<IDisposable>()); } var planetSubscriber = _planetoidSubscribers[data]; planetSubscriber.Add(data.SubscribeToPropertyChanged<APlanetoidData, int>(pd => pd.Capacity, OnSystemMemberCapacityChanged)); planetSubscriber.Add(data.SubscribeToPropertyChanged<APlanetoidData, OpeYield>(pd => pd.Resources, OnSystemMemberResourceValueChanged)); planetSubscriber.Add(data.SubscribeToPropertyChanged<APlanetoidData, XYield>(pd => pd.SpecialResources, OnSystemMemberSpecialResourceValueChanged)); }
public bool ContainsPlanet(APlanetoidData data) { PlanetoidCategory hull = data.Category; return _composition[hull].Contains(data); }