Exemplo n.º 1
0
void C_SceneEntity::PostDataUpdate( DataUpdateType_t updateType )
{
	BaseClass::PostDataUpdate( updateType );

	char const *str = GetSceneFileName();

	if ( updateType == DATA_UPDATE_CREATED )
	{
		Assert( str && str[ 0 ] );
		if (  str && str[ 0 ] )
		{
			LoadSceneFromFile( str );

			// Kill everything except flex events
			Assert( m_pScene );
			if ( m_pScene )
			{
				int types[ 2 ];
				types[ 0 ] =  CChoreoEvent::FLEXANIMATION;
				types[ 1 ] =  CChoreoEvent::EXPRESSION;
				m_pScene->RemoveEventsExceptTypes( types, 2 );
			}

			SetNextClientThink( CLIENT_THINK_ALWAYS );
		}
	}

	// Playback state changed...
	if ( m_bWasPlaying != m_bIsPlayingBack )
	{
		for(int i = 0; i < m_hActorList.Count() ; ++i )
		{
			C_BaseFlex *actor = m_hActorList[ i ].Get();
			if ( !actor )
				continue;

			Assert( m_pScene );

			if ( m_pScene )
			{
				ClearSceneEvents( m_pScene, false );

				if ( m_bIsPlayingBack )
				{
					m_pScene->ResetSimulation();
					actor->StartChoreoScene( m_pScene );
				}
				else
				{
					m_pScene->ResetSimulation();
					actor->RemoveChoreoScene( m_pScene );
				}
			}
		}
	}
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_SceneEntity::UnloadScene( void )
{
	WipeQueuedEvents();

	if ( m_pScene )
	{
		ClearSceneEvents( m_pScene, false );
		for ( int i = 0 ; i < m_pScene->GetNumActors(); i++ )
		{
			C_BaseFlex *pTestActor = FindNamedActor( m_pScene->GetActor( i ) );

			if ( !pTestActor )
				continue;
		
			pTestActor->RemoveChoreoScene( m_pScene );
		}
	}
	delete m_pScene;
	m_pScene = NULL;
}
Exemplo n.º 3
0
void C_SceneEntity::PostDataUpdate( DataUpdateType_t updateType )
{
	BaseClass::PostDataUpdate( updateType );

	char const *str = GetSceneFileName();
	char szFilename[MAX_PATH];
	if ( str )
	{
		Assert( V_strlen( str ) < MAX_PATH );
		V_strcpy( szFilename, str );
	}
	else
	{
		szFilename[0] = '\0';
	}

	char szSceneHWM[MAX_PATH];
	if ( GetHWMorphSceneFileName( szFilename, szSceneHWM ) )
	{
		V_strcpy( szFilename, szSceneHWM );
	}

	if ( updateType == DATA_UPDATE_CREATED )
	{
		Assert( szFilename && szFilename[ 0 ] );
		if (  szFilename && szFilename[ 0 ] )
		{
			LoadSceneFromFile( szFilename );

			// Kill everything except flex events
			Assert( m_pScene );

			// Should handle gestures and sequences clientside.
			if ( m_bMultiplayer )
			{
				if ( m_pScene )
				{
					int types[6];
					types[0] = CChoreoEvent::FLEXANIMATION;
					types[1] = CChoreoEvent::EXPRESSION;
					types[2] = CChoreoEvent::GESTURE;
					types[3] = CChoreoEvent::SEQUENCE;				
					types[4] = CChoreoEvent::SPEAK;
					types[5] = CChoreoEvent::LOOP;
					m_pScene->RemoveEventsExceptTypes( types, 6 );
				}

				PrefetchAnimBlocks( m_pScene );
			}
			else
			{
				if ( m_pScene )
				{
					int types[ 2 ];
					types[ 0 ] =  CChoreoEvent::FLEXANIMATION;
					types[ 1 ] =  CChoreoEvent::EXPRESSION;
					m_pScene->RemoveEventsExceptTypes( types, 2 );
				}
			}

			SetNextClientThink( CLIENT_THINK_ALWAYS );
		}
	}

	// Playback state changed...
	if ( m_bWasPlaying != m_bIsPlayingBack )
	{
		for(int i = 0; i < m_hActorList.Count() ; ++i )
		{
			C_BaseFlex *actor = m_hActorList[ i ].Get();
			if ( !actor )
				continue;

			Assert( m_pScene );

			if ( m_pScene )
			{
				ClearSceneEvents( m_pScene, false );

				if ( m_bIsPlayingBack )
				{
					m_pScene->ResetSimulation();
					actor->StartChoreoScene( m_pScene );
				}
				else
				{
					m_pScene->ResetSimulation();
					actor->RemoveChoreoScene( m_pScene );
				}
			}
		}
	}
}
Exemplo n.º 4
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_SceneEntity::SetupClientOnlyScene( const char *pszFilename, C_BaseFlex *pOwner /* = NULL */, bool bMultiplayer /* = false */ )
{
	m_bIsPlayingBack = true;
	m_bMultiplayer = bMultiplayer;
	m_hOwner = pOwner;
	m_bClientOnly = true;

	char szFilename[128];
	Assert( V_strlen( pszFilename ) < 128 );
	V_strcpy( szFilename, pszFilename );

	char szSceneHWM[128];
	if ( GetHWMorphSceneFileName( szFilename, szSceneHWM ) )
	{
		V_strcpy( szFilename, szSceneHWM );
	}

	Assert( szFilename && szFilename[ 0 ] );
	if (  szFilename && szFilename[ 0 ] )
	{
		LoadSceneFromFile( szFilename );
		
		if (!CommandLine()->FindParm("-hushasserts"))
		{
			Assert( m_pScene );
		}

		// Should handle gestures and sequences client side.
		if ( m_bMultiplayer )
		{
			if ( m_pScene )
			{
				int types[6];
				types[0] = CChoreoEvent::FLEXANIMATION;
				types[1] = CChoreoEvent::EXPRESSION;
				types[2] = CChoreoEvent::GESTURE;
				types[3] = CChoreoEvent::SEQUENCE;
				types[4] = CChoreoEvent::SPEAK;
				types[5] = CChoreoEvent::LOOP;
				m_pScene->RemoveEventsExceptTypes( types, 6 );
			}

			PrefetchAnimBlocks( m_pScene );
		}
		else
		{
			if ( m_pScene )
			{
				int types[ 2 ];
				types[ 0 ] =  CChoreoEvent::FLEXANIMATION;
				types[ 1 ] =  CChoreoEvent::EXPRESSION;
				m_pScene->RemoveEventsExceptTypes( types, 2 );
			}
		}

		SetNextClientThink( CLIENT_THINK_ALWAYS );
	}

	if ( m_hOwner.Get() )
	{
		if (!CommandLine()->FindParm("-hushasserts"))
		{
			Assert( m_pScene );
		}

		if ( m_pScene )
		{
			ClearSceneEvents( m_pScene, false );

			if ( m_bIsPlayingBack )
			{
				m_pScene->ResetSimulation();
				m_hOwner->StartChoreoScene( m_pScene );
			}
			else
			{
				m_pScene->ResetSimulation();
				m_hOwner->RemoveChoreoScene( m_pScene );
			}

			// Reset the flex weights when we start a new scene.  This is normally done on the player model, but since
			// we don't have a player here yet - we need to do this!
			ResetActorFlexesForScene();
		}
	}
	else
	{
		for( int i = 0; i < m_hActorList.Count() ; ++i )
		{
			C_BaseFlex *actor = m_hActorList[ i ].Get();
			if ( !actor )
				continue;

			Assert( m_pScene );

			if ( m_pScene )
			{
				ClearSceneEvents( m_pScene, false );

				if ( m_bIsPlayingBack )
				{
					m_pScene->ResetSimulation();
					actor->StartChoreoScene( m_pScene );
				}
				else
				{
					m_pScene->ResetSimulation();
					actor->RemoveChoreoScene( m_pScene );
				}
			}
		}
	}
}