Use ResourceRefs for RenderSystem, add IReloadableSystem, remove UI package.

This commit is contained in:
2024-10-15 21:51:26 +02:00
parent 4d5c6bbe9a
commit 7dff8076b9
14 changed files with 64 additions and 248 deletions

View File

@@ -1,14 +1,14 @@
[ParticleEmitterSettings]
MaxParticles = 256
EmitRadius = 32
Explosiveness = 0.0
LifeTime = 0.5
MaxParticles = 4096
EmitRadius = 128
Explosiveness = 1.0
LifeTime = 1.0
Direction = [0.0, 1.0]
LinearVelocity = 200
Gravity = [0.0, 980.0]
Gravity = [0.0, 0.0]
LinearVelocityRandom = 0.5
ScaleBegin = 1.0
ScaleEnd = 2.0
ScaleEnd = 0.0
ColorBegin = [255, 0, 255, 255]
ColorEnd = [0, 0, 0, 0]

View File

@@ -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));
}