From b29af701b9a0b6bfbd2acaae06e32e9742fd7e78 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 22 Dec 2012 10:15:53 +0000 Subject: 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 --- source/Pickup.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'source/Pickup.cpp') diff --git a/source/Pickup.cpp b/source/Pickup.cpp index 3034e73de..f147434ab 100644 --- a/source/Pickup.cpp +++ b/source/Pickup.cpp @@ -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); -- cgit v1.2.3