blob: c4cf15d14c54cce9e90a5e0bcf145f3bed29089a (
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
|
#pragma once
class cMonster;
class cEntity;
class cChunk;
class cAIComponent
{
protected:
cMonster * m_Self;
cEntity * m_Target;
float m_IdleInterval;
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
/** Coordinates of the next position that should be reached */
Vector3d m_Destination;
/** Coordinates for the ultimate, final destination. */
Vector3d m_FinalDestination;
/** A semi-temporary list to store the traversed coordinates during active pathfinding so we don't visit them again */
std::vector<Vector3i> m_TraversedCoordinates;
/** Stores if mobile is currently moving towards the ultimate, final destination */
bool m_bMovingToDestination;
/**********
* Pathfinding
**********/
inline void FinishPathFinding(void)
{
m_TraversedCoordinates.clear();
m_bMovingToDestination = false;
}
/** Finds the next place to go
This is based on the ultimate, final destination and the current position, as well as the traversed coordinates, and any environmental hazards */
void TickPathFinding(void);
inline bool IsCoordinateInTraversedList(Vector3i a_Coords)
{
return (std::find(m_TraversedCoordinates.begin(), m_TraversedCoordinates.end(), a_Coords) != m_TraversedCoordinates.end());
}
bool IsMovingToTargetPosition();
bool ReachedFinalDestination();
virtual bool ReachedDestination(void);
virtual void MoveToPosition(const Vector3d & a_Position);
void SetPitchAndYawFromDestination();
/**********
* Event Management
**********/
// void EventLosePlayer(void);
// virtual void EventSeePlayer(cEntity * a_Entity);
virtual void InStateIdle (float a_Dt);
virtual void InStateChasing (float a_Dt);
virtual void InStateEscaping(float a_Dt);
public:
cAIComponent(cMonster * a_Entity);
virtual ~cAIComponent(){}
virtual void Tick(float a_Dt, cChunk & a_Chunk);
};
|