Split Update into Update and UpdateInternal so that every class doesn't need to early abort in Update when hibernating

This commit is contained in:
Chris Danford
2005-06-11 10:32:58 +00:00
parent 3b3408d11e
commit 98784d3fb5
11 changed files with 33 additions and 28 deletions
+15 -3
View File
@@ -486,9 +486,6 @@ void Actor::Update( float fDeltaTime )
// LOG->Trace( "Actor::Update( %f )", fDeltaTime );
ASSERT_M( fDeltaTime >= 0, ssprintf("%f",fDeltaTime) );
if( m_bFirstUpdate )
m_bFirstUpdate = false;
if( m_fHibernateSecondsLeft > 0 )
{
m_fHibernateSecondsLeft -= fDeltaTime;
@@ -500,6 +497,14 @@ void Actor::Update( float fDeltaTime )
m_fHibernateSecondsLeft = 0;
}
this->UpdateInternal( fDeltaTime );
}
void Actor::UpdateInternal( float fDeltaTime )
{
if( m_bFirstUpdate )
m_bFirstUpdate = false;
switch( m_EffectClock )
{
case CLOCK_TIMER:
@@ -1052,6 +1057,13 @@ bool Actor::HasCommand( const CString &sCmdName )
return it != m_mapNameToCommands.end();
}
const apActorCommands& Actor::GetCommand( const CString &sCommandName ) const
{
map<CString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sCommandName );
ASSERT( it != m_mapNameToCommands.end() );
return it->second;
}
void Actor::PlayCommand( const CString &sCommandName )
{
PlayCommand2( sCommandName, NULL );
+5 -1
View File
@@ -87,8 +87,11 @@ public:
virtual void DrawPrimitives() {}; // Derivitives should override
virtual void EndDraw(); // pops transform from world matrix stack
// TODO: make Update non virtual and change all classes to override UpdateInternal
// instead.
bool IsFirstUpdate() const;
virtual void Update( float fDeltaTime );
virtual void Update( float fDeltaTime ); // this can short circuit UpdateInternal
virtual void UpdateInternal( float fDeltaTime ); // override this
void UpdateTweening( float fDeltaTime );
void CopyTweening( const Actor &from );
@@ -333,6 +336,7 @@ public:
virtual void PushSelf( lua_State *L );
void AddCommand( const CString &sCmdName, apActorCommands apac );
bool HasCommand( const CString &sCmdName );
const apActorCommands& GetCommand( const CString &sCommandName ) const;
virtual void PlayCommand( const CString &sCommandName );
virtual void PlayCommand2( const CString &sCommandName, Actor *pParent );
virtual void RunCommands( const LuaReference& cmds );
+2 -5
View File
@@ -216,16 +216,13 @@ void ActorFrame::RunCommandsOnLeaves( const LuaReference& cmds )
m_SubActors[i]->RunCommandsOnLeaves( cmds );
}
void ActorFrame::Update( float fDeltaTime )
void ActorFrame::UpdateInternal( float fDeltaTime )
{
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
fDeltaTime *= m_fUpdateRate;
Actor::Update( fDeltaTime );
if( m_fHibernateSecondsLeft > 0 )
return;
Actor::UpdateInternal( fDeltaTime );
// update all sub-Actors
for( vector<Actor*>::iterator it=m_SubActors.begin(); it!=m_SubActors.end(); it++ )
+1 -1
View File
@@ -71,7 +71,7 @@ public:
virtual void RunCommandsOnChildren( const apActorCommands& cmds ) { RunCommandsOnChildren( *cmds ); } // convenience
virtual void RunCommandsOnLeaves( const LuaReference& cmds ); /* but not on self */
virtual void Update( float fDeltaTime );
virtual void UpdateInternal( float fDeltaTime );
virtual void DrawPrimitives();
// propagated commands
+2 -5
View File
@@ -153,12 +153,9 @@ void ActorScroller::LoadFromNode( const CString &sDir, const XNode *pNode )
pNode->GetAttrValue( "QuantizePixels", m_fQuantizePixels );
}
void ActorScroller::Update( float fDeltaTime )
void ActorScroller::UpdateInternal( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
if( m_fHibernateSecondsLeft > 0 )
return; // early abort
ActorFrame::UpdateInternal( fDeltaTime );
/* If we have no children, the code below will busy loop. */
if( !m_SubActors.size() )
+1 -1
View File
@@ -42,7 +42,7 @@ public:
const CString &sTransformFunction,
bool bUseMask );
virtual void Update( float fDelta );
virtual void UpdateInternal( float fDelta );
virtual void DrawPrimitives(); // DOES draw
void LoadFromNode( const CString &sDir, const XNode *pNode );
+2 -5
View File
@@ -556,12 +556,9 @@ void BGAnimationLayer::LoadFromNode( const CString& sDir, const XNode* pNode )
}
}
void BGAnimationLayer::Update( float fDeltaTime )
void BGAnimationLayer::UpdateInternal( float fDeltaTime )
{
if( m_fHibernateSecondsLeft > 0 )
return;
ActorFrame::Update( fDeltaTime );
ActorFrame::UpdateInternal( fDeltaTime );
fDeltaTime *= m_fUpdateRate;
+1 -1
View File
@@ -20,7 +20,7 @@ public:
void LoadFromAniLayerFile( const CString& sPath );
void LoadFromNode( const CString& sDir, const XNode* pNode );
void Update( float fDeltaTime );
void UpdateInternal( float fDeltaTime );
void DrawPrimitives();
bool EarlyAbortDraw();
+1 -3
View File
@@ -629,9 +629,7 @@ bool ThemeManager::GetMetricRaw( const CString &sClassName, const CString &sValu
CString sFallback;
for( deque<Theme>::const_iterator iter = g_vThemes.begin();
iter != g_vThemes.end();
iter++ )
FOREACHD_CONST( Theme, g_vThemes, iter )
{
if( iter->iniMetrics->GetValue(sClassName,sValueName,ret) )
return true;
+2 -2
View File
@@ -65,7 +65,7 @@ void Transition::Load( CString sBGAniDir )
}
void Transition::Update( float fDeltaTime )
void Transition::UpdateInternal( float fDeltaTime )
{
if( m_State != transitioning )
return;
@@ -83,7 +83,7 @@ void Transition::Update( float fDeltaTime )
SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone );
}
ActorFrame::Update( fDeltaTime );
ActorFrame::UpdateInternal( fDeltaTime );
}
void Transition::Reset()
+1 -1
View File
@@ -16,7 +16,7 @@ public:
void Load( CString sBGAniDir );
virtual void Update( float fDeltaTime );
virtual void UpdateInternal( float fDeltaTime );
virtual void StartTransitioning( ScreenMessage send_when_done = SM_None );
virtual bool EarlyAbortDraw();