1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "Globals.h"
#include "FallingBlock.h"
#include "World.h"
#include "ClientHandle.h"
cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType)
: super( a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f )
, 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
Vector3i BlockPos( m_OriginalPosition.x, (int)(m_Pos.y - 0.5), m_OriginalPosition.z );
if (!IsPassable(GetWorld()->GetBlock(BlockPos)))
{
Destroy();
GetWorld()->SetBlock( BlockPos.x, BlockPos.y + 1, BlockPos.z, m_BlockType, 0 );
}
}
|