private void BuildEvaluateList(GameSnapshotModel snapshot) { List <Build> newNotifications = new List <Build>(), removedNotifications = new List <Build>(), changedNotifications = new List <Build>(); lock (mutex) { int oldNumber = _currentBuilds.Count; int newNumber = snapshot.ProjectPct.Length; int commonNumber = Math.Min(oldNumber, newNumber); for (int i = 0; i < commonNumber; i++) { var curr = _currentBuilds[i]; var newValue = snapshot.ProjectPct[i]; if (curr.Value != newValue) { if (curr.Value == 0) { newNotifications.Add(curr); } else if (newValue == 0) { removedNotifications.Add(curr); } else { changedNotifications.Add(curr); } curr.Value = newValue; } } for (int i = oldNumber; i < newNumber; i++) { var newValue = snapshot.ProjectPct[i]; var notification = new Build() { Number = i, Value = newValue }; if (newValue > 0) { newNotifications.Add(notification); } _currentBuilds.Add(notification); } for (int i = newNumber; i < oldNumber; i++) { var curr = _currentBuilds[i]; if (curr.Value > 0) { removedNotifications.Add(curr); } } if (newNumber < oldNumber) { _currentBuilds.RemoveRange(newNumber, newNumber - oldNumber); } } if (newNotifications.Count > 0) { FireNewBuildNotification(newNotifications); } if (changedNotifications.Count > 0) { FireChangedBuildNotification(changedNotifications); } if (removedNotifications.Count > 0) { FireRemovedBuildNotification(removedNotifications); } }
private void DailyDealEvaluateList(GameSnapshotModel snapshot) => GenericEvaluteList(snapshot.DailyDeals, ntf => ntf.StoreItem, (oldn, newn) => oldn.Update(newn), _currentDailyDealsNotifications, FireNewDailyDealNotification, FireChangedDailyDealNotification, FireRemovedDailyDealNotification);
private void InvasionEvaluateList(GameSnapshotModel snapshot) => GenericEvaluteList(snapshot.Invasions, ntf => ntf.Id.Oid, (oldn, newn) => oldn.Update(newn), _currentInvasionsNotifications, FireNewInvasionNotification, FireChangedInvasionNotification, FireRemovedInvasionNotification);
private void VoidEvaluateList(GameSnapshotModel snapshot) => GenericEvaluteList(snapshot.VoidTraders, ntf => ntf.Id.Oid, (oldn, newn) => oldn.Update(newn), _currentVoidsNotifications, FireNewVoidTraderNotification, FireChangedVoidTraderNotification, FireRemovedVoidTraderNotification);
private void AlertEvaluateList(GameSnapshotModel snapshot) => GenericEvaluteList(snapshot.Alerts, ntf => ntf.Id.Oid, null, _currentAlertsNotifications, FireNewAlertNotification, null, FireRemovedAlertNotification);