1
0
Fork 0
cuberite-2a/src/Entities/TNTEntity.cpp

66 lines
911 B
C++
Raw Normal View History

#include "Globals.h"
#include "TNTEntity.h"
#include "../World.h"
#include "../ClientHandle.h"
cTNTEntity::cTNTEntity(Vector3d a_Pos, int a_FuseTicks) :
2020-04-13 16:38:06 +00:00
Super(etTNT, a_Pos, 0.98, 0.98),
2014-03-08 11:24:33 +00:00
m_FuseTicks(a_FuseTicks)
{
SetGravity(-16.0f);
2020-03-19 02:35:21 +00:00
SetAirDrag(0.02f);
}
void cTNTEntity::SpawnOn(cClientHandle & a_ClientHandle)
{
2020-04-20 19:46:04 +00:00
a_ClientHandle.SendSpawnEntity(*this);
m_bDirtyOrientation = false; // TODO: why?
m_bDirtyHead = false;
}
void cTNTEntity::Explode(void)
{
m_FuseTicks = 0;
Destroy();
FLOGD("BOOM at {0}", GetPosition());
m_World->DoExplosionAt(4.0, GetPosX(), GetPosY(), GetPosZ(), true, esPrimedTNT, this);
}
void cTNTEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
2020-04-13 16:38:06 +00:00
Super::Tick(a_Dt, a_Chunk);
if (!IsTicking())
{
// The base class tick destroyed us
return;
}
BroadcastMovementUpdate();
2016-02-05 21:45:45 +00:00
2014-03-08 11:24:33 +00:00
m_FuseTicks -= 1;
if (m_FuseTicks <= 0)
{
Explode();
}
}