2012-09-30 09:37:44 -07:00
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
#include "FallingBlock.h"
|
|
|
|
#include "World.h"
|
|
|
|
#include "ClientHandle.h"
|
|
|
|
|
|
|
|
|
2012-12-21 04:21:20 -08:00
|
|
|
|
2012-09-30 09:37:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType)
|
2012-12-21 04:52:14 -08:00
|
|
|
: super(etFallingBlock, a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f )
|
2012-09-30 09:37:44 -07:00
|
|
|
, m_BlockType( a_BlockType )
|
|
|
|
, m_OriginalPosition( a_BlockPosition )
|
|
|
|
, m_SpeedY( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cFallingBlock::Initialize(cWorld * a_World)
|
|
|
|
{
|
|
|
|
super::Initialize( a_World );
|
|
|
|
a_World->BroadcastSpawn(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
|
|
|
|
{
|
|
|
|
a_ClientHandle.SendSpawnObject(*this, 70, m_BlockType, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cFallingBlock::Tick(float a_Dt)
|
|
|
|
{
|
|
|
|
float MilliDt = a_Dt * 0.001f;
|
|
|
|
m_SpeedY -= MilliDt * 9.8f;
|
|
|
|
m_Pos.y += m_SpeedY * MilliDt;
|
|
|
|
|
|
|
|
//GetWorld()->BroadcastTeleportEntity(*this); // Testing position
|
|
|
|
|
2012-12-21 04:21:20 -08:00
|
|
|
Vector3i BlockPos( m_OriginalPosition.x, (int)(m_Pos.y - 0.5), m_OriginalPosition.z );
|
|
|
|
if (!IsPassable(GetWorld()->GetBlock(BlockPos)))
|
2012-09-30 09:37:44 -07:00
|
|
|
{
|
|
|
|
Destroy();
|
2012-12-21 04:21:20 -08:00
|
|
|
GetWorld()->SetBlock( BlockPos.x, BlockPos.y + 1, BlockPos.z, m_BlockType, 0 );
|
2012-09-30 09:37:44 -07:00
|
|
|
}
|
2012-12-21 04:21:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|