blob: 9c481f0e2bf0b0796a8ff14550f1562cafc5823a (
plain) (
blame)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef AI_ROUTE_H
#define AI_ROUTE_H
#ifdef _WIN32
#pragma once
#endif
#include "ai_basenpc.h"
#include "mathlib/vector.h"
#include "ai_network.h"
#include "ai_node.h"
#include "ai_waypoint.h"
struct AI_Waypoint_t;
struct OverlayLine_t;
class CAI_BaseNPC;
//=============================================================================
// >> CAI_Path
//=============================================================================
#define DEF_WAYPOINT_TOLERANCE (0.1)
class CAI_Path
{
//-----------------------------------------------------------------
public:
void SetWaypoints(AI_Waypoint_t* route, bool fSetGoalFromLast = false) ;
void PrependWaypoints( AI_Waypoint_t *pWaypoints );
void PrependWaypoint( const Vector &newPoint, Navigation_t navType, unsigned waypointFlags );
bool IsEmpty() const { return m_Waypoints.IsEmpty(); }
AI_Waypoint_t * GetCurWaypoint() { return m_Waypoints.GetFirst(); }
const AI_Waypoint_t *GetCurWaypoint() const { return m_Waypoints.GetFirst(); }
AI_Waypoint_t * GetGoalWaypoint() { return m_Waypoints.GetLast(); }
const AI_Waypoint_t *GetGoalWaypoint() const { return m_Waypoints.GetLast(); }
const Vector & CurWaypointPos() const;
const Vector & NextWaypointPos() const;
float CurWaypointYaw() const;
int CurWaypointFlags() const;
Navigation_t CurWaypointNavType() const;
AI_Waypoint_t * GetTransitionWaypoint();
//---------------------------------
float GetPathLength();
float GetPathDistanceToGoal( const Vector &);
float GetStartTime() const { return m_routeStartTime; }
//---------------------------------
// How close do we need to get to the goal
//---------------------------------
void SetGoalTolerance(float tolerance) { m_goalTolerance = tolerance; }
float GetGoalTolerance() const { return m_goalTolerance; }
void SetWaypointTolerance(float tolerance) { m_waypointTolerance = tolerance; }
float GetWaypointTolerance() const { return m_waypointTolerance; }
//---------------------------------
// The activity to use during motion
//---------------------------------
Activity GetMovementActivity() const { return m_activity; }
Activity SetMovementActivity(Activity activity);
int GetMovementSequence() const { return m_sequence; }
int SetMovementSequence(int sequence) { return (m_sequence = sequence); }
Activity GetArrivalActivity( ) const;
void SetArrivalActivity(Activity activity);
int GetArrivalSequence( ) const;
void SetArrivalSequence(int sequence);
void SetGoalDirection( const Vector &goalDirection );
void SetGoalDirection( CBaseEntity *pTarget );
Vector GetGoalDirection( const Vector &startPos );
void SetGoalSpeed( float flSpeed );
void SetGoalSpeed( CBaseEntity *pTarget );
float GetGoalSpeed( const Vector &startPos );
void SetGoalStoppingDistance( float flDistance );
float GetGoalStoppingDistance( ) const;
//---------------------------------
// Target of this path
//---------------------------------
void SetTarget(CBaseEntity * pTarget ) { m_target = pTarget; }
void ClearTarget() { m_target = NULL; m_vecTargetOffset = vec3_origin; }
void SetTargetOffset( const Vector &vecOffset) { m_vecTargetOffset = vecOffset; }
CBaseEntity * GetTarget() { return m_target; }
void SetGoalType(GoalType_t goalType); // Set the goal type
void SetGoalPosition(const Vector &goalPos); // Set the goal position
void SetLastNodeAsGoal(bool bReset = false); // Sets last node as goal and goal position
void ResetGoalPosition(const Vector &goalPos); // Reset the goal position
// Returns the *base* goal position (without the offset applied)
const Vector& BaseGoalPosition() const;
// Returns the *actual* goal position (with the offset applied)
const Vector & ActualGoalPosition(void) const; // Get the goal position
GoalType_t GoalType(void) const; // Get the goal type
void SetGoalFlags( unsigned flags ) { m_goalFlags = flags; }
unsigned GoalFlags( void ) const; // Get the goal flags
void Advance( void ); // Advance to next waypoint if possible
bool CurWaypointIsGoal(void) const;
void Clear(void);
CAI_Path();
~CAI_Path();
//---------------------------------
int GetLastNodeReached() { return m_iLastNodeReached; }
void ClearWaypoints()
{
m_Waypoints.RemoveAll();
m_iLastNodeReached = NO_NODE;
}
private:
// Computes the goal distance for each waypoint along the route
static void ComputeRouteGoalDistances(AI_Waypoint_t *pGoalWaypoint);
//---------------------------------
CAI_WaypointList m_Waypoints;
//---------------------------------
float m_goalTolerance; // How close do we need to get to the goal
Activity m_activity; // The activity to use during motion
int m_sequence; // The sequence to use during motion
EHANDLE m_target; // Target of this path
Vector m_vecTargetOffset; // offset from the target in world space
float m_waypointTolerance;
//---------------------------------
Activity m_arrivalActivity;
int m_arrivalSequence;
//---------------------------------
int m_iLastNodeReached; // What was the last node that I reached
bool m_bGoalPosSet; // Was goal position set (used to check for errors)
Vector m_goalPos; // Our ultimate goal position
bool m_bGoalTypeSet; // Was goal position set (used to check for errors)
GoalType_t m_goalType; // Type of goal
unsigned m_goalFlags; // Goal flags
//---------------------------------
float m_routeStartTime;
//---------------------------------
Vector m_goalDirection;
EHANDLE m_goalDirectionTarget;
float m_goalSpeed;
EHANDLE m_goalSpeedTarget;
float m_goalStoppingDistance; // Distance we want to stop before the goal
//---------------------------------
static AI_Waypoint_t gm_InvalidWaypoint;
DECLARE_SIMPLE_DATADESC();
};
#endif // AI_ROUTE_H
|