Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
ParticleEmitterComponent.h
Go to the documentation of this file.
1/**
2 * @file ParticleEmitterComponent.h
3 * @ingroup mnd_components
4 * @brief Spawns particles each frame at the owner's world position.
5 *
6 * Pushes Particle instances into Engine::GetParticleSystem(). All emission
7 * parameters are JSON-tunable. Random ranges are uniform between *Min and *Max.
8 */
9
10#pragma once
11
12#include <random>
13
14#include "scene/Component.h"
15
16namespace mnd
17{
18
20{
22 public:
23 void Update(f32 deltaTime) override;
24 void LoadProperties(const nlohmann::json &json) override;
25
26 void SetEmitting(bool on) { m_emitting = on; }
27 [[nodiscard]] bool IsEmitting() const { return m_emitting; }
28
29 /// Single-shot burst at the owner's current position (e.g. on death/hit).
30 void Burst(int count);
31
32 private:
33 void EmitOne();
34
35 bool m_emitting = true;
36 f32 m_rate = 30.0F; ///< Particles per second.
37 f32 m_accum = 0.0F; ///< Internal time accumulator.
38
39 vec3 m_offset{0.0F}; ///< World offset added to owner position.
40 vec3 m_velocityMin{-0.5F, 1.0F, -0.5F};
41 vec3 m_velocityMax{0.5F, 2.5F, 0.5F};
42 vec3 m_acceleration{0.0F, -2.0F, 0.0F};
43
44 f32 m_lifetimeMin = 0.6F;
45 f32 m_lifetimeMax = 1.2F;
46 f32 m_sizeStart = 0.18F;
47 f32 m_sizeEnd = 0.0F;
48
49 vec4 m_colorStart{1.0F, 0.85F, 0.45F, 1.0F};
50 vec4 m_colorEnd{1.0F, 0.20F, 0.10F, 0.0F};
51
52 std::mt19937 m_rng{std::random_device{}()};
53};
54
55} // namespace mnd
void LoadProperties(const nlohmann::json &json) override
void Burst(int count)
Single-shot burst at the owner's current position (e.g. on death/hit).
void Update(f32 deltaTime) override
#define COMPONENT(ComponentClass)
Definition Component.h:105
glm::vec4 vec4
4-component float vector (e.g. RGBA colour, homogeneous coords).
Definition Types.h:52
glm::vec3 vec3
3-component float vector (e.g. world position, RGB colour, normals).
Definition Types.h:51
float f32
32-bit IEEE float — the standard GL scalar type.
Definition Types.h:40