Make most subsystems available as protected properties in base Game class, implement IDisposable on systems.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using System.Numerics;
|
||||
|
||||
using Voile;
|
||||
using Voile.Rendering;
|
||||
using Voile.Audio;
|
||||
@@ -7,43 +5,16 @@ using Voile.Resources;
|
||||
using Voile.SceneGraph;
|
||||
using Voile.Utils;
|
||||
|
||||
|
||||
public class TestGame : Game
|
||||
{
|
||||
public override string ResourceRoot => "Resources/";
|
||||
|
||||
public TestGame() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
_renderer = new RaylibRenderer();
|
||||
InitializeDefault();
|
||||
|
||||
_audioBackend = new FmodAudioBackend();
|
||||
_inputHandler = new RaylibInputHandler();
|
||||
|
||||
_renderer.CreateAndInitialize(new WindowSettings()
|
||||
{
|
||||
Title = "Test Game",
|
||||
Size = new Vector2(1280, 720),
|
||||
}, new RendererSettings()
|
||||
{
|
||||
UseVSync = true,
|
||||
Fullscreen = false
|
||||
});
|
||||
|
||||
_audioBackend.Initialize();
|
||||
|
||||
_scene = new Scene(new SceneSettings()
|
||||
{
|
||||
Renderer = _renderer,
|
||||
AudioBackend = _audioBackend,
|
||||
InputHandler = _inputHandler,
|
||||
ResourceManager = ResourceManager
|
||||
});
|
||||
|
||||
_uiLayer = new UiLayer();
|
||||
_worldLayer = new EntityLayer();
|
||||
}
|
||||
|
||||
protected override void LoadResources()
|
||||
@@ -66,9 +37,20 @@ public class TestGame : Game
|
||||
|
||||
protected override void Ready()
|
||||
{
|
||||
_inputHandler!.AddInputMapping("play", new InputAction[] { new KeyInputAction(KeyboardKey.Spacebar) });
|
||||
_inputHandler.AddInputMapping("sprint", new InputAction[] { new KeyInputAction(KeyboardKey.LeftShift) });
|
||||
_inputHandler.AddInputMapping("toggle_fullscreen", new InputAction[] { new KeyInputAction(KeyboardKey.F11) });
|
||||
_scene = new Scene(new SceneSettings()
|
||||
{
|
||||
Renderer = Renderer,
|
||||
AudioBackend = _audioBackend!,
|
||||
InputHandler = Input,
|
||||
ResourceManager = ResourceManager
|
||||
});
|
||||
|
||||
_uiLayer = new UiLayer();
|
||||
_worldLayer = new EntityLayer();
|
||||
|
||||
Input.AddInputMapping("play", new InputAction[] { new KeyInputAction(KeyboardKey.Spacebar) });
|
||||
Input.AddInputMapping("sprint", new InputAction[] { new KeyInputAction(KeyboardKey.LeftShift) });
|
||||
Input.AddInputMapping("toggle_fullscreen", new InputAction[] { new KeyInputAction(KeyboardKey.F11) });
|
||||
|
||||
_scene!.AddLayer("World", _worldLayer!);
|
||||
|
||||
@@ -91,15 +73,13 @@ public class TestGame : Game
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
_renderer!.Shutdown();
|
||||
_audioBackend?.Shutdown();
|
||||
ShutdownDefault();
|
||||
_audioBackend!.Dispose();
|
||||
}
|
||||
|
||||
private Renderer? _renderer;
|
||||
private Sound? _testSound;
|
||||
private Font? _font;
|
||||
private FmodAudioBackend? _audioBackend;
|
||||
private InputHandler? _inputHandler;
|
||||
private Scene? _scene;
|
||||
|
||||
private UiLayer? _uiLayer;
|
||||
|
||||
Reference in New Issue
Block a user