let Actors store commands

This commit is contained in:
Chris Danford
2005-01-04 10:41:32 +00:00
parent 32bb778e22
commit a3b49485b5
2 changed files with 35 additions and 8 deletions
+25 -4
View File
@@ -52,6 +52,8 @@ void Actor::Reset()
m_ZTestMode = ZTEST_OFF;
m_bZWrite = false;
m_CullMode = CULL_NONE;
m_mapNameToCommands.clear();
}
Actor::Actor()
@@ -623,9 +625,16 @@ void Actor::AddRotationR( float rot )
RageQuatMultiply( &DestTweenState().quat, DestTweenState().quat, RageQuatFromR(rot) );
}
void Actor::RunCommands( const Commands &vCommands )
void Actor::AddCommands( const CString sName, const Commands &cmds )
{
FOREACH_CONST( Command, vCommands.v, c )
CString sKey = sName;
sKey.MakeLower();
m_mapNameToCommands[sKey] = cmds;
}
void Actor::RunCommands( const Commands &cmds )
{
FOREACH_CONST( Command, cmds.v, c )
this->HandleCommand( *c );
}
@@ -768,10 +777,10 @@ void Actor::HandleCommand( const Command &command )
EndHandleArgs;
}
float Actor::GetCommandsLengthSeconds( const Commands &vCommands )
float Actor::GetCommandsLengthSeconds( const Commands &cmds )
{
Actor temp;
temp.RunCommands(vCommands);
temp.RunCommands(cmds);
return temp.GetTweenTimeLeft();
}
@@ -913,6 +922,18 @@ void Actor::QueueCommand( Command command )
DestTweenState().command = command;
}
void Actor::PlayCommand( const CString &sCommandName )
{
CString sKey = sCommandName;
sKey.MakeLower();
map<CString, Commands>::const_iterator it = m_mapNameToCommands.find( sKey );
if( it == m_mapNameToCommands.end() )
return;
RunCommands( it->second );
}
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
+10 -4
View File
@@ -6,6 +6,7 @@
#include "RageTypes.h"
#include "Command.h"
#include <deque>
#include <map>
#define DRAW_ORDER_BEFORE_EVERYTHING -100
#define DRAW_ORDER_TRANSITIONS 100
@@ -303,9 +304,10 @@ public:
//
// Commands
//
void RunCommands( const Commands &vCommands );
void AddCommands( const CString sName, const Commands &cmds );
void RunCommands( const Commands &cmds );
virtual void HandleCommand( const Command &command ); // derivable
static float GetCommandsLengthSeconds( const Commands &vCommands );
static float GetCommandsLengthSeconds( const Commands &cmds );
//
// Animation
@@ -320,8 +322,7 @@ public:
//
virtual void GainFocus( float fRate, bool bRewindMovie, bool bLoop ) {}
virtual void LoseFocus() {}
virtual void PlayCommand( const CString &sCommandName ) {}
virtual void PlayOffCommand( const CString &sCommandName ) {}
virtual void PlayCommand( const CString &sCommandName );
protected:
@@ -403,6 +404,11 @@ protected:
// global state
//
static float g_fCurrentBGMTime, g_fCurrentBGMBeat;
//
// commands
//
map<CString, Commands> m_mapNameToCommands;
};
#endif