populate fleet summaries into sourcecache

This commit is contained in:
Torben Nehmer 2024-10-08 19:26:34 +02:00
parent 64c99fa1a0
commit a383f63a61
No known key found for this signature in database

View File

@ -36,6 +36,7 @@ public class FleetManager : IEnableLogger
public override string ToString() => $"To {Destination}: {TotalIronium}I/{TotalBoranium}B/{TotalGermanium}G/{TotalColonists}C"; public override string ToString() => $"To {Destination}: {TotalIronium}I/{TotalBoranium}B/{TotalGermanium}G/{TotalColonists}C";
} }
private IObservable<IChangeSet<FleetSummary>>? _fleetSummaries; private IObservable<IChangeSet<FleetSummary>>? _fleetSummaries;
private ReadOnlyObservableCollection<FleetSummary>? summaries; private ReadOnlyObservableCollection<FleetSummary>? summaries;
@ -59,26 +60,15 @@ public class FleetManager : IEnableLogger
TotalGermanium = group.List.Items.Sum(f => f.Germanium), TotalGermanium = group.List.Items.Sum(f => f.Germanium),
TotalColonists = group.List.Items.Sum(f => f.Colonists) TotalColonists = group.List.Items.Sum(f => f.Colonists)
}) })
// .Transform(group =>
// group.List.Connect()
// .QueryWhenChanged(query =>
// {
// var iro = query.Sum(f => f.Ironium);
// var bor = query.Sum(f => f.Boranium);
// var ger = query.Sum(f => f.Germanium);
// var col = query.Sum(f => f.Colonists);
// return new FleetSummary
// {
// Destination = group.GroupKey,
// TotalIronium = iro,
// TotalBoranium = bor,
// TotalGermanium = ger,
// TotalColonists = col
// };
// })
// )
; ;
// Demo only
var sourceCache = new SourceCache<FleetSummary, string>(fs => fs.Destination);
var tmp = _fleetSummaries
.AddKey(fs => fs.Destination)
.PopulateInto(sourceCache);
_fleetSummaries _fleetSummaries
.ObserveOn(RxApp.MainThreadScheduler) .ObserveOn(RxApp.MainThreadScheduler)
.Bind(out summaries) .Bind(out summaries)