summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-08-22 19:54:36 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-08-22 19:55:30 +0200
commit10a5271501670fc5f7066bbeefc63cd106351672 (patch)
tree9bc1ef775ae6ded57b465266c01cd83b664747ed /src/Mobs/Behaviors
parentd (diff)
downloadcuberite-10a5271501670fc5f7066bbeefc63cd106351672.tar
cuberite-10a5271501670fc5f7066bbeefc63cd106351672.tar.gz
cuberite-10a5271501670fc5f7066bbeefc63cd106351672.tar.bz2
cuberite-10a5271501670fc5f7066bbeefc63cd106351672.tar.lz
cuberite-10a5271501670fc5f7066bbeefc63cd106351672.tar.xz
cuberite-10a5271501670fc5f7066bbeefc63cd106351672.tar.zst
cuberite-10a5271501670fc5f7066bbeefc63cd106351672.zip
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r--src/Mobs/Behaviors/BehaviorDayLightBurner.cpp19
-rw-r--r--src/Mobs/Behaviors/BehaviorDayLightBurner.h8
-rw-r--r--src/Mobs/Behaviors/BehaviorItemFollower.cpp1
3 files changed, 16 insertions, 12 deletions
diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
index 9f182a359..809f0190f 100644
--- a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
+++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
@@ -2,10 +2,11 @@
#include "BehaviorDayLightBurner.h"
#include "../Monster.h"
-#include "../../World.h"
#include "../../Entities/Player.h"
#include "../../Entities/Entity.h"
+#include "../../Chunk.h"
+
cBehaviorDayLightBurner::cBehaviorDayLightBurner(cMonster * a_Parent) : m_Parent(a_Parent)
{
ASSERT(m_Parent != nullptr);
@@ -13,7 +14,7 @@ cBehaviorDayLightBurner::cBehaviorDayLightBurner(cMonster * a_Parent) : m_Parent
void cBehaviorDayLightBurner::Tick(cChunk & a_Chunk, bool WouldBurn)
{
- int RelY = POSY_TOINT;
+ int RelY = static_cast<int>(m_Parent->GetPosY());
if ((RelY < 0) || (RelY >= cChunkDef::Height))
{
// Outside the world
@@ -21,21 +22,21 @@ void cBehaviorDayLightBurner::Tick(cChunk & a_Chunk, bool WouldBurn)
}
if (!a_Chunk.IsLightValid())
{
- m_World->QueueLightChunk(GetChunkX(), GetChunkZ());
+ m_Parent->GetWorld()->QueueLightChunk(m_Parent->GetChunkX(), m_Parent->GetChunkZ());
return;
}
- if (!IsOnFire() && WouldBurn)
+ if (!m_Parent->IsOnFire() && WouldBurn)
{
// Burn for 100 ticks, then decide again
- StartBurning(100);
+ m_Parent->StartBurning(100);
}
}
-bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d & a_Location, cChunk & a_Chunk)
+bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk)
{
int RelY = FloorC(a_Location.y);
if (RelY <= 0)
@@ -57,11 +58,11 @@ bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d & a_Location, cChunk & a_Chun
if (
(Chunk->GetBlock(Rel.x, Rel.y, Rel.z) != E_BLOCK_SOULSAND) && // Not on soulsand
- (GetWorld()->GetTimeOfDay() < 12000 + 1000) && // Daytime
- GetWorld()->IsWeatherSunnyAt(POSX_TOINT, POSZ_TOINT) // Not raining
+ (m_Parent->GetWorld()->GetTimeOfDay() < 12000 + 1000) && // Daytime
+ m_Parent->GetWorld()->IsWeatherSunnyAt(static_cast<int>(m_Parent->GetPosX()), static_cast<int>(m_Parent->GetPosZ())) // Not raining
)
{
- int MobHeight = static_cast<int>(a_Location.y) + round(GetHeight()) - 1; // The height of the mob head
+ int MobHeight = static_cast<int>(a_Location.y) + static_cast<int>(round(m_Parent->GetHeight())) - 1; // The height of the mob head
if (MobHeight >= cChunkDef::Height)
{
return true;
diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.h b/src/Mobs/Behaviors/BehaviorDayLightBurner.h
index b54a863af..d967b5f68 100644
--- a/src/Mobs/Behaviors/BehaviorDayLightBurner.h
+++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.h
@@ -1,16 +1,20 @@
#pragma once
+// mobTodo I just need vector3d
+#include "../../World.h"
+
// fwds
class cMonster;
class cEntity;
class cChunk;
-class Vector3d;
class cBehaviorDayLightBurner
{
+public:
cBehaviorDayLightBurner(cMonster * a_Parent);
- bool WouldBurnAt(Vector3d & a_Location, cChunk & a_Chunk);
+ void Tick(cChunk & a_Chunk, bool WouldBurn);
+ bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk);
// Functions our host Monster should invoke:
void Tick();
diff --git a/src/Mobs/Behaviors/BehaviorItemFollower.cpp b/src/Mobs/Behaviors/BehaviorItemFollower.cpp
index 9d64ee0db..833050e69 100644
--- a/src/Mobs/Behaviors/BehaviorItemFollower.cpp
+++ b/src/Mobs/Behaviors/BehaviorItemFollower.cpp
@@ -19,7 +19,6 @@ cBehaviorItemFollower::cBehaviorItemFollower(cMonster * a_Parent) :
bool cBehaviorItemFollower::ActiveTick()
{
- cWorld * World = m_Parent->GetWorld();
cItems FollowedItems;
m_Parent->GetFollowedItems(FollowedItems);
if (FollowedItems.Size() > 0)