add Actor::QueueCommand

This commit is contained in:
Chris Danford
2004-04-24 18:38:18 +00:00
parent 7cd77dc83a
commit 61ebde3f13
2 changed files with 30 additions and 1 deletions
+27 -1
View File
@@ -253,8 +253,15 @@ void Actor::UpdateTweening( float fDeltaTime )
TweenInfo &TI = m_TweenInfo[0]; // earliest tween
if( TI.m_fTimeLeftInTween == TI.m_fTweenTime ) // we are just beginning this tween
{
m_start = m_current; // set the start position
// Execute the command in this tween (if any).
const ParsedCommand &command = TS.command;
if( !command.vTokens.empty() )
this->HandleCommand( command );
}
float fSecsToSubtract = min( TI.m_fTimeLeftInTween, fDeltaTime );
TI.m_fTimeLeftInTween -= fSecsToSubtract;
fDeltaTime -= fSecsToSubtract;
@@ -636,7 +643,7 @@ void Actor::HandleCommand( const ParsedCommand &command )
const CString& sName = sParam(0);
// Commands that go in the tweening queue:
if ( sName=="sleep" ) { BeginTweening( fParam(1), TWEEN_LINEAR ); BeginTweening( 0, TWEEN_LINEAR ); }
if ( sName=="sleep" ) Sleep( fParam(1) );
else if( sName=="linear" ) BeginTweening( fParam(1), TWEEN_LINEAR );
else if( sName=="accelerate" ) BeginTweening( fParam(1), TWEEN_ACCELERATE );
else if( sName=="decelerate" ) BeginTweening( fParam(1), TWEEN_DECELERATE );
@@ -729,6 +736,13 @@ void Actor::HandleCommand( const ParsedCommand &command )
else if( sName=="hidden" ) SetHidden( bParam(1) );
else if( sName=="hibernate" ) SetHibernate( fParam(1) );
else if( sName=="playcommand" ) PlayCommand( sParam(1) );
else if( sName=="queuecommand" )
{
ParsedCommand newcommand = command;
newcommand.vTokens.erase( newcommand.vTokens.begin() );
QueueCommand( newcommand );
return; // don't to parameter number checking
}
/* These are commands intended for a Sprite commands, but they will get
* sent to all sub-actors (which aren't necessarily Sprites) on
@@ -875,3 +889,15 @@ void Actor::CopyTweening( const Actor &from )
m_TweenStates = from.m_TweenStates;
m_TweenInfo = from.m_TweenInfo;
}
void Actor::Sleep( float time )
{
BeginTweening( time, TWEEN_LINEAR );
BeginTweening( 0, TWEEN_LINEAR );
}
void Actor::QueueCommand( ParsedCommand command )
{
BeginTweening( 0, TWEEN_LINEAR );
DestTweenState().command = command;
}
+3
View File
@@ -51,6 +51,7 @@ public:
RageColor diffuse[4];
RageColor glow;
GlowMode glowmode;
ParsedCommand command; // command to execute when this
void Init();
static void MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween );
@@ -181,6 +182,8 @@ public:
void BeginTweening( float time, TweenType tt = TWEEN_LINEAR );
void StopTweening();
void Sleep( float time );
void QueueCommand( ParsedCommand command );
virtual void FinishTweening();
virtual void HurryTweening( float factor );
// Let ActorFrame and BGAnimation override