* added param Difference in LifeChanged message

* dont die on 1st song because initial life is not set
This commit is contained in:
Vecais Dumais Laacis
2007-08-07 11:15:18 +00:00
parent 1aad3ba5a5
commit 670e134dad
2 changed files with 9 additions and 6 deletions
+8 -5
View File
@@ -97,8 +97,10 @@ void LifeMeterTime::Load( const PlayerState *pPlayerState, PlayerStageStats *pPl
void LifeMeterTime::OnLoadSong() void LifeMeterTime::OnLoadSong()
{ {
if( GetLifeSeconds() <= 0 ) if( ( GetLifeSeconds() <= 0 ) && ( GAMESTATE->GetCourseSongIndex() > 0 ) )
{
return; return;
}
Course* pCourse = GAMESTATE->m_pCurCourse; Course* pCourse = GAMESTATE->m_pCurCourse;
ASSERT( pCourse ); ASSERT( pCourse );
@@ -109,7 +111,7 @@ void LifeMeterTime::OnLoadSong()
m_soundGainLife.Play(); m_soundGainLife.Play();
SendLifeChangedMessage( fOldLife, TapNoteScore_Invalid, HoldNoteScore_Invalid ); SendLifeChangedMessage( fOldLife, TapNoteScore_Invalid, HoldNoteScore_Invalid, pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].fGainSeconds );
} }
@@ -137,7 +139,7 @@ void LifeMeterTime::ChangeLife( TapNoteScore tns )
m_fLifeTotalLostSeconds -= fMeterChange; m_fLifeTotalLostSeconds -= fMeterChange;
SendLifeChangedMessage( fOldLife, tns, HoldNoteScore_Invalid ); SendLifeChangedMessage( fOldLife, tns, HoldNoteScore_Invalid, fMeterChange );
} }
void LifeMeterTime::ChangeLife( HoldNoteScore hns, TapNoteScore tns ) void LifeMeterTime::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
@@ -157,7 +159,7 @@ void LifeMeterTime::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
m_fLifeTotalLostSeconds -= fMeterChange; m_fLifeTotalLostSeconds -= fMeterChange;
SendLifeChangedMessage( fOldLife, tns, hns ); SendLifeChangedMessage( fOldLife, tns, hns, fMeterChange );
} }
void LifeMeterTime::HandleTapScoreNone() void LifeMeterTime::HandleTapScoreNone()
@@ -165,13 +167,14 @@ void LifeMeterTime::HandleTapScoreNone()
} }
void LifeMeterTime::SendLifeChangedMessage( float fOldLife, TapNoteScore tns, HoldNoteScore hns ) void LifeMeterTime::SendLifeChangedMessage( float fOldLife, TapNoteScore tns, HoldNoteScore hns, float fDifference )
{ {
Message msg( "LifeChanged" ); Message msg( "LifeChanged" );
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber ); msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
msg.SetParam( "TapNoteScore", LuaReference::Create(tns) ); msg.SetParam( "TapNoteScore", LuaReference::Create(tns) );
msg.SetParam( "HoldNoteScore", LuaReference::Create(hns) ); msg.SetParam( "HoldNoteScore", LuaReference::Create(hns) );
msg.SetParam( "OldLife", fOldLife ); msg.SetParam( "OldLife", fOldLife );
msg.SetParam( "Difference", fDifference );
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) ); msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
MESSAGEMAN->Broadcast( msg ); MESSAGEMAN->Broadcast( msg );
} }
+1 -1
View File
@@ -33,7 +33,7 @@ public:
private: private:
float GetLifeSeconds() const; float GetLifeSeconds() const;
void SendLifeChangedMessage( float fOldLife, TapNoteScore tns, HoldNoteScore hns ); void SendLifeChangedMessage( float fOldLife, TapNoteScore tns, HoldNoteScore hns, float fDifference );
AutoActor m_sprBackground; AutoActor m_sprBackground;
Quad m_quadDangerGlow; Quad m_quadDangerGlow;