aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/playerenumerator.h
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/client/playerenumerator.h
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/client/playerenumerator.h')
-rw-r--r--mp/src/game/client/playerenumerator.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/mp/src/game/client/playerenumerator.h b/mp/src/game/client/playerenumerator.h
new file mode 100644
index 00000000..172e9adf
--- /dev/null
+++ b/mp/src/game/client/playerenumerator.h
@@ -0,0 +1,71 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef PLAYERENUMERATOR_H
+#define PLAYERENUMERATOR_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "utlvector.h"
+#include "ehandle.h"
+#include "ispatialpartition.h"
+
+class C_BaseEntity;
+
+class CPlayerEnumerator : public IPartitionEnumerator
+{
+ DECLARE_CLASS_NOBASE( CPlayerEnumerator );
+public:
+ //Forced constructor
+ CPlayerEnumerator( float radius, Vector vecOrigin )
+ {
+ m_flRadiusSquared = radius * radius;
+ m_vecOrigin = vecOrigin;
+ m_Objects.RemoveAll();
+ }
+
+ int GetObjectCount() { return m_Objects.Size(); }
+
+ C_BaseEntity *GetObject( int index )
+ {
+ if ( index < 0 || index >= GetObjectCount() )
+ return NULL;
+
+ return m_Objects[ index ];
+ }
+
+ //Actual work code
+ virtual IterationRetval_t EnumElement( IHandleEntity *pHandleEntity )
+ {
+ C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( pHandleEntity->GetRefEHandle() );
+ if ( pEnt == NULL )
+ return ITERATION_CONTINUE;
+
+ if ( !pEnt->IsPlayer() )
+ return ITERATION_CONTINUE;
+
+ Vector deltaPos = pEnt->GetAbsOrigin() - m_vecOrigin;
+ if ( deltaPos.LengthSqr() > m_flRadiusSquared )
+ return ITERATION_CONTINUE;
+
+ CHandle< C_BaseEntity > h;
+ h = pEnt;
+ m_Objects.AddToTail( h );
+
+ return ITERATION_CONTINUE;
+ }
+
+public:
+ //Data members
+ float m_flRadiusSquared;
+ Vector m_vecOrigin;
+
+ CUtlVector< CHandle< C_BaseEntity > > m_Objects;
+};
+
+#endif // PLAYERENUMERATOR_H \ No newline at end of file