add hibernate (don't draw or update) to Actor

This commit is contained in:
Chris Danford
2004-02-02 01:10:56 +00:00
parent 0bff292827
commit 5b791f603b
5 changed files with 30 additions and 6 deletions
+12
View File
@@ -55,6 +55,7 @@ void Actor::Reset()
m_bShadow = false;
m_fShadowLength = 4;
m_bIsAnimating = true;
m_fHibernateSecondsLeft = 0;
m_bTextureWrapping = false;
m_BlendMode = BLEND_NORMAL;
@@ -75,6 +76,8 @@ void Actor::Draw()
{
if( m_bHidden )
return; // early abort
if( m_fHibernateSecondsLeft > 0 )
return; // early abort
// call the most-derived versions
this->BeginDraw();
@@ -295,6 +298,12 @@ void Actor::Update( float fDeltaTime )
{
// LOG->Trace( "Actor::Update( %f )", fDeltaTime );
m_fHibernateSecondsLeft -= fDeltaTime;
m_fHibernateSecondsLeft = max( 0, m_fHibernateSecondsLeft );
if( m_fHibernateSecondsLeft > 0 )
return;
// update effect
switch( m_Effect )
{
@@ -816,6 +825,7 @@ void Actor::HandleCommand( const ParsedCommand &command )
else if( sName=="clearzbuffer" ) SetClearZBuffer( bParam(1) );
else if( sName=="backfacecull" ) SetUseBackfaceCull( bParam(1) );
else if( sName=="hidden" ) SetHidden( bParam(1) );
else if( sName=="hibernate" ) SetHibernate( fParam(1) );
else if( sName=="playcommand" ) PlayCommand( sParam(1) );
/* These are commands intended for a Sprite commands, but they will get
@@ -848,6 +858,8 @@ float Actor::GetTweenTimeLeft() const
{
float tot = 0;
tot += m_fHibernateSecondsLeft;
for( unsigned i=0; i<m_TweenInfo.size(); ++i )
tot += m_TweenInfo[i].m_fTimeLeftInTween;
+8 -5
View File
@@ -265,14 +265,16 @@ public:
//
// other properties
//
bool GetHidden() const { return m_bHidden; }
void SetHidden( bool b ) { m_bHidden = b; }
bool GetHidden() const { return m_bHidden; }
void SetHidden( bool b ) { m_bHidden = b; }
void SetShadowLength( float fLength );
void EnableShadow( bool b ) { m_bShadow = b; }
void EnableShadow( bool b ) { m_bShadow = b; }
// TODO: Implement hibernate as a tween type?
void SetHibernate( float fSecs ) { m_fHibernateSecondsLeft = fSecs; }
virtual void EnableAnimation( bool b ) { m_bIsAnimating = b; }
virtual void StartAnimating() { this->EnableAnimation(true); };
virtual void StopAnimating() { this->EnableAnimation(false); };
virtual void StartAnimating() { this->EnableAnimation(true); };
virtual void StopAnimating() { this->EnableAnimation(false); };
//
@@ -367,6 +369,7 @@ protected:
// other properties
//
bool m_bHidden;
float m_fHibernateSecondsLeft;
bool m_bShadow;
float m_fShadowLength;
bool m_bIsAnimating;
+4 -1
View File
@@ -77,6 +77,9 @@ void ActorFrame::Update( float fDeltaTime )
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
Actor::Update( fDeltaTime );
if( m_fHibernateSecondsLeft > 0 )
return;
// update all sub-Actors
for( vector<Actor*>::iterator it=m_SubActors.begin(); it!=m_SubActors.end(); it++ )
(*it)->Update(fDeltaTime);
@@ -121,7 +124,7 @@ float ActorFrame::GetTweenTimeLeft() const
float m = Actor::GetTweenTimeLeft();
for( unsigned i=0; i<m_SubActors.size(); i++ )
m = max(m, m_SubActors[i]->GetTweenTimeLeft());
m = max(m, m_fHibernateSecondsLeft + m_SubActors[i]->GetTweenTimeLeft());
return m;
+3
View File
@@ -55,6 +55,9 @@ void ActorScroller::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
if( m_fHibernateSecondsLeft > 0 )
return; // early abort
fapproach( m_fCurrentItem, m_fDestinationItem, fDeltaTime/m_fSecondsPerItem );
}
+3
View File
@@ -653,6 +653,9 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer )
void BGAnimationLayer::Update( float fDeltaTime )
{
if( m_fHibernateSecondsLeft > 0 )
return;
fDeltaTime *= m_fUpdateRate;
const float fSongBeat = GAMESTATE->m_fSongBeat;