diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-25 00:32:16 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-25 00:32:16 -0700 |
| commit | a779011b9048cdda04887c77e20ee8936f332a7a (patch) | |
| tree | 6a771ff692d1717967755cc56e4534a582dd117a /src/vfx/mod.rs | |
| parent | 9cb48c504ddb3882f39e2b17048f0593316a95ce (diff) | |
vfx pipeline
Diffstat (limited to 'src/vfx/mod.rs')
| -rw-r--r-- | src/vfx/mod.rs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/vfx/mod.rs b/src/vfx/mod.rs new file mode 100644 index 0000000..3a7d1a5 --- /dev/null +++ b/src/vfx/mod.rs @@ -0,0 +1,58 @@ +use glam::Vec2; + +use crate::content::vfx::VfxMaterialId; + +pub struct VfxLine { + pub a: Vec2, + pub b: Vec2, + pub width: f32, + pub material: VfxMaterialId, + pub alive_for: f32, + pub lifetime: f32, +} + +impl VfxLine { + pub fn new(a: Vec2, b: Vec2, width: f32, material: VfxMaterialId, lifetime: f32) -> Self { + VfxLine { + a, + b, + width, + material, + alive_for: 0.0, + lifetime, + } + } +} + +pub trait VfxWriter { + fn write_vfx_line(&mut self, line: VfxLine) -> (); +} + +pub struct VfxManager { + pub lines: Vec<VfxLine>, +} + +impl VfxManager { + pub fn after_render(&mut self, delta_time: f32) { + let mut i = 0; + while i < self.lines.len() { + let l = &mut self.lines[i]; + l.alive_for += delta_time; + if l.alive_for > l.lifetime { + self.lines.swap_remove(i); + continue; + } + i += 1; + } + } + + pub fn new() -> Self { + VfxManager { lines: Vec::new() } + } +} + +impl VfxWriter for VfxManager { + fn write_vfx_line(&mut self, line: VfxLine) -> () { + self.lines.push(line); + } +} |
