finished rewrite of player planet loading

This commit is contained in:
Torben Nehmer 2025-01-26 13:29:41 +01:00
parent 8f63587966
commit bfdbc347eb
No known key found for this signature in database

View File

@ -25,10 +25,7 @@ public class PlanetManager : IDisposable, IEnableLogger
/// Observable changeset showing all player planets converted to view models. /// Observable changeset showing all player planets converted to view models.
/// </summary> /// </summary>
public IObservable<IChangeSet<PlayerPlanetViewModel, string>> PlayerPlanetsSource public IObservable<IChangeSet<PlayerPlanetViewModel, string>> PlayerPlanetsSource
=> _planets => _playerPlanets.AsObservableCache().Connect();
.Connect()
.Filter(planet => planet.OwnerId == Game.Player.Name)
.Transform(planet => new PlayerPlanetViewModel(planet));
/// <summary> /// <summary>
/// Cache with all player planets, indexed by planet name. /// Cache with all player planets, indexed by planet name.
@ -64,6 +61,7 @@ public class PlanetManager : IDisposable, IEnableLogger
var planetsToDelete = cacheKeys.Except(planetNames); var planetsToDelete = cacheKeys.Except(planetNames);
_planets.Edit(innerCache => _planets.Edit(innerCache =>
{ {
// TODO: Update Planet loop in the same way as the player planet update loop
foreach (var name in planetsToDelete) foreach (var name in planetsToDelete)
innerCache.RemoveKey(name); innerCache.RemoveKey(name);
innerCache.AddOrUpdate(allPlanets); innerCache.AddOrUpdate(allPlanets);