summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Components/AIComponent.cpp
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2014-08-26 21:12:38 +0200
committerSamuel Barney <samjbarney@gmail.com>2014-08-26 21:12:38 +0200
commitba94c1c41cb1824bf39270fb24dd1dac2d405900 (patch)
tree866a45ce68e03581ccc45f9bf0b0474f25542b6c /src/Mobs/Components/AIComponent.cpp
parentAdded AIPassiveAgressive component. (diff)
downloadcuberite-ba94c1c41cb1824bf39270fb24dd1dac2d405900.tar
cuberite-ba94c1c41cb1824bf39270fb24dd1dac2d405900.tar.gz
cuberite-ba94c1c41cb1824bf39270fb24dd1dac2d405900.tar.bz2
cuberite-ba94c1c41cb1824bf39270fb24dd1dac2d405900.tar.lz
cuberite-ba94c1c41cb1824bf39270fb24dd1dac2d405900.tar.xz
cuberite-ba94c1c41cb1824bf39270fb24dd1dac2d405900.tar.zst
cuberite-ba94c1c41cb1824bf39270fb24dd1dac2d405900.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Components/AIComponent.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Mobs/Components/AIComponent.cpp b/src/Mobs/Components/AIComponent.cpp
index 1c33dcaca..12a89c201 100644
--- a/src/Mobs/Components/AIComponent.cpp
+++ b/src/Mobs/Components/AIComponent.cpp
@@ -21,9 +21,9 @@ void cAIComponent::Tick(float a_Dt, cChunk & a_Chunk)
if (m_bMovingToDestination)
{
- if (m_Self->GetEnvironmentComponent().GetOnGround() && m_Self->GetMovementComponent().DoesPosYRequireJump((int)floor(m_Destination.y)))
+ if (m_Self->GetEnvironmentComponent()->GetOnGround() && m_Self->GetMovementComponent()->DoesPosYRequireJump((int)floor(m_Destination.y)))
{
- m_Self->GetEnvironmentComponent().SetOnGround(false);
+ m_Self->GetEnvironmentComponent()->SetOnGround(false);
// TODO: Change to AddSpeedY once collision detection is fixed - currently, mobs will go into blocks attempting to jump without a teleport
m_Self->AddPosY(1.2); // Jump!!
@@ -35,7 +35,7 @@ void cAIComponent::Tick(float a_Dt, cChunk & a_Chunk)
Distance.y = 0;
Distance.Normalize();
- if (m_Self->GetEnvironmentComponent().GetOnGround())
+ if (m_Self->GetEnvironmentComponent()->GetOnGround())
{
Distance *= 2.5f;
}
@@ -185,7 +185,7 @@ void cAIComponent::TickPathFinding()
BLOCKTYPE BlockAtY = m_Self->GetWorld()->GetBlock(gCrossCoords[i].x + PosX, PosY, gCrossCoords[i].z + PosZ);
BLOCKTYPE BlockAtYP = m_Self->GetWorld()->GetBlock(gCrossCoords[i].x + PosX, PosY + 1, gCrossCoords[i].z + PosZ);
BLOCKTYPE BlockAtYPP = m_Self->GetWorld()->GetBlock(gCrossCoords[i].x + PosX, PosY + 2, gCrossCoords[i].z + PosZ);
- int LowestY = m_Self->GetMovementComponent().FindFirstNonAirBlockPosition(gCrossCoords[i].x + PosX, gCrossCoords[i].z + PosZ);
+ int LowestY = m_Self->GetMovementComponent()->FindFirstNonAirBlockPosition(gCrossCoords[i].x + PosX, gCrossCoords[i].z + PosZ);
BLOCKTYPE BlockAtLowestY = m_Self->GetWorld()->GetBlock(gCrossCoords[i].x + PosX, LowestY, gCrossCoords[i].z + PosZ);
if (
@@ -259,7 +259,7 @@ bool cAIComponent::IsMovingToTargetPosition()
bool cAIComponent::ReachedFinalDestination()
{
- if ((m_Self->GetPosition() - m_FinalDestination).Length() <= m_Self->GetAttackComponent().GetAttackRange())
+ if ((m_Self->GetPosition() - m_FinalDestination).Length() <= m_Self->GetAttackComponent()->GetAttackRange())
{
return true;
}
@@ -321,9 +321,9 @@ void cAIComponent::InStateIdle(float a_Dt)
{
Vector3d Destination(m_Self->GetPosX() + Dist.x, 0, m_Self->GetPosZ() + Dist.z);
- int NextHeight = m_Self->GetMovementComponent().FindFirstNonAirBlockPosition(Destination.x, Destination.z);
+ int NextHeight = m_Self->GetMovementComponent()->FindFirstNonAirBlockPosition(Destination.x, Destination.z);
- if (m_Self->GetMovementComponent().IsNextYPosReachable(NextHeight))
+ if (m_Self->GetMovementComponent()->IsNextYPosReachable(NextHeight))
{
Destination.y = NextHeight;
MoveToPosition(Destination);
@@ -354,7 +354,7 @@ void cAIComponent::InStateEscaping(float a_Dt)
if (m_Target != NULL)
{
- int sight_distance = m_Self->GetEnvironmentComponent().GetSightDistance();
+ int sight_distance = m_Self->GetEnvironmentComponent()->GetSightDistance();
Vector3d newloc = m_Self->GetPosition();
newloc.x = (m_Target->GetPosition().x < newloc.x)? (newloc.x + sight_distance): (newloc.x - sight_distance);
newloc.z = (m_Target->GetPosition().z < newloc.z)? (newloc.z + sight_distance): (newloc.z - sight_distance);