summaryrefslogtreecommitdiff
path: root/game/server/NextBot/NextBotAttentionInterface.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/NextBot/NextBotAttentionInterface.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/server/NextBot/NextBotAttentionInterface.cpp')
-rw-r--r--game/server/NextBot/NextBotAttentionInterface.cpp162
1 files changed, 162 insertions, 0 deletions
diff --git a/game/server/NextBot/NextBotAttentionInterface.cpp b/game/server/NextBot/NextBotAttentionInterface.cpp
new file mode 100644
index 0000000..a774551
--- /dev/null
+++ b/game/server/NextBot/NextBotAttentionInterface.cpp
@@ -0,0 +1,162 @@
+// NextBotAttentionInterface.cpp
+// Manage what this bot pays attention to
+// Author: Michael Booth, April 2007
+//========= Copyright Valve Corporation, All rights reserved. ============//
+
+#include "cbase.h"
+
+#include "NextBot.h"
+#include "NextBotAttentionInterface.h"
+#include "NextBotBodyInterface.h"
+
+#include "tier0/vprof.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+
+//------------------------------------------------------------------------------------------
+/**
+ * Reset to initial state
+ */
+void IAttention::Reset( void )
+{
+ m_body = GetBot()->GetBodyInterface();
+
+ m_attentionSet.RemoveAll();
+}
+
+
+//------------------------------------------------------------------------------------------
+/**
+ * Update internal state
+ */
+void IAttention::Update( void )
+{
+}
+
+
+//------------------------------------------------------------------------------------------
+void IAttention::AttendTo( const CBaseCombatCharacter *who, const char *reason )
+{
+ if ( !IsAwareOf( who ) )
+ {
+ PointOfInterest p;
+ p.m_type = PointOfInterest::WHO;
+ p.m_who = who;
+ p.m_duration.Start();
+
+ m_attentionSet.AddToTail( p );
+ }
+}
+
+
+//------------------------------------------------------------------------------------------
+void IAttention::AttendTo( const CBaseEntity *what, const char *reason )
+{
+ if ( !IsAwareOf( what ) )
+ {
+ PointOfInterest p;
+ p.m_type = PointOfInterest::WHAT;
+ p.m_what = what;
+ p.m_duration.Start();
+
+ m_attentionSet.AddToTail( p );
+ }
+}
+
+
+//------------------------------------------------------------------------------------------
+void IAttention::AttendTo( const Vector &where, IAttention::SignificanceLevel significance, const char *reason )
+{
+ PointOfInterest p;
+ p.m_type = PointOfInterest::WHERE;
+ p.m_where = where;
+ p.m_duration.Start();
+
+ m_attentionSet.AddToTail( p );
+}
+
+
+//------------------------------------------------------------------------------------------
+void IAttention::Disregard( const CBaseCombatCharacter *who, const char *reason )
+{
+ FOR_EACH_VEC( m_attentionSet, it )
+ {
+ if ( m_attentionSet[ it ].m_type == PointOfInterest::WHO )
+ {
+ CBaseCombatCharacter *myWho = m_attentionSet[ it ].m_who;
+
+ if ( !myWho || myWho->entindex() == who->entindex() )
+ {
+ m_attentionSet.Remove( it );
+ return;
+ }
+ }
+ }
+}
+
+
+//------------------------------------------------------------------------------------------
+void IAttention::Disregard( const CBaseEntity *what, const char *reason )
+{
+ FOR_EACH_VEC( m_attentionSet, it )
+ {
+ if ( m_attentionSet[ it ].m_type == PointOfInterest::WHAT )
+ {
+ CBaseCombatCharacter *myWhat = m_attentionSet[ it ].m_what;
+
+ if ( !myWhat || myWhat->entindex() == what->entindex() )
+ {
+ m_attentionSet.Remove( it );
+ return;
+ }
+ }
+ }
+}
+
+
+//------------------------------------------------------------------------------------------
+/**
+ * Return true if given actor is in our attending set
+ */
+bool IAttention::IsAwareOf( const CBaseCombatCharacter *who ) const
+{
+ FOR_EACH_VEC( m_attentionSet, it )
+ {
+ if ( m_attentionSet[ it ].m_type == PointOfInterest::WHO )
+ {
+ CBaseCombatCharacter *myWho = m_attentionSet[ it ].m_who;
+
+ if ( myWho && myWho->entindex() == who->entindex() )
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+
+//------------------------------------------------------------------------------------------
+/**
+ * Return true if given object is in our attending set
+ */
+bool IAttention::IsAwareOf( const CBaseEntity *what ) const
+{
+ FOR_EACH_VEC( m_attentionSet, it )
+ {
+ if ( m_attentionSet[ it ].m_type == PointOfInterest::WHAT )
+ {
+ CBaseEntity *myWhat = m_attentionSet[ it ].m_what;
+
+ if ( myWhat && myWhat->entindex() == what->entindex() )
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+} \ No newline at end of file