2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_COMPONENTS_PARTICLES_H
|
|
|
|
#define GAME_CLIENT_COMPONENTS_PARTICLES_H
|
|
|
|
#include <base/vmath.h>
|
|
|
|
#include <game/client/component.h>
|
|
|
|
|
|
|
|
// particles
|
|
|
|
struct CParticle
|
|
|
|
{
|
|
|
|
void SetDefault()
|
|
|
|
{
|
|
|
|
m_Vel = vec2(0,0);
|
|
|
|
m_LifeSpan = 0;
|
|
|
|
m_StartSize = 32;
|
|
|
|
m_EndSize = 32;
|
|
|
|
m_Rot = 0;
|
|
|
|
m_Rotspeed = 0;
|
|
|
|
m_Gravity = 0;
|
|
|
|
m_Friction = 0;
|
|
|
|
m_FlowAffected = 1.0f;
|
2019-04-26 21:47:34 +00:00
|
|
|
m_Color = ColorRGBA(1,1,1,1);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
vec2 m_Pos;
|
|
|
|
vec2 m_Vel;
|
|
|
|
|
|
|
|
int m_Spr;
|
|
|
|
|
|
|
|
float m_FlowAffected;
|
|
|
|
|
|
|
|
float m_LifeSpan;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float m_StartSize;
|
|
|
|
float m_EndSize;
|
|
|
|
|
|
|
|
float m_Rot;
|
|
|
|
float m_Rotspeed;
|
|
|
|
|
|
|
|
float m_Gravity;
|
|
|
|
float m_Friction;
|
|
|
|
|
2019-04-26 21:47:34 +00:00
|
|
|
ColorRGBA m_Color;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// set by the particle system
|
|
|
|
float m_Life;
|
|
|
|
int m_PrevPart;
|
|
|
|
int m_NextPart;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CParticles : public CComponent
|
|
|
|
{
|
|
|
|
friend class CGameClient;
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
GROUP_PROJECTILE_TRAIL=0,
|
|
|
|
GROUP_EXPLOSIONS,
|
|
|
|
GROUP_GENERAL,
|
|
|
|
NUM_GROUPS
|
|
|
|
};
|
|
|
|
|
|
|
|
CParticles();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2019-04-11 22:46:54 +00:00
|
|
|
void Add(int Group, CParticle *pPart, float TimePassed = 0.f);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void OnReset();
|
|
|
|
virtual void OnRender();
|
2018-03-13 20:52:44 +00:00
|
|
|
virtual void OnInit();
|
2010-05-29 07:25:38 +00:00
|
|
|
private:
|
2018-03-13 20:52:44 +00:00
|
|
|
int m_ParticleQuadContainerIndex;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_PARTICLES=1024*8,
|
|
|
|
};
|
|
|
|
|
|
|
|
CParticle m_aParticles[MAX_PARTICLES];
|
|
|
|
int m_FirstFree;
|
|
|
|
int m_aFirstPart[NUM_GROUPS];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void RenderGroup(int Group);
|
|
|
|
void Update(float TimePassed);
|
|
|
|
|
|
|
|
template<int TGROUP>
|
|
|
|
class CRenderGroup : public CComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CParticles *m_pParts;
|
|
|
|
virtual void OnRender() { m_pParts->RenderGroup(TGROUP); }
|
|
|
|
};
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CRenderGroup<GROUP_PROJECTILE_TRAIL> m_RenderTrail;
|
|
|
|
CRenderGroup<GROUP_EXPLOSIONS> m_RenderExplosions;
|
|
|
|
CRenderGroup<GROUP_GENERAL> m_RenderGeneral;
|
|
|
|
};
|
|
|
|
#endif
|