From 44ff8f74c05f7a630c86bd01cc2ea7271bde492b Mon Sep 17 00:00:00 2001 From: Ben H Date: Sun, 21 Apr 2024 11:16:59 -0400 Subject: [PATCH] exposing more functionality for manually registering services + added "UI" and "GSM" to project dictionary --- BenMakesGames.PlayPlayMini.sln.DotSettings | 3 +++ .../BenMakesGames.PlayPlayMini.csproj | 4 ++-- .../GameStateManagerBuilder.cs | 20 ++++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 BenMakesGames.PlayPlayMini.sln.DotSettings diff --git a/BenMakesGames.PlayPlayMini.sln.DotSettings b/BenMakesGames.PlayPlayMini.sln.DotSettings new file mode 100644 index 0000000..d9697fd --- /dev/null +++ b/BenMakesGames.PlayPlayMini.sln.DotSettings @@ -0,0 +1,3 @@ + + GSM + UI \ No newline at end of file diff --git a/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj b/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj index 368c7e6..74bced9 100644 --- a/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj +++ b/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj @@ -5,7 +5,7 @@ Ben Hendel-Doying An opinionated framework for making smallish games with MonoGame. 2021-2024 Ben Hendel-Doying - 4.5.0 + 4.6.0 true monogame game engine framework di state @@ -27,7 +27,7 @@ - + diff --git a/BenMakesGames.PlayPlayMini/GameStateManagerBuilder.cs b/BenMakesGames.PlayPlayMini/GameStateManagerBuilder.cs index 0ad1538..274869d 100644 --- a/BenMakesGames.PlayPlayMini/GameStateManagerBuilder.cs +++ b/BenMakesGames.PlayPlayMini/GameStateManagerBuilder.cs @@ -21,7 +21,7 @@ public class GameStateManagerBuilder private AssetCollection GameAssets { get; } = new(); - private Action? AddServicesCallback { get; set; } + private Action? AddServicesCallback { get; set; } private Action? ConfigurationCallback { get; set; } private string WindowTitle { get; set; } = "PlayPlayMini Game"; private (int Width, int Height, int Zoom) WindowSize { get; set; } = (1920 / 3, 1080 / 3, 2); @@ -69,7 +69,7 @@ public GameStateManagerBuilder AddAssets(IList assets) return this; } - public GameStateManagerBuilder AddServices(Action callback) + public GameStateManagerBuilder AddServices(Action callback) { if (AddServicesCallback is not null) throw new ArgumentException("AddServices may only be called once!"); @@ -79,13 +79,23 @@ public GameStateManagerBuilder AddServices(Action callback) instead.")] + public GameStateManagerBuilder AddServices(Action callback) + { + if (AddServicesCallback is not null) + throw new ArgumentException("AddServices may only be called once!"); + + AddServicesCallback = (s, c, _) => callback(s, c); + + return this; + } + + [Obsolete("Use AddServices(Action callback) instead.")] public GameStateManagerBuilder AddServices(Action callback) { if (AddServicesCallback is not null) throw new ArgumentException("AddServices may only be called once!"); - AddServicesCallback = (s, _) => callback(s); + AddServicesCallback = (s, _, _) => callback(s); return this; } @@ -179,7 +189,7 @@ public void Run() .As(typeof(ILogger<>)) .SingleInstance(); - AddServicesCallback?.Invoke(builder, configuration); + AddServicesCallback?.Invoke(builder, configuration, serviceWatcher); if(InitialGameState is null) throw new ArgumentException("No initial game state set! You must call GameStateManagerBuilder's SetInitialGameState method before calling its Run method.");