summaryrefslogtreecommitdiff
path: root/game/client/tf2/proxy_sunroof.cpp
blob: 894bfbc0779b1c7bf70c102264eca14f952ce868 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "cbase.h"
#include "materialsystem/imaterial.h"
#include "materialsystem/imaterialsystem.h"
#include <KeyValues.h>
#include "materialsystem/imaterialvar.h"
#include "C_BaseTFPlayer.h"
#include "functionproxy.h"
#include "C_PlayerResource.h"
#include "Weapon_CombatShield.h"

// for the 2/5/03 demo
#include "c_demo_entities.h"
#include "c_basefourwheelvehicle.h"

//=============================================================================
//
// TF Shield raising proxy. 
//
class CTFSunroofProxy : public CResultProxy
{
public:

	virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
	virtual void OnBind( void *pEnt );

private:

	CFloatInput	m_Factor;
};

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

bool CTFSunroofProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
{
	if ( !CResultProxy::Init( pMaterial, pKeyValues ) )
		return false;

	// Init shield raise times.
	//if ( !m_Factor.Init( pMaterial, pKeyValues, "scale", 1 ) )
	//	return false;

	return true;
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CTFSunroofProxy::OnBind( void *pArg )
{
	C_BaseEntity *pEntity = BindArgToEntity( pArg );
	C_BaseTFFourWheelVehicle* pVehicle = dynamic_cast<C_BaseTFFourWheelVehicle*>(pEntity);
	if( !pVehicle )
		return;

	if( pVehicle->GetPassengerCount() )
	{
		SetFloatResult(0.f);
	} 
	else
	{
		SetFloatResult(1.f);
	}
}

EXPOSE_INTERFACE( CTFSunroofProxy, IMaterialProxy, "TFSunroof" IMATERIAL_PROXY_INTERFACE_VERSION );