Ejemplo n.º 1
0
        private Asset CreateAssetWrapper(AssetType type)
        {
            Asset asset;

            switch (type)
            {
                case AssetType.Notecard:
                    asset = new AssetNotecard();
                    break;
                case AssetType.LSLText:
                    asset = new AssetScriptText();
                    break;
                case AssetType.LSLBytecode:
                    asset = new AssetScriptBinary();
                    break;
                case AssetType.Texture:
                    asset = new AssetTexture();
                    break;
                case AssetType.Object:
                    asset = new AssetPrim();
                    break;
                case AssetType.Clothing:
                    asset = new AssetClothing();
                    break;
                case AssetType.Bodypart:
                    asset = new AssetBodypart();
                    break;
                case AssetType.Animation:
                    asset = new AssetAnimation();
                    break;
                case AssetType.Sound:
                    asset = new AssetSound();
                    break;
                case AssetType.Landmark:
                    asset = new AssetLandmark();
                    break;
                case AssetType.Gesture:
                    asset = new AssetGesture();
                    break;
                default:
                    Logger.Log("Unimplemented asset type: " + type, Helpers.LogLevel.Error, Client);
                    return null;
            }

            return asset;
        }
Ejemplo n.º 2
0
        public static Asset CreateAssetWrapper(AssetType type, UUID uuid, byte[] data)
        {
            Asset asset;

            switch (type)
            {
                case AssetType.Animation:
                    asset = new AssetAnimation(uuid, data);
                    break;
                case AssetType.Gesture:
                    asset = new AssetGesture(uuid, data);
                    break;
                case AssetType.Landmark:
                    asset = new AssetLandmark(uuid, data);
                    break;
                case AssetType.Bodypart:
                    asset = new AssetBodypart(uuid, data);
                    break;
                case AssetType.Clothing:
                    asset = new AssetClothing(uuid, data);
                    break;
                case AssetType.LSLBytecode:
                    asset = new AssetScriptBinary(uuid, data);
                    break;
                case AssetType.LSLText:
                    asset = new AssetScriptText(uuid, data);
                    break;
                case AssetType.Notecard:
                    asset = new AssetNotecard(uuid, data);
                    break;
                case AssetType.Sound:
                    asset = new AssetSound(uuid, data);
                    break;
                case AssetType.Texture:
                    asset = new AssetTexture(uuid, data);
                    break;
#if COGBOT_LIBOMV
                    case AssetType.CallingCard:
                    asset = new AssetCallingCard(uuid, data);
                    break;
#endif
                default:
#if COGBOT_LIBOMV
                    asset = new AssetMutable(type, uuid, data);
                    Logger.Log("[OarFile] Not Implemented asset type " + type, Helpers.LogLevel.Error);
#else
                    throw new NotImplementedException("Unimplemented asset type: " + type);
#endif
                    break;
            }
            return asset;
        }
        private static bool LoadAsset(string assetPath, byte[] data, AssetLoadedCallback assetCallback, long bytesRead, long totalBytes)
        {
            // Right now we're nastily obtaining the UUID from the filename
            string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
            int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

            if (i == -1)
            {
                Logger.Log(String.Format(
                    "[OarFile]: Could not find extension information in asset path {0} since it's missing the separator {1}.  Skipping",
                    assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR), Helpers.LogLevel.Warning);
                return false;
            }

            string extension = filename.Substring(i);
            UUID uuid;
            UUID.TryParse(filename.Remove(filename.Length - extension.Length), out uuid);

            if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
            {
                AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
                Asset asset = null;

                switch (assetType)
                {
                    case AssetType.Animation:
                        asset = new AssetAnimation(uuid, data);
                        break;
                    case AssetType.Bodypart:
                        asset = new AssetBodypart(uuid, data);
                        break;
                    case AssetType.Clothing:
                        asset = new AssetClothing(uuid, data);
                        break;
                    case AssetType.Gesture:
                        asset = new AssetGesture(uuid, data);
                        break;
                    case AssetType.Landmark:
                        asset = new AssetLandmark(uuid, data);
                        break;
                    case AssetType.LSLBytecode:
                        asset = new AssetScriptBinary(uuid, data);
                        break;
                    case AssetType.LSLText:
                        asset = new AssetScriptText(uuid, data);
                        break;
                    case AssetType.Notecard:
                        asset = new AssetNotecard(uuid, data);
                        break;
                    case AssetType.Object:
                        asset = new AssetPrim(uuid, data);
                        break;
                    case AssetType.Sound:
                        asset = new AssetSound(uuid, data);
                        break;
                    case AssetType.Texture:
                        asset = new AssetTexture(uuid, data);
                        break;
                    default:
                        Logger.Log("[OarFile] Unhandled asset type " + assetType, Helpers.LogLevel.Error);
                        break;
                }

                if (asset != null)
                {
                    assetCallback(asset, bytesRead, totalBytes);
                    return true;
                }
            }

            Logger.Log("[OarFile] Failed to load asset", Helpers.LogLevel.Warning);
            return false;
        }
Ejemplo n.º 4
0
        public static Asset CreateAssetWrapper(AssetType type, UUID uuid, byte[] data)
        {
            Asset asset;

            switch (type)
            {
            case AssetType.Animation:
                asset = new AssetAnimation(uuid, data);
                break;

            case AssetType.Gesture:
                asset = new AssetGesture(uuid, data);
                break;

            case AssetType.Landmark:
                asset = new AssetLandmark(uuid, data);
                break;

            case AssetType.Bodypart:
                asset = new AssetBodypart(uuid, data);
                break;

            case AssetType.Clothing:
                asset = new AssetClothing(uuid, data);
                break;

            case AssetType.LSLBytecode:
                asset = new AssetScriptBinary(uuid, data);
                break;

            case AssetType.LSLText:
                asset = new AssetScriptText(uuid, data);
                break;

            case AssetType.Notecard:
                asset = new AssetNotecard(uuid, data);
                break;

            case AssetType.Sound:
                asset = new AssetSound(uuid, data);
                break;

            case AssetType.Texture:
                asset = new AssetTexture(uuid, data);
                break;

#if COGBOT_LIBOMV
            case AssetType.CallingCard:
                asset = new AssetCallingCard(uuid, data);
                break;
#endif
            default:
#if COGBOT_LIBOMV
                asset = new AssetMutable(type, uuid, data);
                Logger.Log("[OarFile] Not Implemented asset type " + type, Helpers.LogLevel.Error);
#else
                throw new NotImplementedException("Unimplemented asset type: " + type);
#endif
                break;
            }
            return(asset);
        }