summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_item.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/tf/tf_item.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/shared/tf/tf_item.cpp')
-rw-r--r--game/shared/tf/tf_item.cpp110
1 files changed, 110 insertions, 0 deletions
diff --git a/game/shared/tf/tf_item.cpp b/game/shared/tf/tf_item.cpp
new file mode 100644
index 0000000..7471b6b
--- /dev/null
+++ b/game/shared/tf/tf_item.cpp
@@ -0,0 +1,110 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//
+//=============================================================================//
+#include "cbase.h"
+#include "tf_item.h"
+#include "tf_shareddefs.h"
+
+#ifdef CLIENT_DLL
+#include "c_tf_player.h"
+
+// NVNT haptics system interface
+#include "haptics/ihaptics.h"
+#else
+#include "tf_player.h"
+#endif
+
+IMPLEMENT_NETWORKCLASS_ALIASED( TFItem, DT_TFItem )
+
+BEGIN_NETWORK_TABLE( CTFItem, DT_TFItem )
+END_NETWORK_TABLE()
+
+//-----------------------------------------------------------------------------
+// Purpose: Identifier.
+//-----------------------------------------------------------------------------
+unsigned int CTFItem::GetItemID( void ) const
+{
+ return TF_ITEM_UNDEFINED;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CTFItem::PickUp( CTFPlayer *pPlayer, bool bInvisible )
+{
+ // SetParent with attachment point - look it up later if need be!
+ SetOwnerEntity( pPlayer );
+ SetParent( pPlayer );
+ SetLocalOrigin( vec3_origin );
+ SetLocalAngles( vec3_angle );
+
+ // Make invisible?
+ if ( bInvisible )
+ {
+ AddEffects( EF_NODRAW );
+ }
+
+ // Add the item to the player's item inventory.
+ pPlayer->SetItem( this );
+ // NVNT if this is the client dll and the owner is the local
+ // player notify the haptics system.
+#ifdef CLIENT_DLL
+ if(pPlayer->IsLocalPlayer())
+ haptics->ProcessHapticEvent(2,"Game","ctf_item_start");
+#endif
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CTFItem::Drop( CTFPlayer *pPlayer, bool bVisible, bool bThrown /*= false*/, bool bMessage /*= true*/ )
+{
+ // Remove the item from the player's item inventory.
+ pPlayer->SetItem( NULL );
+
+ // Make visible?
+ if ( bVisible )
+ {
+ RemoveEffects( EF_NODRAW );
+ }
+ // NVNT if this is the client dll and the owner is the local
+ // player notify the haptics system we are dropping this item.
+#ifdef CLIENT_DLL
+ if(pPlayer->IsLocalPlayer())
+ haptics->ProcessHapticEvent(2,"Game","ctf_item_stop");
+#endif
+
+ // Clear the parent.
+ SetParent( NULL );
+ SetOwnerEntity( NULL );
+}
+
+#ifdef CLIENT_DLL
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+bool CTFItem::ShouldDraw()
+{
+ // If I'm carrying the flag in 1st person, don't draw it
+ if ( ToTFPlayer(GetMoveParent())->InFirstPersonView() )
+ return false;
+
+ return BaseClass::ShouldDraw();
+}
+
+//-----------------------------------------------------------------------------
+// Should this object cast shadows?
+//-----------------------------------------------------------------------------
+ShadowType_t CTFItem::ShadowCastType()
+{
+ if ( ToTFPlayer(GetMoveParent())->ShouldDrawThisPlayer() )
+ {
+ // Using the viewmodel.
+ return SHADOWS_NONE;
+ }
+
+ return BaseClass::ShadowCastType();
+}
+
+#endif