blob: 08b60c497c3985192d50fc148f596e0da4862133 (
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
|
//=============================================================================
// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved.
//
// File: waypointai.h
//
// Description: Blahblahblah
//
// History: 10/07/2002 + Created -- NAME
//
//=============================================================================
#ifndef WAYPOINTAI_H
#define WAYPOINTAI_H
//========================================
// Nested Includes
//========================================
#include <ai/vehicle/vehicleai.h>
//========================================
// Forward References
//========================================
class Locator;
//=============================================================================
//
// Synopsis: Blahblahblah
//
//=============================================================================
class WaypointAI : public VehicleAI
{
public:
static const float DEFAULT_TRIGGER_RADIUS;
WaypointAI(
Vehicle* pVehicle,
bool enableSegmentOptimization=true,
float triggerRadius=DEFAULT_TRIGGER_RADIUS,
bool autoResetOnDestroyed=false );
virtual ~WaypointAI();
void ClearWaypoints();
void AddWaypoint( Locator* loc );
virtual void Update( float timeins );
virtual void Initialize();
virtual void Reset();
int GetCurrentWayPoint() const { return miCurrentWayPoint; };
// get/set collectible from mission objective
void SetCurrentCollectible( int collectible );
int GetCurrentCollectible() const;
// get/set current lap
void SetCurrentLap( int lap );
int GetCurrentLap() const;
// get/set dist to current collectible
float GetDistToCurrentCollectible() const;
void SetDistToCurrentCollectible( float dist );
static const int MAX_WAYPOINTS = 32;
enum WaypointAIType
{
RACE,
EVADE,
TARGET
};
void SetAIType( WaypointAIType type );
void UseTurbo();
protected:
void FollowWaypoints();
void SetCurrentWayPoint( int index );
virtual bool MustRepopulateSegments();
virtual bool TestReachedTarget( const rmt::Vector& start, const rmt::Vector& end );
virtual void GetClosestPathElementToTarget(
rmt::Vector& targetPos,
RoadManager::PathElement& elem,
RoadSegment*& seg,
float& segT,
float& roadT );
virtual void DoCatchUp( float timeins );
void UpdateNeedsResetOnSpot( float timeins );
void UpdateNeedToWaitForPlayer( float timeins );
void PossiblyUseTurbo();
private:
virtual int RegisterHudMapIcon();
bool TestWaypoint( int waypoint );
//Prevent wasteful constructor creation.
WaypointAI( const WaypointAI& waypointai );
WaypointAI& operator=( const WaypointAI& waypointai );
private:
struct WayPoint
{
Locator* loc;
RoadManager::PathElement elem;
float segT;
RoadSegment* seg;
float roadT;
};
WayPoint mpWayPoints[ MAX_WAYPOINTS ];
int miNumWayPoints;
int miCurrentWayPoint;
int miNextWayPoint;
// distance at and closer than which we consider a waypoint reached
// (and move along to next waypoint)
float mTriggerRadius;
///////////////// RACE DATA ///////////////////
// we keep pieces of the race data in this class
// because catch-up logic will need to use them
float mDistToCurrentCollectible;
int miCurrentCollectible;
int miNumLapsCompleted;
bool mCurrWayPointHasMoved : 1;
///////////////// Auto-resetting stuff ///////////
bool mNeedsResetOnSpot : 1;
bool mAutoResetOnDestroyed : 1;
float mSecondsTillResetOnSpot;
WaypointAIType mWaypointAIType;
////////////// Turbo logic stuff ///////////////
float mSecondsSinceTurboUse;
float mSecondsWaitingForPlayer;
};
inline void WaypointAI::SetCurrentCollectible( int collectible )
{
miCurrentCollectible = collectible;
}
inline int WaypointAI::GetCurrentCollectible() const
{
return miCurrentCollectible;
}
inline void WaypointAI::SetCurrentLap( int lap )
{
miNumLapsCompleted = lap;
}
inline int WaypointAI::GetCurrentLap() const
{
return miNumLapsCompleted;
}
inline void WaypointAI::SetDistToCurrentCollectible( float dist )
{
rAssert( dist >= 0.0f );
mDistToCurrentCollectible = dist;
}
inline float WaypointAI::GetDistToCurrentCollectible() const
{
return mDistToCurrentCollectible;
}
inline void WaypointAI::SetAIType( WaypointAIType type )
{
mWaypointAIType = type;
}
#endif //WAYPOINTAI_H
|