WIP: ResourceManager refactor, hot reloading using ResourceRef, API changes.
This commit is contained in:
@@ -15,16 +15,25 @@ public class TestGame : Game
|
||||
{
|
||||
InitializeDefault();
|
||||
_particleSystem = new ParticleSystem();
|
||||
|
||||
ResourceManager.AddResourceLoaderAssociation(new ParticleEmitterSettingsResourceLoader());
|
||||
|
||||
Input.AddInputMapping("reload", new InputAction[] { new KeyInputAction(KeyboardKey.R) });
|
||||
}
|
||||
|
||||
protected override void LoadResources()
|
||||
{
|
||||
if (!ResourceManager.TryLoad("my_sound", "sounds/test_sound.ogg", out Sound? _testSound))
|
||||
{
|
||||
// if (!ResourceManager.TryLoad("my_sound", "sounds/test_sound.ogg", out Sound? _testSound))
|
||||
// {
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
if (!ResourceManager.TryLoad("inter_regular", "fonts/Inter-Regular.ttf", out Font? _font))
|
||||
// if (!ResourceManager.TryLoad("inter_regular", "fonts/Inter-Regular.ttf", out Font? _font))
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
if (!ResourceManager.TryLoad("test_emitter.toml", out _emitterSettings))
|
||||
{
|
||||
|
||||
}
|
||||
@@ -32,19 +41,19 @@ public class TestGame : Game
|
||||
|
||||
protected override void Ready()
|
||||
{
|
||||
_particleSystem!.CreateEmitter(Renderer.WindowSize / 2, new ParticleEmitterSettings()
|
||||
{
|
||||
ColorBegin = Color.Green,
|
||||
ColorEnd = Color.Red,
|
||||
EmitRadius = 128,
|
||||
MaxParticles = 256
|
||||
});
|
||||
_emitterId = _particleSystem!.CreateEmitter(Renderer.WindowSize / 2, _emitterSettings);
|
||||
}
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
while (Renderer.ShouldRun)
|
||||
{
|
||||
if (Input.IsActionPressed("reload"))
|
||||
{
|
||||
ResourceManager.Reload();
|
||||
_particleSystem!.RestartEmitter(_emitterId);
|
||||
}
|
||||
|
||||
_particleSystem!.Update(Renderer.FrameTime);
|
||||
|
||||
Renderer.BeginFrame();
|
||||
@@ -77,5 +86,7 @@ public class TestGame : Game
|
||||
}
|
||||
|
||||
private ParticleSystem? _particleSystem;
|
||||
private int _emitterId;
|
||||
private ResourceRef<ParticleEmitterSettingsResource>? _emitterSettings;
|
||||
private Logger _logger = new(nameof(TestGame));
|
||||
}
|
||||
Reference in New Issue
Block a user