fixup fleet summaries
This commit is contained in:
@ -7,6 +7,7 @@ using ReactiveUI;
|
||||
using ReactiveUI.SourceGenerators;
|
||||
using StarsAssistant.Services;
|
||||
using Splat;
|
||||
using StarsAssistant.Model;
|
||||
|
||||
namespace StarsAssistant.ViewModels;
|
||||
|
||||
@ -14,13 +15,15 @@ public partial class PlayerPlanetViewModel : ViewModelBase
|
||||
{
|
||||
private readonly Model.Planet Planet;
|
||||
|
||||
private Game Game;
|
||||
private readonly Services.Game Game;
|
||||
|
||||
private readonly IObservable<Change<FleetSummaryByDestination, string>> _fleetSummaryChanges;
|
||||
|
||||
public PlayerPlanetViewModel(Model.Planet planet)
|
||||
{
|
||||
Game = Locator.Current.GetService<Game>()!;
|
||||
Game = Locator.Current.GetService<Services.Game>()!;
|
||||
|
||||
if (planet.OwnerId != Game.Player.Name)
|
||||
if (planet.OwnerId != Services.Game.Player.Name)
|
||||
throw new InvalidOperationException("PlayerPlanet ViewModels can only be created for player planets.");
|
||||
|
||||
Planet = planet;
|
||||
@ -58,13 +61,13 @@ public partial class PlayerPlanetViewModel : ViewModelBase
|
||||
|
||||
FleetManager fm = Locator.Current.GetService<FleetManager>()!;
|
||||
|
||||
var fleetSummaryChanges = fm.FleetSummaries
|
||||
_fleetSummaryChanges = fm.FleetSummariesByDestination
|
||||
.Connect()
|
||||
.Watch(Name)
|
||||
.Log(this, "fleetSummaryChange", change => $"{Name}: {change.Reason}: {change.Previous} => {change.Current}")
|
||||
;
|
||||
|
||||
_populationEnRouteHelper = fleetSummaryChanges
|
||||
_populationEnRouteHelper = _fleetSummaryChanges
|
||||
.Select(change => change.Reason != ChangeReason.Remove ? change.Current.TotalColonists : 0)
|
||||
.Log(this, "PopulationEnRoute", pop => $"{Name}: {pop}")
|
||||
.ToProperty(this, vm => vm.PopulationEnRoute)
|
||||
|
Reference in New Issue
Block a user