Universe.Framework.SceneInfo.UuidGatherer.GatherAssetUuids C# (CSharp) Method

GatherAssetUuids() public method

Gather all the asset uuids associated with the asset referenced by a given uuid
public GatherAssetUuids ( UUID assetUuid, AssetType assetType, AssetType>.IDictionary assetUuids ) : void
assetUuid UUID The uuid of the asset for which to gather referenced assets
assetType AssetType The type of the asset for the uuid given
assetUuids AssetType>.IDictionary The assets gathered
return void
        public void GatherAssetUuids (UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids)
        {
            // avoid infinite loops
            if (assetUuids.ContainsKey (assetUuid))
                return;

            assetUuids [assetUuid] = assetType;

            switch (assetType) {
            case AssetType.Clothing:
            case AssetType.Bodypart:
                GetWearableAssetUuids (assetUuid, assetUuids);
                break;
            case AssetType.Gesture:
                GetGestureAssetUuids (assetUuid, assetUuids);
                break;
            case AssetType.LSLText:
                GetScriptAssetUuids (assetUuid, assetUuids);
                break;
            case AssetType.Object:
                GetSceneObjectAssetUuids (assetUuid, assetUuids);
                break;
            }
        }

Same methods

UuidGatherer::GatherAssetUuids ( ISceneEntity sceneObject, AssetType>.IDictionary assetUuids ) : void

Usage Example

        /// <summary>
        ///     Archive the region requested.
        /// </summary>
        /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
        public void ArchiveRegion()
        {
            Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();

            ISceneEntity[] entities = m_scene.Entities.GetEntities();
            List<ISceneEntity> sceneObjects = new List<ISceneEntity>();
            int numObjectsSkippedPermissions = 0;

            // Filter entities so that we only have scene objects.
            // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
            // end up having to do this
            foreach (ISceneEntity entity in entities.Where(entity => !entity.IsDeleted && !entity.IsAttachment))
            {
                if (!CanUserArchiveObject(m_scene.RegionInfo.EstateSettings.EstateOwner, entity, m_checkPermissions))
                    // The user isn't allowed to copy/transfer this object, so it will not be included in the OAR.
                    ++numObjectsSkippedPermissions;
                else
                    sceneObjects.Add(entity);
            }

            UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);

            foreach (ISceneEntity sceneObject in sceneObjects)
            {
                assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
            }

            MainConsole.Instance.InfoFormat(
                "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
                sceneObjects.Count, assetUuids.Count);

            if (numObjectsSkippedPermissions > 0)
            {
                MainConsole.Instance.DebugFormat(
                    "[ARCHIVER]: {0} scene objects skipped due to lack of permissions",
                    numObjectsSkippedPermissions);
            }

            // Make sure that we also request terrain texture assets
            RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;

            if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
                assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;

            if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
                assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;

            if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
                assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;

            if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
                assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;

            TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);

            // Asynchronously request all the assets required to perform this archive operation
            ArchiveWriteRequestExecution awre
                = new ArchiveWriteRequestExecution(
                    sceneObjects,
                    m_scene.RequestModuleInterface<ITerrainModule>(),
                    m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
                    m_scene,
                    archiveWriter,
                    m_requestId);

            new AssetsRequest(
                new AssetsArchiver(archiveWriter), assetUuids,
                m_scene.AssetService, awre.ReceivedAllAssets).Execute();
        }
All Usage Examples Of Universe.Framework.SceneInfo.UuidGatherer::GatherAssetUuids