forked from LukeZurg22/SKSSL
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGameManager.cs
More file actions
37 lines (31 loc) · 1023 Bytes
/
GameManager.cs
File metadata and controls
37 lines (31 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace SKSSL;
/// <summary>
/// Static class game manager used to run and handle total game instance.
/// </summary>
public static class GameManager
{
/// Topmost game instance reverse-accessible from lower ends of the call-chain.
public static SSLGame Game { get; private set; } = null!;
/// Title of game window.
public static string Title => Game.Title;
/// Aspect ratio to render the game.
public static float AspectRatio => Game.GraphicsDevice.Viewport.AspectRatio;
/// Force game closure.
public static void Exit()
{
// Safely exit without suicidal tendencies.
SSLGame game = Game;
SSLGame.Quit();
game.Exit();
}
/// Force game status reset.
public static void ResetGame() => SSLGame.ResetGame();
/// Run the game instance.
public static void Run<T>() where T : SSLGame, new()
{
// Safely run without running-the-gun.
using T type = new();
Game = type;
Game.Run();
}
}