diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf2/proxy_objpower.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/tf2/proxy_objpower.cpp')
| -rw-r--r-- | game/client/tf2/proxy_objpower.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/game/client/tf2/proxy_objpower.cpp b/game/client/tf2/proxy_objpower.cpp new file mode 100644 index 0000000..e9f36a9 --- /dev/null +++ b/game/client/tf2/proxy_objpower.cpp @@ -0,0 +1,56 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Proxy to hook into an object's powered state +// +//=============================================================================// + +#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_baseobject.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +class CTFObjectPowerProxy : public CResultProxy +{ +public: + virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues ); + virtual void OnBind( void *pEnt ); +}; + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CTFObjectPowerProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues ) +{ + if ( !CResultProxy::Init( pMaterial, pKeyValues ) ) + return false; + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CTFObjectPowerProxy::OnBind( void *pArg ) +{ + C_BaseEntity *pEntity = BindArgToEntity( pArg ); + if (!pEntity) + return; + + C_BaseObject *pObject = dynamic_cast<C_BaseObject*>( pEntity ); + Assert( pObject ); + + float flPoweredState = (float)(!pObject->IsBuilding() && !pObject->IsPlacing() && pObject->IsPowered()); + + Assert( m_pResult ); + SetFloatResult( flPoweredState ); +} + + +EXPOSE_INTERFACE( CTFObjectPowerProxy, IMaterialProxy, "TFObjectPower" IMATERIAL_PROXY_INTERFACE_VERSION ); |