9 : _visual(visual), _duration(20.0f / server_tick_rate)
15 static const Color COLORS[] = {
26 float angle = (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * 2.0f * PI;
27 float spread = (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * 0.25f;
28 float speed = 2.5f + (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * 2.5f;
32 p.
vel.x = std::cos(angle) * spread * speed;
34 p.
vel.z = std::sin(angle) * spread * speed;
35 p.
color = COLORS[rand() % 4];
36 p.
size = 0.04f + (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * 0.05f;
38 p.
delay = (
static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * (
_duration * 0.6f);
63 p.alpha = remaining > 0.0f ? std::min(1.0f, remaining / (
_duration * 0.4f)) : 0.0f;
64 p.pos.x += p.vel.x * dt;
65 p.pos.y += p.vel.y * dt;
66 p.pos.z += p.vel.z * dt;
static constexpr int PARTICLE_COUNT
static constexpr int PARTICLE_COUNT
std::vector< Particle > _particles
LevelUpBehavior(VisualState &visual, float server_tick_rate)
bool isDone() const override
Returns true when the behavior has completed and can be removed.
void update(float dt) override
Visual-only state for an entity, driven by behaviors each frame. Logical state (x,...