1
0

Moved daylight burning directly into cMonster.

This commit is contained in:
madmaxoft
2013-09-05 22:40:08 +02:00
parent cdaa483778
commit ff762a7ece
6 changed files with 46 additions and 40 deletions

View File

@@ -15,6 +15,7 @@
#include "../Vector3i.h"
#include "../Vector3d.h"
#include "../Tracer.h"
#include "../Chunk.h"
// #include "../../iniFile/iniFile.h"
@@ -100,6 +101,9 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
// Burning in daylight
HandleDaylightBurning(a_Chunk);
HandlePhysics(a_Dt,a_Chunk);
BroadcastMovementUpdate();
@@ -473,3 +477,35 @@ void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned
void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
{
if (!m_BurnsInDaylight)
{
return;
}
int RelY = (int)floor(GetPosY());
if ((RelY < 0) || (RelY >= cChunkDef::Height))
{
// Outside the world
return;
}
int RelX = (int)floor(GetPosX()) - a_Chunk.GetPosX() * cChunkDef::Width;
int RelZ = (int)floor(GetPosZ()) - a_Chunk.GetPosZ() * cChunkDef::Width;
if (
(a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight
(a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
(GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime
!IsOnFire() // Not already burning
)
{
// Burn for 100 ticks, then decide again
StartBurning(100);
}
}