Move player to game engine.
This commit is contained in:
@ -53,6 +53,6 @@ public partial class CSVDataLoader : IEnableLogger
|
||||
|
||||
this.Log().Debug($"Got file type {type} for player {player}");
|
||||
var loader = new CSV.PlanetLoader();
|
||||
loader.ImportForRace(Model.Race.Player);
|
||||
loader.ImportForRace(Services.Game.Player);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.Reflection.PortableExecutable;
|
||||
using Splat;
|
||||
|
||||
namespace StarsAssistant.Services;
|
||||
@ -64,6 +65,22 @@ public class Game
|
||||
/// </summary>
|
||||
public string PlanetFileSearchPattern => $"{BaseName}.p*";
|
||||
|
||||
/// <summary>
|
||||
/// Internal helper to lazily load the current player from the DB.
|
||||
/// </summary>
|
||||
private readonly static Lazy<Model.Race>LazyPlayer = new ( () => {
|
||||
using var db = Locator.Current.GetService<Model.StarsDatabase>()!;
|
||||
Model.Race result = db.Race
|
||||
.Where(r => r.PlayerRace == true)
|
||||
.First();
|
||||
return result;
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Get the Race object for the current player, lazy initialized.
|
||||
/// </summary>
|
||||
public static Model.Race Player => LazyPlayer.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of a planet file for a given race.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user