Move some player-specific data out of the bloated GameState class.

Have gameplay objects hold a PlayerState pointer instead of a PlayerNumber and indexing back into GameState.
This will simplify off-screen players (e.g. CPU ghosts, network replicated human players, >2 players using one NoteField)
This commit is contained in:
Chris Danford
2004-12-20 06:25:59 +00:00
parent 52545966e6
commit f840c014a9
70 changed files with 977 additions and 655 deletions
+12 -4
View File
@@ -7,6 +7,7 @@
#include "GameState.h"
#include "ThemeManager.h"
#include "StageStats.h"
#include "PlayerState.h"
ScoreDisplayOni::ScoreDisplayOni()
@@ -22,9 +23,13 @@ ScoreDisplayOni::ScoreDisplayOni()
this->AddChild( &m_text );
}
void ScoreDisplayOni::Init( PlayerNumber pn )
void ScoreDisplayOni::Init( const PlayerState* pPlayerState )
{
ScoreDisplay::Init( pn );
ScoreDisplay::Init( pPlayerState );
// TODO: Remove use of PlayerNumber.
PlayerNumber pn = pPlayerState->m_PlayerNumber;
m_text.SetDiffuse( PlayerToColor(pn) );
}
@@ -33,9 +38,12 @@ void ScoreDisplayOni::Update( float fDelta )
{
ScoreDisplay::Update( fDelta );
// TODO: Remove use of PlayerNumber.
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
float fSecsIntoPlay = 0;
if( GAMESTATE->IsPlayerEnabled(m_PlayerNumber) )
fSecsIntoPlay = g_CurStageStats.fAliveSeconds[m_PlayerNumber];
if( GAMESTATE->IsPlayerEnabled(pn) )
fSecsIntoPlay = g_CurStageStats.fAliveSeconds[pn];
m_text.SetText( SecondsToMMSSMsMs(fSecsIntoPlay) );
}