pull stuff out from GameState
This commit is contained in:
@@ -560,47 +560,6 @@ void GameState::Update( float fDelta )
|
|||||||
{
|
{
|
||||||
m_pPlayerState[p]->Update( fDelta );
|
m_pPlayerState[p]->Update( fDelta );
|
||||||
|
|
||||||
// TRICKY: GAMESTATE->Update is run before any of the Screen update's,
|
|
||||||
// so we'll clear these flags here and let them get turned on later
|
|
||||||
m_pPlayerState[p]->m_bAttackBeganThisUpdate = false;
|
|
||||||
m_pPlayerState[p]->m_bAttackEndedThisUpdate = false;
|
|
||||||
|
|
||||||
bool bRebuildPlayerOptions = false;
|
|
||||||
|
|
||||||
/* See if any delayed attacks are starting or ending. */
|
|
||||||
for( unsigned s=0; s<m_pPlayerState[p]->m_ActiveAttacks.size(); s++ )
|
|
||||||
{
|
|
||||||
Attack &attack = m_pPlayerState[p]->m_ActiveAttacks[s];
|
|
||||||
|
|
||||||
// -1 is the "starts now" sentinel value. You must add the attack
|
|
||||||
// by calling GameState::LaunchAttack, or else the -1 won't be
|
|
||||||
// converted into the current music time.
|
|
||||||
ASSERT( attack.fStartSecond != -1 );
|
|
||||||
|
|
||||||
bool bCurrentlyEnabled =
|
|
||||||
attack.bGlobal ||
|
|
||||||
( attack.fStartSecond < this->m_fMusicSeconds &&
|
|
||||||
m_fMusicSeconds < attack.fStartSecond+attack.fSecsRemaining );
|
|
||||||
|
|
||||||
if( m_pPlayerState[p]->m_ActiveAttacks[s].bOn == bCurrentlyEnabled )
|
|
||||||
continue; /* OK */
|
|
||||||
|
|
||||||
if( m_pPlayerState[p]->m_ActiveAttacks[s].bOn && !bCurrentlyEnabled )
|
|
||||||
m_pPlayerState[p]->m_bAttackEndedThisUpdate = true;
|
|
||||||
else if( !m_pPlayerState[p]->m_ActiveAttacks[s].bOn && bCurrentlyEnabled )
|
|
||||||
m_pPlayerState[p]->m_bAttackBeganThisUpdate = true;
|
|
||||||
|
|
||||||
bRebuildPlayerOptions = true;
|
|
||||||
|
|
||||||
m_pPlayerState[p]->m_ActiveAttacks[s].bOn = bCurrentlyEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( bRebuildPlayerOptions )
|
|
||||||
m_pPlayerState[p]->RebuildPlayerOptionsFromActiveAttacks();
|
|
||||||
|
|
||||||
if( m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut > 0 )
|
|
||||||
m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut = max( 0, m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut - fDelta );
|
|
||||||
|
|
||||||
if( !m_bGoalComplete[p] && IsGoalComplete(p) )
|
if( !m_bGoalComplete[p] && IsGoalComplete(p) )
|
||||||
{
|
{
|
||||||
m_bGoalComplete[p] = true;
|
m_bGoalComplete[p] = true;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "PlayerState.h"
|
#include "PlayerState.h"
|
||||||
|
#include "GameState.h"
|
||||||
|
|
||||||
void PlayerState::ResetNoteSkins()
|
void PlayerState::ResetNoteSkins()
|
||||||
{
|
{
|
||||||
@@ -10,6 +11,47 @@ void PlayerState::ResetNoteSkins()
|
|||||||
void PlayerState::Update( float fDelta )
|
void PlayerState::Update( float fDelta )
|
||||||
{
|
{
|
||||||
m_CurrentPlayerOptions.Approach( m_PlayerOptions, fDelta );
|
m_CurrentPlayerOptions.Approach( m_PlayerOptions, fDelta );
|
||||||
|
|
||||||
|
// TRICKY: GAMESTATE->Update is run before any of the Screen update's,
|
||||||
|
// so we'll clear these flags here and let them get turned on later
|
||||||
|
m_bAttackBeganThisUpdate = false;
|
||||||
|
m_bAttackEndedThisUpdate = false;
|
||||||
|
|
||||||
|
bool bRebuildPlayerOptions = false;
|
||||||
|
|
||||||
|
/* See if any delayed attacks are starting or ending. */
|
||||||
|
for( unsigned s=0; s<m_ActiveAttacks.size(); s++ )
|
||||||
|
{
|
||||||
|
Attack &attack = m_ActiveAttacks[s];
|
||||||
|
|
||||||
|
// -1 is the "starts now" sentinel value. You must add the attack
|
||||||
|
// by calling GameState::LaunchAttack, or else the -1 won't be
|
||||||
|
// converted into the current music time.
|
||||||
|
ASSERT( attack.fStartSecond != -1 );
|
||||||
|
|
||||||
|
bool bCurrentlyEnabled =
|
||||||
|
attack.bGlobal ||
|
||||||
|
( attack.fStartSecond < GAMESTATE->m_fMusicSeconds &&
|
||||||
|
GAMESTATE->m_fMusicSeconds < attack.fStartSecond+attack.fSecsRemaining );
|
||||||
|
|
||||||
|
if( m_ActiveAttacks[s].bOn == bCurrentlyEnabled )
|
||||||
|
continue; /* OK */
|
||||||
|
|
||||||
|
if( m_ActiveAttacks[s].bOn && !bCurrentlyEnabled )
|
||||||
|
m_bAttackEndedThisUpdate = true;
|
||||||
|
else if( !m_ActiveAttacks[s].bOn && bCurrentlyEnabled )
|
||||||
|
m_bAttackBeganThisUpdate = true;
|
||||||
|
|
||||||
|
bRebuildPlayerOptions = true;
|
||||||
|
|
||||||
|
m_ActiveAttacks[s].bOn = bCurrentlyEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( bRebuildPlayerOptions )
|
||||||
|
RebuildPlayerOptionsFromActiveAttacks();
|
||||||
|
|
||||||
|
if( m_fSecondsUntilAttacksPhasedOut > 0 )
|
||||||
|
m_fSecondsUntilAttacksPhasedOut = max( 0, m_fSecondsUntilAttacksPhasedOut - fDelta );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerState::RebuildPlayerOptionsFromActiveAttacks()
|
void PlayerState::RebuildPlayerOptionsFromActiveAttacks()
|
||||||
|
|||||||
Reference in New Issue
Block a user