Use ResourceRefs for RenderSystem, add IReloadableSystem, remove UI package.
This commit is contained in:
@@ -5,6 +5,7 @@ using Voile.Input;
|
||||
using Voile.Systems.Particles;
|
||||
using System.Numerics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics;
|
||||
|
||||
public class TestGame : Game
|
||||
{
|
||||
@@ -19,6 +20,8 @@ public class TestGame : Game
|
||||
ResourceManager.AddResourceLoaderAssociation(new ParticleEmitterSettingsResourceLoader());
|
||||
|
||||
Input.AddInputMapping("reload", new InputAction[] { new KeyInputAction(KeyboardKey.R) });
|
||||
|
||||
_particleSimStopwatch = new Stopwatch();
|
||||
}
|
||||
|
||||
protected override void LoadResources()
|
||||
@@ -28,10 +31,12 @@ public class TestGame : Game
|
||||
|
||||
// }
|
||||
|
||||
// if (!ResourceManager.TryLoad("inter_regular", "fonts/Inter-Regular.ttf", out Font? _font))
|
||||
// {
|
||||
if (!ResourceManager.TryLoad("fonts/Inter-Regular.ttf", out _font))
|
||||
{
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
ResourceManager.TryLoad("icon.png", out _icon);
|
||||
|
||||
if (!ResourceManager.TryLoad("test_emitter.toml", out _emitterSettings))
|
||||
{
|
||||
@@ -54,7 +59,9 @@ public class TestGame : Game
|
||||
_particleSystem!.RestartEmitter(_emitterId);
|
||||
}
|
||||
|
||||
_particleSimStopwatch = Stopwatch.StartNew();
|
||||
_particleSystem!.Update(Renderer.FrameTime);
|
||||
_particleSimStopwatch.Stop();
|
||||
|
||||
Renderer.BeginFrame();
|
||||
Renderer.ClearBackground(Color.Black);
|
||||
@@ -63,7 +70,14 @@ public class TestGame : Game
|
||||
DrawEmitter(emitter);
|
||||
}
|
||||
|
||||
Renderer.SetTransform(Renderer.WindowSize / 2, Vector2.Zero);
|
||||
Renderer.DrawTexture(_icon, Color.White);
|
||||
|
||||
Renderer.ResetTransform();
|
||||
Renderer.DrawText(_font, $"Particle Sim: {TimeSpan.FromTicks(_particleSimStopwatch.ElapsedTicks).TotalMilliseconds} ms", Color.White);
|
||||
|
||||
Renderer.EndFrame();
|
||||
_particleSimStopwatch.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +104,11 @@ public class TestGame : Game
|
||||
}
|
||||
|
||||
[NotNull] private ParticleSystem _particleSystem;
|
||||
|
||||
private Stopwatch _particleSimStopwatch;
|
||||
private int _emitterId;
|
||||
private ResourceRef<ParticleEmitterSettingsResource> _emitterSettings;
|
||||
private ResourceRef<Font> _font;
|
||||
private ResourceRef<Texture2d> _icon;
|
||||
private Logger _logger = new(nameof(TestGame));
|
||||
}
|
||||
Reference in New Issue
Block a user