summaryrefslogtreecommitdiffstats
path: root/src/Entities/Compoments/AIAgresssiveComponent.cpp
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2014-08-20 16:29:06 +0200
committerSamuel Barney <samjbarney@gmail.com>2014-08-20 16:29:06 +0200
commit72e2182daf9b99a4aca3d7c06e96ff96c0862629 (patch)
treec52aa9ee39db1f1f77489545c395b08db3f5b9b1 /src/Entities/Compoments/AIAgresssiveComponent.cpp
parentRevert "Fixed include paths." (diff)
downloadcuberite-72e2182daf9b99a4aca3d7c06e96ff96c0862629.tar
cuberite-72e2182daf9b99a4aca3d7c06e96ff96c0862629.tar.gz
cuberite-72e2182daf9b99a4aca3d7c06e96ff96c0862629.tar.bz2
cuberite-72e2182daf9b99a4aca3d7c06e96ff96c0862629.tar.lz
cuberite-72e2182daf9b99a4aca3d7c06e96ff96c0862629.tar.xz
cuberite-72e2182daf9b99a4aca3d7c06e96ff96c0862629.tar.zst
cuberite-72e2182daf9b99a4aca3d7c06e96ff96c0862629.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Compoments/AIAgresssiveComponent.cpp95
1 files changed, 2 insertions, 93 deletions
diff --git a/src/Entities/Compoments/AIAgresssiveComponent.cpp b/src/Entities/Compoments/AIAgresssiveComponent.cpp
index 4dcd3e618..ae89ef5b9 100644
--- a/src/Entities/Compoments/AIAgresssiveComponent.cpp
+++ b/src/Entities/Compoments/AIAgresssiveComponent.cpp
@@ -1,34 +1,5 @@
#include "AIAgressiveComponent.h"
-
-
-void cAIAggressiveComponent::Tick(float a_Dt, cChunk & a_Chunk)
-{
- super::Tick(a_Dt, a_Chunk);
-
- if (m_EMState == CHASING)
- {
- CheckEventLostPlayer();
- }
- else
- {
- CheckEventSeePlayer();
- }
-
- if (m_Target == NULL)
- return;
-
- cTracer LineOfSight(GetWorld());
- Vector3d AttackDirection(m_Target->GetPosition() - GetPosition());
-
- if (ReachedFinalDestination() && !LineOfSight.Trace(GetPosition(), AttackDirection, (int)AttackDirection.Length()))
- {
- // Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
- Attack(a_Dt / 1000);
- }
-}
-
-
void cAIAggressiveComponent::Attack(float a_Dt)
{
float attack_interval = m_Self->GetAttackInterval();
@@ -38,13 +9,12 @@ void cAIAggressiveComponent::Attack(float a_Dt)
{
// Setting this higher gives us more wiggle room for attackrate
attack_interval = 0.0f;
- m_Target->TakeDamage(dtMobAttack, m_Self, m_AttackDamage, 0);
+ m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
}
m_Self->SetAttackInterval(attack_interval)
}
-
bool cAIAggressiveComponent::IsMovingToTargetPosition()
{
// Difference between destination x and target x is negligible (to 10^-12 precision)
@@ -58,65 +28,4 @@ bool cAIAggressiveComponent::IsMovingToTargetPosition()
return false;
}
return true;
-}
-
-
-/// Event Checkers
-void cAIAggressiveComponent::CheckEventLostPlayer(void)
-{
- if (m_Target != NULL)
- {
- if ((m_Target->GetPosition() - GetPosition()).Length() > m_Self->GetSightDistance())
- {
- EventLosePlayer();
- }
- }
- else
- {
- EventLosePlayer();
- }
-}
-
-
-/// Event Handlers
-void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity)
-{
- if (!((cPlayer *)a_Entity)->IsGameModeCreative())
- {
- m_Target = a_Entity;
- m_EMState = CHASING;
- }
-}
-
-
-void cAIAggressiveComponent::EventLosePlayer(void)
-{
- m_Target = NULL;
- m_EMState = IDLE;
-}
-
-
-/// State Logic
-void cAggressiveMonster::InStateChasing(float a_Dt)
-{
- super::InStateChasing(a_Dt);
-
- if (m_Target != NULL)
- {
- if (m_Target->IsPlayer())
- {
- if (((cPlayer *)m_Target)->IsGameModeCreative())
- {
- m_EMState = IDLE;
- return;
- }
- }
-
- if (!IsMovingToTargetPosition())
- {
- m_Self->MoveToPosition(m_Target->GetPosition());
- }
- }
-}
-
-
+} \ No newline at end of file