summaryrefslogtreecommitdiff
path: root/game/client/tf2/c_weapon_twohandedcontainer.cpp
blob: 8ff85c59ce8752857ac429c13c303cd3b69ba778 (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
164
165
166
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Client's Support "weapon"
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "weapon_twohandedcontainer.h"

//-----------------------------------------------------------------------------
// Purpose: Draws little viewmodel attachments
//-----------------------------------------------------------------------------
void C_WeaponTwoHandedContainer::ViewModelDrawn( C_BaseViewModel *pBaseViewModel )
{
	BaseClass::ViewModelDrawn( pBaseViewModel );

	if (pBaseViewModel->ViewModelIndex() != 0)
	{
		if ( m_hRightWeapon )
		{
			m_hRightWeapon->ViewModelDrawn(pBaseViewModel);
		}
	}
	else
	{
		if ( m_hLeftWeapon )
		{
			m_hLeftWeapon->ViewModelDrawn(pBaseViewModel);
		}
	}
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool C_WeaponTwoHandedContainer::OnFireEvent( C_BaseViewModel *pViewModel, const Vector& origin, 
											  const QAngle& angles, int event, const char *options )
{
	bool bRight = m_hRightWeapon->OnFireEvent( pViewModel, origin, angles, event, options );
	bool bLeft = m_hLeftWeapon->OnFireEvent( pViewModel, origin, angles, event, options );

	return ( bRight || bLeft );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_WeaponTwoHandedContainer::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged( updateType );

	// Did we just receive a new weapon?
	bool rightchanged = m_hOldRightWeapon.Get() != m_hRightWeapon.Get() ? true : false;
	bool leftchanged = m_hOldLeftWeapon.Get() != m_hLeftWeapon.Get() ? true : false;

	if ( rightchanged || leftchanged )
	{
		/*
		// Tell weapons that they're being holstered
		if ( m_hRightWeapon != NULL && rightchanged )
		{
			m_hRightWeapon->Holster( NULL );
		}
		if ( m_hLeftWeapon != NULL && leftchanged )
		{
			m_hLeftWeapon->Holster( NULL );
		}
		*/

		HookWeaponEntities();
	}
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_WeaponTwoHandedContainer::HookWeaponEntities( void )
{
	m_hOldRightWeapon	= m_hRightWeapon;
	m_hOldLeftWeapon	= m_hLeftWeapon;
}

//-----------------------------------------------------------------------------
// Purpose: Never draw the container
//-----------------------------------------------------------------------------
bool C_WeaponTwoHandedContainer::ShouldDraw( void )
{
	return false;
}

//-----------------------------------------------------------------------------
// Purpose: This weapon is the active weapon, and it should now draw anything
//			it wants to. This gets called every frame.
//-----------------------------------------------------------------------------
void C_WeaponTwoHandedContainer::Redraw()
{
	BaseClass::Redraw();

	if ( m_hRightWeapon.Get() )
	{
		m_hRightWeapon->Redraw();
	}
	if ( m_hLeftWeapon.Get() )
	{
		m_hLeftWeapon->Redraw();
	}
}

//-----------------------------------------------------------------------------
// Purpose: Draw both weapon's ammo's
//-----------------------------------------------------------------------------
void C_WeaponTwoHandedContainer::DrawAmmo()
{
	// Just tell our active weapon to draw it's ammo, since our offhand doesn't use it
	if ( m_hLeftWeapon )
	{
		m_hLeftWeapon->DrawAmmo();
	}
	if ( m_hRightWeapon.Get() )
	{
		m_hRightWeapon->DrawAmmo();
	}
}

//-----------------------------------------------------------------------------
// Purpose: Let each weapon handle input
//-----------------------------------------------------------------------------
void C_WeaponTwoHandedContainer::HandleInput( void )
{
	BaseClass::HandleInput();

	if ( m_hRightWeapon )
	{
		m_hRightWeapon->HandleInput();
	}
	if ( m_hLeftWeapon )
	{
		m_hLeftWeapon->HandleInput();
	}
}

//-----------------------------------------------------------------------------
// Purpose: Let each weapon handle input
//-----------------------------------------------------------------------------
void C_WeaponTwoHandedContainer::OverrideMouseInput( float *x, float *y )
{
	BaseClass::OverrideMouseInput( x,y );

	if ( m_hRightWeapon )
	{
		m_hRightWeapon->OverrideMouseInput( x,y );
	}
	if ( m_hLeftWeapon )
	{
		m_hLeftWeapon->OverrideMouseInput( x,y );
	}
}

//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool C_WeaponTwoHandedContainer::VisibleInWeaponSelection( void )
{
	return false;
}