1
0

MTRand reference is now passed as a Tick() parameter so that it isn't created and destroyed over and over again. All entities will handle physics (empty callback for now)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1096 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2012-12-22 10:15:53 +00:00
parent aebe130299
commit b29af701b9
31 changed files with 405 additions and 167 deletions

View File

@@ -67,36 +67,33 @@ void cPickup::SpawnOn(cClientHandle & a_Client)
void cPickup::Tick(float a_Dt)
void cPickup::Tick(float a_Dt, MTRand & a_TickRandom)
{
super::Tick(a_Dt, a_TickRandom);
m_Timer += a_Dt;
a_Dt = a_Dt / 1000.f;
if(m_bCollected)
if (m_bCollected)
{
if(m_Timer > 500.f) // 0.5 second
if (m_Timer > 500.f) // 0.5 second
{
Destroy();
return;
}
}
if( m_Timer > 1000*60*5 ) // 5 minutes
if (m_Timer > 1000 * 60 * 5) // 5 minutes
{
Destroy();
return;
}
if( m_Pos.y < 0 ) // Out of this world!
if (m_Pos.y < -8) // Out of this world and no more visible!
{
Destroy();
return;
}
if (!m_bCollected)
{
HandlePhysics(a_Dt);
}
if (!m_bReplicated || m_bDirtyPosition)
{
MoveToCorrectChunk();
@@ -229,7 +226,7 @@ void cPickup::HandlePhysics(float a_Dt)
bool cPickup::CollectedBy( cPlayer* a_Dest )
bool cPickup::CollectedBy(cPlayer * a_Dest)
{
if (m_bCollected)
{
@@ -252,7 +249,8 @@ bool cPickup::CollectedBy( cPlayer* a_Dest )
m_World->BroadcastCollectPickup(*this, *a_Dest);
m_bCollected = true;
m_Timer = 0;
if( m_Item->m_ItemCount != 0 ) {
if (m_Item->m_ItemCount != 0)
{
cItems Pickup;
Pickup.push_back(cItem(*m_Item));
m_World->SpawnItemPickups(Pickup, m_Pos.x, m_Pos.y, m_Pos.z);