Пример #1
0
/// Recursive function for resolving a package request.
///
/// @param[out] rspPackage   Resolved package.
/// @param[in]  packagePath  Package object path.
void CachePackageLoader::ResolvePackage( GameObjectPtr& rspPackage, GameObjectPath packagePath )
{
    HELIUM_ASSERT( !packagePath.IsEmpty() );

    rspPackage = GameObject::FindObject( packagePath );
    if( !rspPackage )
    {
        GameObjectPtr spParent;
        GameObjectPath parentPath = packagePath.GetParent();
        if( !parentPath.IsEmpty() )
        {
            ResolvePackage( spParent, parentPath );
            HELIUM_ASSERT( spParent );
        }

        HELIUM_VERIFY( GameObject::CreateObject(
            rspPackage,
            Package::GetStaticType(),
            packagePath.GetName(),
            spParent ) );
        HELIUM_ASSERT( rspPackage );
        HELIUM_ASSERT( rspPackage->IsClass( Package::GetStaticType()->GetClass() ) );
    }

    rspPackage->SetFlags( GameObject::FLAG_PRELOADED | GameObject::FLAG_LINKED | GameObject::FLAG_LOADED );
}
Пример #2
0
/// Find an object based on its path name.
///
/// @param[in] path  FilePath of the object to locate.
///
/// @return  Pointer to the object if found, null pointer if not found.
GameObject* GameObject::FindObject( GameObjectPath path )
{
    // Make sure the path isn't empty.
    if( path.IsEmpty() )
    {
        return NULL;
    }

    // Assemble a list of object names and instance indices, from the top level on down.
    size_t pathDepth = 0;
    size_t packageDepth = 0;
    for( GameObjectPath testPath = path; !testPath.IsEmpty(); testPath = testPath.GetParent() )
    {
        ++pathDepth;

        if( testPath.IsPackage() )
        {
            ++packageDepth;
        }
    }

    StackMemoryHeap<>& rStackHeap = ThreadLocalStackAllocator::GetMemoryHeap();
    StackMemoryHeap<>::Marker stackMarker( rStackHeap );

    Name* pPathNames = static_cast< Name* >( rStackHeap.Allocate( sizeof( Name ) * pathDepth ) );
    HELIUM_ASSERT( pPathNames );

    uint32_t* pInstanceIndices = static_cast< uint32_t* >( rStackHeap.Allocate( sizeof( uint32_t ) * pathDepth ) );
    HELIUM_ASSERT( pInstanceIndices );

    size_t pathIndex = pathDepth;
    for( GameObjectPath testPath = path; !testPath.IsEmpty(); testPath = testPath.GetParent() )
    {
        HELIUM_ASSERT( pathIndex != 0 );
        --pathIndex;

        pPathNames[ pathIndex ] = testPath.GetName();
        pInstanceIndices[ pathIndex ] = testPath.GetInstanceIndex();
    }

    HELIUM_ASSERT( pathIndex == 0 );

    // Search from the root.
    return FindChildOf( NULL, pPathNames, pInstanceIndices, pathDepth, packageDepth );
}
Пример #3
0
/// Initialize this manager.
///
/// @return  True if this manager was initialized successfully, false if not.
///
/// @see Shutdown()
bool WorldManager::Initialize()
{
    HELIUM_ASSERT( !m_spWorldPackage );

    // Create the world package first.
    // XXX TMC: Note that we currently assume that the world package has no parents, so we don't need to handle
    // recursive package creation.  If we want to move the world package to a subpackage, this will need to be
    // updated accordingly.
    GameObjectPath worldPackagePath = GetWorldPackagePath();
    HELIUM_ASSERT( !worldPackagePath.IsEmpty() );
    HELIUM_ASSERT( worldPackagePath.GetParent().IsEmpty() );
    bool bCreateResult = GameObject::Create< Package >( m_spWorldPackage, worldPackagePath.GetName(), NULL );
    HELIUM_ASSERT( bCreateResult );
    if( !bCreateResult )
    {
        HELIUM_TRACE(
            TRACE_ERROR,
            TXT( "WorldManager::Initialize(): Failed to create world package \"%s\".\n" ),
            *worldPackagePath.ToString() );

        return false;
    }

    HELIUM_ASSERT( m_spWorldPackage );

    // Reset frame timings.
    m_actualFrameTickCount = 0;
    m_frameTickCount = 0;
    m_frameDeltaTickCount = 0;
    m_frameDeltaSeconds = 0.0f;

    // First frame still needs to be processed.
    m_bProcessedFirstFrame = false;

    return true;
}