summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2014-08-26 01:24:41 +0200
committerSamuel Barney <samjbarney@gmail.com>2014-08-26 01:24:41 +0200
commit46016b6fa5aad90e8c009ab6839c02fc96cae81c (patch)
tree089aeff487de7c288c3567fa55b1cd8b574eb3c3
parentAdded some missing code (diff)
downloadcuberite-46016b6fa5aad90e8c009ab6839c02fc96cae81c.tar
cuberite-46016b6fa5aad90e8c009ab6839c02fc96cae81c.tar.gz
cuberite-46016b6fa5aad90e8c009ab6839c02fc96cae81c.tar.bz2
cuberite-46016b6fa5aad90e8c009ab6839c02fc96cae81c.tar.lz
cuberite-46016b6fa5aad90e8c009ab6839c02fc96cae81c.tar.xz
cuberite-46016b6fa5aad90e8c009ab6839c02fc96cae81c.tar.zst
cuberite-46016b6fa5aad90e8c009ab6839c02fc96cae81c.zip
-rw-r--r--src/Mobs/Components/AIAggressiveComponent.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Mobs/Components/AIAggressiveComponent.h b/src/Mobs/Components/AIAggressiveComponent.h
index d6a76e3d9..373861ffd 100644
--- a/src/Mobs/Components/AIAggressiveComponent.h
+++ b/src/Mobs/Components/AIAggressiveComponent.h
@@ -1,15 +1,51 @@
#pragma once
#include "AIComponent.h"
+class cEntity;
+
class cAIAggressiveComponent : public cAIComponent {
typedef cAIComponent super;
+ void EventSeePlayer(cEntity * a_Entity);
+ void EventLosePlayer(void);
protected:
+ void InStateChasing(float a_Dt);
+
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
+ enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality;
+
cEntity * m_Target;
+ /** 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;
+
+ 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();
+ void CheckEventSeePlayer(void);
+ void CheckEventLostPlayer(void);
public:
cAIAggressiveComponent(cMonster * a_Monster);
virtual void Tick(float a_Dt, cChunk & a_Chunk) /*override*/;
virtual void Attack(float a_Dt);
+ void MoveToPosition(const Vector3d & a_Position);
};