move RebuildPlayerOptionsFromActiveAttacks into PlayerState (SGameplay
commit in a moment)
This commit is contained in:
@@ -594,7 +594,7 @@ void GameState::Update( float fDelta )
|
||||
}
|
||||
|
||||
if( bRebuildPlayerOptions )
|
||||
RebuildPlayerOptionsFromActiveAttacks( p );
|
||||
m_pPlayerState[p]->RebuildPlayerOptionsFromActiveAttacks();
|
||||
|
||||
if( m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut > 0 )
|
||||
m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut = max( 0, m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut - fDelta );
|
||||
@@ -1223,7 +1223,7 @@ void GameState::LaunchAttack( PlayerNumber target, const Attack& a )
|
||||
attack.fStartSecond = this->m_fMusicSeconds;
|
||||
m_pPlayerState[target]->m_ActiveAttacks.push_back( attack );
|
||||
|
||||
this->RebuildPlayerOptionsFromActiveAttacks( target );
|
||||
m_pPlayerState[target]->RebuildPlayerOptionsFromActiveAttacks();
|
||||
}
|
||||
|
||||
void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al )
|
||||
@@ -1235,7 +1235,7 @@ void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al )
|
||||
m_pPlayerState[pn]->m_ActiveAttacks.erase( m_pPlayerState[pn]->m_ActiveAttacks.begin()+s, m_pPlayerState[pn]->m_ActiveAttacks.begin()+s+1 );
|
||||
--s;
|
||||
}
|
||||
RebuildPlayerOptionsFromActiveAttacks( pn );
|
||||
m_pPlayerState[pn]->RebuildPlayerOptionsFromActiveAttacks();
|
||||
}
|
||||
|
||||
void GameState::EndActiveAttacksForPlayer( PlayerNumber pn )
|
||||
@@ -1256,32 +1256,6 @@ void GameState::RemoveAllInventory()
|
||||
}
|
||||
}
|
||||
|
||||
void GameState::RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn )
|
||||
{
|
||||
// rebuild player options
|
||||
PlayerOptions po = m_pPlayerState[pn]->m_StoredPlayerOptions;
|
||||
for( unsigned s=0; s<m_pPlayerState[pn]->m_ActiveAttacks.size(); s++ )
|
||||
{
|
||||
if( !m_pPlayerState[pn]->m_ActiveAttacks[s].bOn )
|
||||
continue; /* hasn't started yet */
|
||||
po.FromString( m_pPlayerState[pn]->m_ActiveAttacks[s].sModifiers );
|
||||
}
|
||||
m_pPlayerState[pn]->m_PlayerOptions = po;
|
||||
|
||||
|
||||
int iSumOfAttackLevels = m_pPlayerState[pn]->GetSumOfActiveAttackLevels();
|
||||
if( iSumOfAttackLevels > 0 )
|
||||
{
|
||||
m_pPlayerState[pn]->m_iLastPositiveSumOfAttackLevels = iSumOfAttackLevels;
|
||||
m_pPlayerState[pn]->m_fSecondsUntilAttacksPhasedOut = 10000; // any positive number that won't run out before the attacks
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't change! m_iLastPositiveSumOfAttackLevels[p] = iSumOfAttackLevels;
|
||||
m_pPlayerState[pn]->m_fSecondsUntilAttacksPhasedOut = 2; // 2 seconds to phase out
|
||||
}
|
||||
}
|
||||
|
||||
void GameState::RemoveAllActiveAttacks() // called on end of song
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
|
||||
@@ -192,12 +192,10 @@ public:
|
||||
|
||||
void GetUndisplayedBeats( const PlayerState* pPlayerState, float TotalSeconds, float &StartBeat, float &EndBeat ) const; // only meaningful when a NoteField is in use
|
||||
void LaunchAttack( PlayerNumber target, const Attack& a );
|
||||
void RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn );
|
||||
void RemoveAllActiveAttacks(); // called on end of song
|
||||
void RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al=NUM_ATTACK_LEVELS /*all*/ );
|
||||
void EndActiveAttacksForPlayer( PlayerNumber pn );
|
||||
void RemoveAllInventory();
|
||||
int GetSumOfActiveAttackLevels( PlayerNumber pn ) const;
|
||||
PlayerNumber GetBestPlayer() const;
|
||||
StageResult GetStageResult( PlayerNumber pn ) const;
|
||||
|
||||
|
||||
@@ -12,13 +12,39 @@ void PlayerState::Update( float fDelta )
|
||||
m_CurrentPlayerOptions.Approach( m_PlayerOptions, fDelta );
|
||||
}
|
||||
|
||||
void PlayerState::RebuildPlayerOptionsFromActiveAttacks()
|
||||
{
|
||||
// rebuild player options
|
||||
PlayerOptions po = m_StoredPlayerOptions;
|
||||
for( unsigned s=0; s<m_ActiveAttacks.size(); s++ )
|
||||
{
|
||||
if( !m_ActiveAttacks[s].bOn )
|
||||
continue; /* hasn't started yet */
|
||||
po.FromString( m_ActiveAttacks[s].sModifiers );
|
||||
}
|
||||
m_PlayerOptions = po;
|
||||
|
||||
|
||||
int iSumOfAttackLevels = GetSumOfActiveAttackLevels();
|
||||
if( iSumOfAttackLevels > 0 )
|
||||
{
|
||||
m_iLastPositiveSumOfAttackLevels = iSumOfAttackLevels;
|
||||
m_fSecondsUntilAttacksPhasedOut = 10000; // any positive number that won't run out before the attacks
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't change! m_iLastPositiveSumOfAttackLevels[p] = iSumOfAttackLevels;
|
||||
m_fSecondsUntilAttacksPhasedOut = 2; // 2 seconds to phase out
|
||||
}
|
||||
}
|
||||
|
||||
int PlayerState::GetSumOfActiveAttackLevels() const
|
||||
{
|
||||
int iSum = 0;
|
||||
|
||||
for( unsigned s=0; s<m_ActiveAttacks.size(); s++ )
|
||||
if( m_ActiveAttacks[s].fSecsRemaining > 0 && m_ActiveAttacks[s].level != NUM_ATTACK_LEVELS )
|
||||
iSum += m_pPlayerState[pn]m_ActiveAttacks[s].level;
|
||||
iSum += m_ActiveAttacks[s].level;
|
||||
|
||||
return iSum;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ struct PlayerState
|
||||
//
|
||||
// Used in Battle and Rave
|
||||
//
|
||||
void RebuildPlayerOptionsFromActiveAttacks();
|
||||
int GetSumOfActiveAttackLevels() const;
|
||||
int m_iCpuSkill; // only used when m_PlayerController is PC_CPU
|
||||
// Attacks take a while to transition out of use. Account for this in PlayerAI
|
||||
|
||||
@@ -1610,7 +1610,7 @@ void ScreenEdit::TransitionEditState( EditState em )
|
||||
|
||||
/* Stop displaying course attacks, if any. */
|
||||
GAMESTATE->RemoveAllActiveAttacks();
|
||||
GAMESTATE->RebuildPlayerOptionsFromActiveAttacks( PLAYER_1 );
|
||||
GAMESTATE->m_pPlayerState[PLAYER_1]->RebuildPlayerOptionsFromActiveAttacks();
|
||||
GAMESTATE->m_pPlayerState[PLAYER_1]->m_CurrentPlayerOptions = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions;
|
||||
|
||||
if( old == STATE_RECORDING )
|
||||
@@ -2820,7 +2820,7 @@ void ScreenEdit::SetupCourseAttacks()
|
||||
for( unsigned i=0; i<Attacks.size(); ++i )
|
||||
GAMESTATE->LaunchAttack( PLAYER_1, Attacks[i] );
|
||||
}
|
||||
GAMESTATE->RebuildPlayerOptionsFromActiveAttacks( PLAYER_1 );
|
||||
GAMESTATE->m_pPlayerState[PLAYER_1]->RebuildPlayerOptionsFromActiveAttacks();
|
||||
}
|
||||
|
||||
void ScreenEdit::CopyToLastSave()
|
||||
|
||||
Reference in New Issue
Block a user