move message helper stuff out of Actor into a new base class so that it can be used w/o deriving from Actor

This commit is contained in:
Chris Danford
2006-02-06 01:26:52 +00:00
parent b03b2dc768
commit a05d1e8265
4 changed files with 68 additions and 49 deletions
+3 -23
View File
@@ -89,7 +89,7 @@ void Actor::InitDefaults()
m_bZWrite = false;
m_CullMode = CULL_NONE;
UnsubcribeAndClearCommands();
UnsubscribeAll();
}
static bool GetMessageNameFromCommandName( const RString &sCommandName, RString &sMessageNameOut )
@@ -105,13 +105,6 @@ static bool GetMessageNameFromCommandName( const RString &sCommandName, RString
}
}
void Actor::UnsubcribeAndClearCommands()
{
FOREACH_CONST( RString, m_vsSubscribedTo, s )
MESSAGEMAN->Unsubscribe( this, *s );
m_vsSubscribedTo.clear();
}
Actor::Actor()
{
m_pLuaInstance = new LuaClass;
@@ -123,11 +116,11 @@ Actor::Actor()
Actor::~Actor()
{
StopTweening();
UnsubcribeAndClearCommands();
UnsubscribeAll();
}
Actor::Actor( const Actor &cpy ):
IMessageSubscriber( cpy )
MessageSubscriber( cpy )
{
/* Don't copy an Actor in the middle of rendering. */
ASSERT( cpy.m_pTempState == NULL );
@@ -183,7 +176,6 @@ Actor::Actor( const Actor &cpy ):
CPY( m_CullMode );
CPY( m_mapNameToCommands );
CPY( m_vsSubscribedTo );
#undef CPY
}
@@ -1278,18 +1270,6 @@ void Actor::HandleMessage( const RString& sMessage )
PlayCommand( sMessage );
}
void Actor::SubscribeToMessage( const RString &sMessageName )
{
MESSAGEMAN->Subscribe( this, sMessageName );
m_vsSubscribedTo.push_back( sMessageName );
}
void Actor::SubscribeToMessage( Message message )
{
MESSAGEMAN->Subscribe( this, message );
m_vsSubscribedTo.push_back( MessageToString(message) );
}
Actor::TweenInfo::TweenInfo()
{
m_pTween = NULL;