summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Components/BurningComponent.inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Components/BurningComponent.inc')
-rw-r--r--src/Mobs/Components/BurningComponent.inc36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Mobs/Components/BurningComponent.inc b/src/Mobs/Components/BurningComponent.inc
new file mode 100644
index 000000000..432879700
--- /dev/null
+++ b/src/Mobs/Components/BurningComponent.inc
@@ -0,0 +1,36 @@
+
+#include "BurningComponent.h"
+
+template <class EntityType, class ChunkType>
+void cBurningComponent<EntityType, ChunkType>::Tick(float a_Dt, ChunkType & a_Chunk)
+{
+
+ int RelY = (int)floor(m_Self.GetPosY());
+ if ((RelY < 0) || (RelY >= cChunkDef::Height))
+ {
+ // Outside the world
+ return;
+ }
+ int PosX = (int)floor(m_Self.GetPosX());
+ int PosZ = (int)floor(m_Self.GetPosZ());
+ int RelX = PosX - m_Self.GetChunkX() * cChunkDef::Width;
+ int RelZ = PosZ - m_Self.GetChunkZ() * cChunkDef::Width;
+
+ if (!a_Chunk.IsLightValid())
+ {
+ a_Chunk.GetWorld()->QueueLightChunk(m_Self.GetChunkX(), m_Self.GetChunkZ());
+ return;
+ }
+
+ if (
+ (a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight
+ (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
+ (a_Chunk.GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime
+ !m_Self.IsOnFire() && // Not already burning
+ a_Chunk.GetWorld()->IsWeatherWetAt(PosX, PosZ) // Not raining
+ )
+ {
+ // Burn for 100 ticks, then decide again
+ m_Self.StartBurning(100);
+ }
+}