8 t = t < 0.0f ? 0.0f : (t > 1.0f ? 1.0f : t);
9 return t * t * (3.0f - 2.0f * t);
12static float lerpf(
float a,
float b,
float t) {
return a + (b - a) * t; }
14static Vector3
lerpv(Vector3 a, Vector3 b,
float t)
23 while (diff > PI) diff -= 2.0f * PI;
24 while (diff < -PI) diff += 2.0f * PI;
29 int totalPlayers,
float tileCenterX,
float tileCenterZ,
30 float tileSize,
float serverTickRate)
33 _isParticleOwner(playerIndex == 0),
34 _duration(300.0f / serverTickRate)
38 float angle = playerIndex * (2.0f * PI /
static_cast<float>(totalPlayers));
40 _slotPos = {tileCenterX + std::cos(angle) * radius, 0.0f,
41 tileCenterZ + std::sin(angle) * radius};
55 static const Color COLORS[] = {
63 float angle = (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX)) * 2.0f * PI;
64 float spread = (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX)) * 0.15f;
69 p.
vel = {(
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX) - 0.5f) * 0.05f,
70 0.15f + (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX)) * 0.2f,
71 (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX) - 0.5f) * 0.05f};
72 p.
color = COLORS[rand() % 3];
73 p.
size = 0.03f + (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX)) * 0.04f;
75 p.
delay = (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX)) * 0.4f;
92 p.pos.x += p.vel.x * dt;
93 p.pos.y += p.vel.y * dt;
94 p.pos.z += p.vel.z * dt;
95 p.alpha -= dt * 0.35f;
98 if (p.alpha <= 0.0f) {
99 float angle = (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX)) * 2.0f * PI;
100 float spread = (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX)) * 0.15f;
101 p.pos = {
_tileCenter.x + std::cos(angle) * spread, 0.1f,
103 p.vel.x = (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX) - 0.5f) * 0.05f;
104 p.vel.y = 0.15f + (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX)) * 0.2f;
105 p.vel.z = (
static_cast<float>(
static_cast<double>(rand()) / RAND_MAX) - 0.5f) * 0.05f;
142 if (
_player.incantationEnded) {
static float smoothstep(float t)
static float lerpf(float a, float b, float t)
static float lerpAngle(float a, float b, float t)
static Vector3 lerpv(Vector3 a, Vector3 b, float t)
std::vector< Particle > _particles
void update(float dt) override
static constexpr float CIRCLE_RADIUS
static constexpr int PARTICLE_COUNT
void _updateParticles(float dt)
static constexpr float END_DURATION
bool isDone() const override
Returns true when the behavior has completed and can be removed.
static constexpr float SPREAD_DURATION
IncantationBehavior(VisualState &visual, Player &player, int playerIndex, int totalPlayers, float tileCenterX, float tileCenterZ, float tileSize, float serverTickRate)
Visual-only state for an entity, driven by behaviors each frame. Logical state (x,...