aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/hl2/c_env_headcrabcanister.cpp
blob: fe92ed2f56aeac662b71ec656f6f83ce8aeced37 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "fx_explosion.h"
#include "tempentity.h"
#include "c_tracer.h"
#include "env_headcrabcanister_shared.h"
#include "baseparticleentity.h"

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

//-----------------------------------------------------------------------------
// Headcrab canister Class (Client-side only!)
//-----------------------------------------------------------------------------
class C_EnvHeadcrabCanister :  public C_BaseAnimating
{
	DECLARE_CLASS( C_EnvHeadcrabCanister, C_BaseAnimating );
	DECLARE_CLIENTCLASS();

public:
	//-------------------------------------------------------------------------
	// Initialization/Destruction
	//-------------------------------------------------------------------------
	C_EnvHeadcrabCanister();
	~C_EnvHeadcrabCanister();

	virtual void OnDataChanged( DataUpdateType_t updateType );
	virtual void ClientThink();

private:
	C_EnvHeadcrabCanister( const C_EnvHeadcrabCanister & );

	CEnvHeadcrabCanisterShared	m_Shared;
	CNetworkVar( bool, m_bLanded );
};


EXTERN_RECV_TABLE(DT_EnvHeadcrabCanisterShared);

IMPLEMENT_CLIENTCLASS_DT( C_EnvHeadcrabCanister, DT_EnvHeadcrabCanister, CEnvHeadcrabCanister )
	RecvPropDataTable( RECVINFO_DT( m_Shared ), 0, &REFERENCE_RECV_TABLE(DT_EnvHeadcrabCanisterShared) ),
	RecvPropBool( RECVINFO( m_bLanded ) ),
END_RECV_TABLE()


//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
C_EnvHeadcrabCanister::C_EnvHeadcrabCanister()
{
}


//-----------------------------------------------------------------------------
// Destructor
//-----------------------------------------------------------------------------
C_EnvHeadcrabCanister::~C_EnvHeadcrabCanister()
{
}


//-----------------------------------------------------------------------------
// On data update
//-----------------------------------------------------------------------------
void C_EnvHeadcrabCanister::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged( updateType );
	if ( updateType == DATA_UPDATE_CREATED )
	{
		SetNextClientThink( CLIENT_THINK_ALWAYS );
	}

	// Stop client-side simulation on landing
	if ( m_bLanded )
	{
		SetNextClientThink( CLIENT_THINK_NEVER );
	}
}


//-----------------------------------------------------------------------------
// Compute position
//-----------------------------------------------------------------------------
void C_EnvHeadcrabCanister::ClientThink()
{
	Vector vecEndPosition;
	QAngle vecEndAngles;
	m_Shared.GetPositionAtTime( gpGlobals->curtime, vecEndPosition, vecEndAngles );
	SetAbsOrigin( vecEndPosition );
	SetAbsAngles( vecEndAngles );
}