2013-07-29 07:13:03 -04:00
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
#include "TNTEntity.h"
|
2013-08-19 05:39:13 -04:00
|
|
|
#include "../World.h"
|
|
|
|
#include "../ClientHandle.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-12 14:57:44 -04:00
|
|
|
cTNTEntity::cTNTEntity(Vector3d a_Pos, unsigned a_FuseTicks) :
|
2020-04-13 12:38:06 -04:00
|
|
|
Super(etTNT, a_Pos, 0.98, 0.98),
|
2014-03-08 06:24:33 -05:00
|
|
|
m_FuseTicks(a_FuseTicks)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2015-03-30 19:42:32 -04:00
|
|
|
SetGravity(-16.0f);
|
2020-03-18 22:35:21 -04:00
|
|
|
SetAirDrag(0.02f);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-26 17:24:36 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
void cTNTEntity::SpawnOn(cClientHandle & a_ClientHandle)
|
|
|
|
{
|
2020-04-20 15:46:04 -04:00
|
|
|
a_ClientHandle.SendSpawnEntity(*this);
|
|
|
|
m_bDirtyOrientation = false; // TODO: why?
|
2013-07-29 07:13:03 -04:00
|
|
|
m_bDirtyHead = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-08 04:25:46 -05:00
|
|
|
void cTNTEntity::Explode(void)
|
|
|
|
{
|
2018-09-24 16:33:39 -04:00
|
|
|
FLOGD("BOOM at {0}", GetPosition());
|
2020-09-12 14:57:44 -04:00
|
|
|
|
|
|
|
// Destroy first so the Explodinator doesn't find us (when iterating through entities):
|
|
|
|
Destroy();
|
|
|
|
|
|
|
|
// TODO: provided centred coordinates to all calls to DoExplosionAt, from entities and blocks
|
|
|
|
// This is to ensure maximum efficiency of explosions
|
|
|
|
m_World->DoExplosionAt(4.0, GetPosX(), GetPosY() + GetHeight() / 2, GetPosZ(), true, esPrimedTNT, this);
|
2014-03-08 04:25:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
void cTNTEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
Super::Tick(a_Dt, a_Chunk);
|
2016-09-03 07:31:27 -04:00
|
|
|
if (!IsTicking())
|
|
|
|
{
|
|
|
|
// The base class tick destroyed us
|
|
|
|
return;
|
|
|
|
}
|
2020-09-12 14:57:44 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
BroadcastMovementUpdate();
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2020-10-05 06:27:14 -04:00
|
|
|
if (m_FuseTicks > 0)
|
|
|
|
{
|
|
|
|
--m_FuseTicks;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_FuseTicks == 0)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2014-03-08 04:25:46 -05:00
|
|
|
Explode();
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|