aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/c_tesla.cpp
blob: 691192a143cf2aa3a71b4eb443ef3cb2f129389b (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "cbase.h"
#include "c_tesla.h"
#include "fx.h"
#include <bitbuf.h>

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

IMPLEMENT_CLIENTCLASS_DT( C_Tesla, DT_Tesla, CTesla )
	RecvPropString( RECVINFO( m_SoundName ) ),
	RecvPropString( RECVINFO( m_iszSpriteName ) )
END_RECV_TABLE()


C_Tesla::C_Tesla()
{
}

void C_Tesla::ReceiveMessage( int classID, bf_read &msg )
{
	CTeslaInfo teslaInfo;

	msg.ReadBitVec3Coord( teslaInfo.m_vPos );
	teslaInfo.m_vAngles.Init();

	teslaInfo.m_nEntIndex = msg.ReadShort();
	teslaInfo.m_flRadius = msg.ReadFloat();

	teslaInfo.m_vColor.x = ((unsigned char)msg.ReadChar()) / 255.0f;
	teslaInfo.m_vColor.y = ((unsigned char)msg.ReadChar()) / 255.0f;
	teslaInfo.m_vColor.z = ((unsigned char)msg.ReadChar()) / 255.0f;
	
	float flAlpha = 0;
	flAlpha = ((unsigned char)msg.ReadChar()) / 255.0f;

	teslaInfo.m_nBeams = msg.ReadChar();
	
	teslaInfo.m_flBeamWidth = msg.ReadFloat();
	teslaInfo.m_flTimeVisible = msg.ReadFloat();
	teslaInfo.m_pszSpriteName = m_iszSpriteName;

	EmitSound( m_SoundName );

	m_QueuedCommands.AddToTail( teslaInfo );
	SetNextClientThink( CLIENT_THINK_ALWAYS );
}


void C_Tesla::ClientThink()
{
	FOR_EACH_LL( m_QueuedCommands, i )
	{
		FX_Tesla( m_QueuedCommands[i] );
	}
	m_QueuedCommands.Purge();
	SetNextClientThink( CLIENT_THINK_NEVER );
}