From c21e275b6d437aaa937b674a04be683636d6e2fa Mon Sep 17 00:00:00 2001 From: dnesov Date: Thu, 17 Oct 2024 02:20:47 +0200 Subject: [PATCH] Update TestGame, add emitter removing, update TODO --- TODO.md | 9 +++++---- TestGame/TestGame.cs | 2 +- Voile/Source/Systems/ParticleSystem.cs | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index b4b0b81..1b29f2a 100644 --- a/TODO.md +++ b/TODO.md @@ -20,7 +20,7 @@ ## Serialization - Serialize attribute. -- Add automatic serialization of resources through code generation and System.Text.Json. +- Add automatic serialization of resources through source generation and System.Text.Json. - ~~Provide means for fetching key/value configuration (INI? TOML?)~~ - Expose some sort of ConfigFile class for safe key/value configuration fetching. @@ -34,17 +34,17 @@ ## Audio - ~~Integrate FMOD~~ -- 2D audio abstraction +- Use SoLoud as a default sound engine. ## Misc - ~~Asset manager~~ - ~~Separate engine and game into separate projects~~ -- Particle system 2.0 +- ~~Particle system 2.0~~ - ~~Reduce the size of Particle struct by infering most parameters through lifetime.~~ - ~~Reduce cache misses by utilizing SoA.~~ - ~~SIMD acceleration.~~ - - Dynamically resize particle arrays as emitters get added or removed. + - ~~Creating and removing emitters.~~ ## SceneGraph module @@ -55,6 +55,7 @@ ## Input - ~~Action system~~ +- Nicer input mapping API using code. - Make action system use an InputMap resource instead. - Gamepad support diff --git a/TestGame/TestGame.cs b/TestGame/TestGame.cs index 78b0efc..52807c1 100644 --- a/TestGame/TestGame.cs +++ b/TestGame/TestGame.cs @@ -70,7 +70,7 @@ public class TestGame : BaseGame } Renderer.ResetTransform(); - Renderer.DrawText(_font, $"Particle Sim: {TimeSpan.FromTicks(_particleSimStopwatch.ElapsedTicks).TotalMilliseconds} ms", Color.White); + Renderer.DrawText(_font, $"Particle Sim: {_particleSimStopwatch.Elapsed.TotalMilliseconds} ms", Color.White); Renderer.SetTransform(new Vector2(0.0f, 16.0f), Vector2.Zero); Renderer.DrawText(_font, $"Render: {RenderFrameTime.TotalMilliseconds:F1} ms", Color.White); diff --git a/Voile/Source/Systems/ParticleSystem.cs b/Voile/Source/Systems/ParticleSystem.cs index e91be06..f296ac7 100644 --- a/Voile/Source/Systems/ParticleSystem.cs +++ b/Voile/Source/Systems/ParticleSystem.cs @@ -258,6 +258,17 @@ public class ParticleSystem : IUpdatableSystem, IDisposable return _emitters.Count - 1; } + public void RemoveEmitter(int emitterIdx) + { + if (emitterIdx >= _emitters.Count) + { + throw new ArgumentException($"Emitter with idx {emitterIdx} is not present!"); + } + + // var emitter = _emitters[emitterIdx]; + _emitters.RemoveAt(emitterIdx); + } + public void SetEmitterPosition(int emitterIdx, Vector2 position) { if (emitterIdx >= _emitters.Count)