-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathNextBotAttentionInterface.cpp
More file actions
105 lines (83 loc) · 2.48 KB
/
NextBotAttentionInterface.cpp
File metadata and controls
105 lines (83 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// 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( CBaseEntity *who, const char *reason )
{
if ( !IsAwareOf( who ) )
{
PointOfInterest p;
p.m_type = PointOfInterest::ENTITY;
p.m_entity = who;
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::POSITION;
p.m_position = where;
p.m_duration.Start();
m_attentionSet.AddToTail( p );
}
//------------------------------------------------------------------------------------------
void IAttention::Disregard( CBaseEntity *who, const char *reason )
{
FOR_EACH_VEC( m_attentionSet, it )
{
if ( m_attentionSet[ it ].m_type == PointOfInterest::ENTITY )
{
CBaseEntity *myWho = m_attentionSet[ it ].m_entity;
if ( !myWho || myWho->entindex() == who->entindex() )
{
m_attentionSet.Remove( it );
return;
}
}
}
}
//------------------------------------------------------------------------------------------
/**
* Return true if given actor is in our attending set
*/
bool IAttention::IsAwareOf( CBaseEntity *who ) const
{
FOR_EACH_VEC( m_attentionSet, it )
{
if ( m_attentionSet[ it ].m_type == PointOfInterest::ENTITY )
{
CBaseEntity *myWho = m_attentionSet[ it ].m_entity;
if ( myWho && myWho->entindex() == who->entindex() )
{
return true;
}
}
}
return false;
}