summaryrefslogtreecommitdiff
path: root/game/server/tf2/info_add_resources.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/server/tf2/info_add_resources.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/server/tf2/info_add_resources.cpp')
-rw-r--r--game/server/tf2/info_add_resources.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/game/server/tf2/info_add_resources.cpp b/game/server/tf2/info_add_resources.cpp
new file mode 100644
index 0000000..1260bb8
--- /dev/null
+++ b/game/server/tf2/info_add_resources.cpp
@@ -0,0 +1,72 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+#include "cbase.h"
+#include "EntityOutput.h"
+#include "EntityList.h"
+#include "tf_team.h"
+#include "baseentity.h"
+#include "tf_stats.h"
+
+//-----------------------------------------------------------------------------
+// Purpose: Map entity that gives resources to players passed into it
+//-----------------------------------------------------------------------------
+class CInfoAddResources : public CBaseEntity
+{
+ DECLARE_CLASS( CInfoAddResources, CBaseEntity );
+public:
+ DECLARE_DATADESC();
+
+ void Spawn( void );
+
+ // Inputs
+ void InputPlayer( inputdata_t &inputdata );
+
+public:
+ // Outputs
+ COutputEvent m_OnAdded;
+
+ // Data
+ int m_iResourceAmount;
+};
+
+BEGIN_DATADESC( CInfoAddResources )
+
+ // inputs
+ DEFINE_INPUTFUNC( FIELD_EHANDLE, "Player", InputPlayer ),
+
+ // outputs
+ DEFINE_OUTPUT( m_OnAdded, "OnAdded" ),
+
+ // keys
+ DEFINE_KEYFIELD_NOT_SAVED( m_iResourceAmount, FIELD_INTEGER, "ResourceAmount" ),
+
+END_DATADESC()
+
+LINK_ENTITY_TO_CLASS( info_add_resources, CInfoAddResources );
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CInfoAddResources::Spawn( void )
+{
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CInfoAddResources::InputPlayer( inputdata_t &inputdata )
+{
+ CBaseEntity *pEntity = (inputdata.value.Entity()).Get();
+ if ( pEntity && pEntity->IsPlayer() )
+ {
+ CBaseTFPlayer *pPlayer = (CBaseTFPlayer *)pEntity;
+ pPlayer->AddBankResources( m_iResourceAmount );
+ TFStats()->IncrementPlayerStat( pPlayer, TF_PLAYER_STAT_RESOURCES_ACQUIRED, m_iResourceAmount );
+ }
+
+ m_OnAdded.FireOutput( inputdata.pActivator, this );
+}