aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/c_te_largefunnel.cpp
blob: 25430db06e4beebe0467aef9940d7782c826039b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $Workfile:     $
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "c_te_particlesystem.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

//-----------------------------------------------------------------------------
// Purpose: Large Funnel TE
//-----------------------------------------------------------------------------
class C_TELargeFunnel : public C_TEParticleSystem
{
public:
	DECLARE_CLASS( C_TELargeFunnel, C_TEParticleSystem );
	DECLARE_CLIENTCLASS();

					C_TELargeFunnel( void );
	virtual			~C_TELargeFunnel( void );

	virtual void	PostDataUpdate( DataUpdateType_t updateType );


public:
	void			CreateFunnel( void );

	int				m_nModelIndex;
	int				m_nReversed;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
C_TELargeFunnel::C_TELargeFunnel( void )
{
	m_nModelIndex = 0;
	m_nReversed = 0;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
C_TELargeFunnel::~C_TELargeFunnel( void )
{
}


void C_TELargeFunnel::CreateFunnel( void )
{
	CSmartPtr<CSimpleEmitter> pSimple = CSimpleEmitter::Create( "TELargeFunnel" );
	pSimple->SetSortOrigin( m_vecOrigin );

	int			i, j;
	SimpleParticle *pParticle;

	Vector		vecDir;
	Vector		vecDest;

	float ratio = 0.25;
	float invratio = 1 / ratio;

	PMaterialHandle hMaterial = pSimple->GetPMaterial( "sprites/flare6" );

	for ( i = -256 ; i <= 256 ; i += 24 )	//24 from 32.. little more dense
	{
		for ( j = -256 ; j <= 256 ; j += 24 )
		{
			pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), hMaterial, m_vecOrigin );			
			if( pParticle )
			{
				if ( m_nReversed )
				{
					pParticle->m_Pos = m_vecOrigin;

					vecDir[0] = i;
					vecDir[1] = j;
					vecDir[2] = random->RandomFloat(100, 800);

					pParticle->m_uchStartAlpha	= 255;
					pParticle->m_uchEndAlpha	= 0;
				}
				else
				{
					pParticle->m_Pos[0] = m_vecOrigin[0] + i;
					pParticle->m_Pos[1] = m_vecOrigin[1] + j;
					pParticle->m_Pos[2] = m_vecOrigin[2] + random->RandomFloat(100, 800);

					// send particle heading to org at a random speed
					vecDir = m_vecOrigin - pParticle->m_Pos;

					pParticle->m_uchStartAlpha	= 0;
					pParticle->m_uchEndAlpha	= 255;
				}

				vecDir *= ratio;

				pParticle->m_vecVelocity = vecDir;			

				pParticle->m_flLifetime = 0;
				pParticle->m_flDieTime = invratio;	

				if( random->RandomInt( 0, 10 ) < 5 )
				{
					// small green particle
					pParticle->m_uchColor[0] = 0;
					pParticle->m_uchColor[1] = 255;
					pParticle->m_uchColor[2] = 0;
				
					pParticle->m_uchStartSize	= 4.0;
				}
				else
				{
					// large white particle
					pParticle->m_uchColor[0] = 255;
					pParticle->m_uchColor[1] = 255;
					pParticle->m_uchColor[2] = 255;
				
					pParticle->m_uchStartSize	= 15.0;
				}

				pParticle->m_uchEndSize		= pParticle->m_uchStartSize;
				pParticle->m_flRoll			= i;	// pseudorandom
				pParticle->m_flRollDelta	= 0;
				pParticle->m_iFlags = 0;
			}

		}
	}

	return;
}

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bool - 
//-----------------------------------------------------------------------------
void C_TELargeFunnel::PostDataUpdate( DataUpdateType_t updateType )
{
	CreateFunnel();
}

IMPLEMENT_CLIENTCLASS_EVENT_DT(C_TELargeFunnel, DT_TELargeFunnel, CTELargeFunnel)
	RecvPropInt( RECVINFO(m_nModelIndex)),
	RecvPropInt( RECVINFO(m_nReversed)),
END_RECV_TABLE()

void TE_LargeFunnel( IRecipientFilter& filter, float delay,
	const Vector* pos, int modelindex, int reversed )
{
	// Major hack to simulate receiving network message
	__g_C_TELargeFunnel.m_vecOrigin = *pos;
	__g_C_TELargeFunnel.m_nModelIndex = modelindex;
	__g_C_TELargeFunnel.m_nReversed = reversed;

	__g_C_TELargeFunnel.PostDataUpdate( DATA_UPDATE_CREATED );
}