9 : _visual(visual), _duration(10.0f / server_tick_rate)
17 float angle = (
static_cast<float>(i) /
PARTICLE_COUNT) * 2.0f * PI +
18 (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * 0.4f;
19 float speed = 0.9f + (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * 0.85f;
23 p.
vel.x = std::cos(angle) * speed;
24 p.
vel.y = 0.6f + (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * 0.5f;
25 p.
vel.z = std::sin(angle) * speed;
26 p.
color = {180, 255, 120, 255};
27 p.
size = 0.06f + (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * 0.05f;
39 if (t > 1.0f) t = 1.0f;
41 float smooth = t * t * (3.0f - 2.0f * t);
52 if (burstAge <= 0.0f)
break;
53 p.pos.x += p.vel.x * dt;
54 p.pos.y += p.vel.y * dt;
55 p.pos.z += p.vel.z * dt;
57 p.alpha = 1.0f - (burstAge / (
_duration * 0.25f));
58 if (p.alpha < 0.0f) p.alpha = 0.0f;
static constexpr int PARTICLE_COUNT
static constexpr int PARTICLE_COUNT
std::vector< Particle > _particles
ForkBehavior(VisualState &visual, float server_tick_rate)
void update(float dt) override
bool isDone() const override
Returns true when the behavior has completed and can be removed.
Visual-only state for an entity, driven by behaviors each frame. Logical state (x,...