Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FontAsset"/> class.
        /// </summary>
        /// <param name="assetContentManager">
        /// The asset content manager.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="fontName">
        /// The font name.
        /// </param>
        /// <param name="fontSize">
        /// The font size.
        /// </param>
        /// <param name="useKerning">
        /// The use kerning.
        /// </param>
        /// <param name="spacing">
        /// The spacing.
        /// </param>
        /// <param name="data">
        /// The data.
        /// </param>
        public FontAsset(
            IAssetContentManager assetContentManager,
            string name,
            string fontName,
            int fontSize,
            bool useKerning,
            int spacing,
            PlatformData data)
        {
            this.Name                  = name;
            this.FontName              = fontName;
            this.FontSize              = fontSize;
            this.UseKerning            = useKerning;
            this.Spacing               = spacing;
            this.PlatformData          = data;
            this.m_AssetContentManager = assetContentManager;

            if (this.PlatformData != null)
            {
                try
                {
                    this.ReloadFont();
                }
                catch (NoAssetContentManagerException)
                {
                }
            }
        }
Example #2
0
        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="assetManager">
        /// The asset manager.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <returns>
        /// The <see cref="IAsset"/>.
        /// </returns>
        public IAsset Handle(IAssetManager assetManager, string name, IRawAsset data)
        {
            if (data.IsCompiled)
            {
                return(new AudioAsset(name, null, data.GetProperty <PlatformData>("PlatformData"), false));
            }

            PlatformData platformData = null;

            if (data.GetProperty <PlatformData>("PlatformData") != null)
            {
                platformData = new PlatformData
                {
                    Platform = data.GetProperty <PlatformData>("PlatformData").Platform,
                    Data     = data.GetProperty <PlatformData>("PlatformData").Data
                };
            }

            var audio = new AudioAsset(
                name,
                ByteReader.ReadAsByteArray(data.GetProperty <object>("RawData")),
                platformData,
                data.GetProperty <bool>("SourcedFromRaw"));

            return(audio);
        }
Example #3
0
        public IAsset Handle(IAssetManager assetManager, string name, IRawAsset data)
        {
            if (data is CompiledAsset)
            {
                return(new EffectAsset(_kernel, _assetContentManager, _rawLaunchArguments, name, null, data.GetProperty <PlatformData>("PlatformData"), false));
            }

            PlatformData platformData = null;

            if (data.GetProperty <PlatformData>("PlatformData") != null)
            {
                platformData = new PlatformData
                {
                    Platform = data.GetProperty <PlatformData>("PlatformData").Platform,
                    Data     = data.GetProperty <PlatformData>("PlatformData").Data
                };
            }

            var effect = new EffectAsset(
                _kernel,
                _assetContentManager,
                _rawLaunchArguments,
                name,
                data.GetProperty <string>("Code"),
                platformData,
                data.GetProperty <bool>("SourcedFromRaw"));

            return(effect);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ModelAsset"/> class.
        /// <para>
        /// This constructor is called by <see cref="ModelAssetLoader"/> when loading a model asset.
        /// </para>
        /// </summary>
        /// <param name="name">
        /// The name of the model asset.
        /// </param>
        /// <param name="rawData">
        /// The raw, serialized model data.
        /// </param>
        /// <param name="rawAdditionalAnimations">
        /// The source raw data that contains additional animations, mapping byte arrays to animation names.
        /// </param>
        /// <param name="data">
        /// The platform specific data.
        /// </param>
        /// <param name="sourcedFromRaw">
        /// Whether or not this asset was sourced from a purely raw asset file (such as a PNG).
        /// </param>
        /// <param name="extension">
        /// The appropriate file extension for this model.
        /// </param>
        public ModelAsset(
            string name,
            byte[] rawData,
            Dictionary <string, byte[]> rawAdditionalAnimations,
            PlatformData data,
            bool sourcedFromRaw,
            string extension)
        {
            this.Name    = name;
            this.RawData = rawData;
            this.RawAdditionalAnimations = rawAdditionalAnimations;
            this.PlatformData            = data;
            this.SourcedFromRaw          = sourcedFromRaw;
            this.Extension = extension;

            if (this.PlatformData != null)
            {
                try
                {
                    this.ReloadModel();
                }
                catch (NoAssetContentManagerException)
                {
                }
            }
        }
Example #5
0
        public UberEffectAsset(
            IKernel kernel,
            IAssetContentManager assetContentManager,
            IRawLaunchArguments rawLaunchArguments,
            string name,
            string code,
            PlatformData platformData,
            bool sourcedFromRaw)
        {
            Name                 = name;
            Code                 = code;
            PlatformData         = platformData;
            _kernel              = kernel;
            _assetContentManager = assetContentManager;
            _rawLaunchArguments  = rawLaunchArguments;
            SourcedFromRaw       = sourcedFromRaw;

            if (PlatformData != null)
            {
                try
                {
                    ReloadEffects();
                }
                catch (NoAssetContentManagerException)
                {
                }
            }
        }
        /// <summary>
        /// The write.
        /// </summary>
        /// <param name="compiledAsset">
        /// The compiled asset.
        /// </param>
        /// <param name="protoWriter">
        /// The proto writer.
        /// </param>
        private static void Write(CompiledAsset compiledAsset, ProtoWriter protoWriter)
        {
            if (compiledAsset.GetType() != typeof(CompiledAsset))
            {
                ThrowUnexpectedSubtype(typeof(CompiledAsset), compiledAsset.GetType());
            }

            string expr_2D = compiledAsset.Loader;

            if (expr_2D != null)
            {
                ProtoWriter.WriteFieldHeader(1, WireType.String, protoWriter);
                ProtoWriter.WriteString(expr_2D, protoWriter);
            }

            PlatformData expr_4A = compiledAsset.PlatformData;

            if (expr_4A != null)
            {
                ProtoWriter.WriteFieldHeader(3, WireType.String, protoWriter);
                SubItemToken token = ProtoWriter.StartSubItem(expr_4A, protoWriter);
                Write(expr_4A, protoWriter);
                ProtoWriter.EndSubItem(token, protoWriter);
            }
        }
        public UnifiedShaderAsset(
            IKernel kernel,
            IAssetContentManager assetContentManager,
            string name,
            string code,
            PlatformData platformData,
            bool sourcedFromRaw)
        {
            _kernel = kernel;
            _assetContentManager = assetContentManager;
            Name           = name;
            Code           = code;
            PlatformData   = platformData;
            SourcedFromRaw = sourcedFromRaw;

            if (this.PlatformData != null)
            {
                try
                {
                    this.ReloadEffect();
                }
                catch (NoAssetContentManagerException)
                {
                }
            }
        }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModelAsset"/> class.
 /// <para>
 /// This constructor is called by <see cref="ModelAssetLoader"/> when loading a model asset.
 /// </para>
 /// </summary>
 /// <param name="modelSerializer">
 ///     The model serializer service.
 /// </param>
 /// <param name="name">
 ///     The name of the model asset.
 /// </param>
 /// <param name="rawData">
 ///     The raw, serialized model data.
 /// </param>
 /// <param name="rawAdditionalAnimations">
 ///     The source raw data that contains additional animations, mapping byte arrays to animation names.
 /// </param>
 /// <param name="data">
 ///     The platform specific data.
 /// </param>
 /// <param name="sourcedFromRaw">
 ///     Whether or not this asset was sourced from a purely raw asset file (such as a PNG).
 /// </param>
 /// <param name="extension">
 ///     The appropriate file extension for this model.
 /// </param>
 /// <param name="importOptions"></param>
 public ModelAsset(IModelSerializer modelSerializer, string name, byte[] rawData, Dictionary <string, byte[]> rawAdditionalAnimations, PlatformData data, bool sourcedFromRaw, string extension, string[] importOptions)
 {
     _modelSerializer        = modelSerializer;
     Name                    = name;
     RawData                 = rawData;
     RawAdditionalAnimations = rawAdditionalAnimations;
     PlatformData            = data;
     SourcedFromRaw          = sourcedFromRaw;
     Extension               = extension;
     ImportOptions           = importOptions;
 }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AudioAsset"/> class.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="rawData">
        /// The raw data.
        /// </param>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <param name="sourcedFromRaw">
        /// The sourced from raw.
        /// </param>
        public AudioAsset(string name, byte[] rawData, PlatformData data, bool sourcedFromRaw)
        {
            this.Name           = name;
            this.RawData        = rawData;
            this.PlatformData   = data;
            this.SourcedFromRaw = sourcedFromRaw;

            if (this.PlatformData != null)
            {
                this.ReloadAudio();
            }
        }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextureAsset"/> class.
 /// <para>
 /// This constructor is called by <see cref="TextureAssetLoader"/> when loading a texture asset.
 /// </para>
 /// </summary>
 /// <param name="assetContentManager">
 /// The asset content manager used to create the MonoGame asset from the compiled data.
 /// </param>
 /// <param name="name">
 /// The name of the texture asset.
 /// </param>
 /// <param name="rawData">
 /// The raw data used for compilation, or null if there is no source information.
 /// </param>
 /// <param name="data">
 /// The platform-specific data used at runtime, or null if there is no compiled information.
 /// </param>
 /// <param name="sourcedFromRaw">
 /// Whether or not this asset was sourced from a purely raw asset file (such as a PNG).
 /// </param>
 public TextureAsset(
     IAssetContentManager assetContentManager,
     string name,
     byte[] rawData,
     PlatformData data,
     bool sourcedFromRaw)
 {
     this.Name                  = name;
     this.RawData               = rawData;
     this.PlatformData          = data;
     this.m_AssetContentManager = assetContentManager;
     this.SourcedFromRaw        = sourcedFromRaw;
 }
Example #11
0
        public TextureAtlasAsset(
            IAssetContentManager assetContentManager,
            string name,
            PlatformData data)
        {
            this.Name         = name;
            this.SourceOnly   = false;
            this.CompiledOnly = true;

            var memory = new MemoryStream(data.Data);

            using (var reader = new BinaryReader(memory))
            {
                var textureSize         = reader.ReadInt32();
                var texturePlatformData = reader.ReadBytes(textureSize);

                var textureAsset = new TextureAsset(
                    assetContentManager,
                    name,
                    null,
                    new PlatformData
                {
                    Platform = data.Platform,
                    Data     = texturePlatformData
                },
                    false);
                this.AtlasTexture = textureAsset;

                this.Mappings = new Dictionary <string, UVMapping>();
                var uvMappingCount = reader.ReadInt32();
                for (var i = 0; i < uvMappingCount; i++)
                {
                    var mappingName  = reader.ReadString();
                    var topLeftU     = reader.ReadSingle();
                    var topLeftV     = reader.ReadSingle();
                    var bottomRightU = reader.ReadSingle();
                    var bottomRightV = reader.ReadSingle();
                    this.Mappings.Add(
                        mappingName,
                        new UVMapping
                    {
                        TopLeft     = new Vector2(topLeftU, topLeftV),
                        BottomRight = new Vector2(bottomRightU, bottomRightV)
                    });
                }
            }
        }
Example #12
0
 public UberEffectAsset(
     IKernel kernel,
     IAssetContentManager assetContentManager,
     IRawLaunchArguments rawLaunchArguments,
     string name,
     string code,
     PlatformData platformData,
     bool sourcedFromRaw)
 {
     Name                 = name;
     Code                 = code;
     PlatformData         = platformData;
     _kernel              = kernel;
     _assetContentManager = assetContentManager;
     _rawLaunchArguments  = rawLaunchArguments;
     SourcedFromRaw       = sourcedFromRaw;
 }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextureAsset"/> class.
        /// <para>
        /// This constructor is called by <see cref="TextureAssetLoader"/> when loading a texture asset.
        /// </para>
        /// </summary>
        /// <param name="assetContentManager">
        /// The asset content manager used to create the MonoGame asset from the compiled data.
        /// </param>
        /// <param name="name">
        /// The name of the texture asset.
        /// </param>
        /// <param name="rawData">
        /// The raw data used for compilation, or null if there is no source information.
        /// </param>
        /// <param name="data">
        /// The platform-specific data used at runtime, or null if there is no compiled information.
        /// </param>
        /// <param name="sourcedFromRaw">
        /// Whether or not this asset was sourced from a purely raw asset file (such as a PNG).
        /// </param>
        public TextureAsset(
            IAssetContentManager assetContentManager,
            string name,
            byte[] rawData,
            PlatformData data,
            bool sourcedFromRaw)
        {
            this.Name                  = name;
            this.RawData               = rawData;
            this.PlatformData          = data;
            this.m_AssetContentManager = assetContentManager;
            this.SourcedFromRaw        = sourcedFromRaw;

            if (this.PlatformData != null)
            {
                try
                {
                    this.ReloadTexture();
                }
                catch (NoAssetContentManagerException)
                {
                }
            }
        }
Example #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EffectAsset"/> class.
        /// </summary>
        /// <param name="assetContentManager">
        /// The asset content manager.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="code">
        /// The code.
        /// </param>
        /// <param name="platformData">
        /// The platform data.
        /// </param>
        /// <param name="sourcedFromRaw">
        /// The sourced from raw.
        /// </param>
        public EffectAsset(
            IAssetContentManager assetContentManager,
            string name,
            string code,
            PlatformData platformData,
            bool sourcedFromRaw)
        {
            this.Name                  = name;
            this.Code                  = code;
            this.PlatformData          = platformData;
            this.m_AssetContentManager = assetContentManager;
            this.SourcedFromRaw        = sourcedFromRaw;

            if (this.PlatformData != null)
            {
                try
                {
                    this.ReloadEffect();
                }
                catch (NoAssetContentManagerException)
                {
                }
            }
        }
        /// <summary>
        /// The read.
        /// </summary>
        /// <param name="platformData">
        /// The platform data.
        /// </param>
        /// <param name="protoReader">
        /// The proto reader.
        /// </param>
        /// <returns>
        /// The <see cref="PlatformData"/>.
        /// </returns>
        private static PlatformData Read(PlatformData platformData, ProtoReader protoReader)
        {
            int num;

            while ((num = protoReader.ReadFieldHeader()) > 0)
            {
                if (num != 1)
                {
                    if (num != 2)
                    {
                        if (platformData == null)
                        {
                            var expr_164 = new PlatformData();
                            ProtoReader.NoteObject(expr_164, protoReader);
                            platformData = expr_164;
                        }

                        protoReader.SkipField();
                    }
                    else
                    {
                        if (platformData == null)
                        {
                            var expr_134 = new PlatformData();
                            ProtoReader.NoteObject(expr_134, protoReader);
                            platformData = expr_134;
                        }

                        byte[] array = ProtoReader.AppendBytes(platformData.Data, protoReader);
                        if (array != null)
                        {
                            platformData.Data = array;
                        }
                    }
                }
                else
                {
                    if (platformData == null)
                    {
                        var expr_19 = new PlatformData();
                        ProtoReader.NoteObject(expr_19, protoReader);
                        platformData = expr_19;
                    }

                    int num2           = protoReader.ReadInt32();
                    var targetPlatform = TargetPlatform.Windows;
                    if (num2 != 0)
                    {
                        if (num2 != 1)
                        {
                            if (num2 != 2)
                            {
                                if (num2 != 3)
                                {
                                    if (num2 != 4)
                                    {
                                        if (num2 != 5)
                                        {
                                            if (num2 != 6)
                                            {
                                                if (num2 != 7)
                                                {
                                                    if (num2 != 8)
                                                    {
                                                        if (num2 != 9)
                                                        {
                                                            if (num2 != 10)
                                                            {
                                                                if (num2 != 11)
                                                                {
                                                                    if (num2 != 12)
                                                                    {
                                                                        protoReader.ThrowEnumException(
                                                                            typeof(TargetPlatform),
                                                                            num2);
                                                                    }
                                                                    else
                                                                    {
                                                                        targetPlatform = TargetPlatform.RaspberryPi;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    targetPlatform = TargetPlatform.WindowsPhone8;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                targetPlatform = TargetPlatform.PlayStationMobile;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            targetPlatform = TargetPlatform.Ouya;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        targetPlatform = TargetPlatform.NativeClient;
                                                    }
                                                }
                                                else
                                                {
                                                    targetPlatform = TargetPlatform.WindowsStoreApp;
                                                }
                                            }
                                            else
                                            {
                                                targetPlatform = TargetPlatform.MacOSX;
                                            }
                                        }
                                        else
                                        {
                                            targetPlatform = TargetPlatform.Linux;
                                        }
                                    }
                                    else
                                    {
                                        targetPlatform = TargetPlatform.Android;
                                    }
                                }
                                else
                                {
                                    targetPlatform = TargetPlatform.iOS;
                                }
                            }
                            else
                            {
                                targetPlatform = TargetPlatform.WindowsPhone;
                            }
                        }
                        else
                        {
                            targetPlatform = TargetPlatform.Xbox360;
                        }
                    }
                    else
                    {
                        targetPlatform = TargetPlatform.Windows;
                    }

                    platformData.Platform = targetPlatform;
                }
            }

            if (platformData == null)
            {
                var expr_18C = new PlatformData();
                ProtoReader.NoteObject(expr_18C, protoReader);
                platformData = expr_18C;
            }

            return(platformData);
        }
        /// <summary>
        /// The read.
        /// </summary>
        /// <param name="compiledAsset">
        /// The compiled asset.
        /// </param>
        /// <param name="protoReader">
        /// The proto reader.
        /// </param>
        /// <returns>
        /// The <see cref="CompiledAsset"/>.
        /// </returns>
        private static CompiledAsset Read(CompiledAsset compiledAsset, ProtoReader protoReader)
        {
            int num;

            while ((num = protoReader.ReadFieldHeader()) > 0)
            {
                if (num != 1)
                {
                    if (num != 3)
                    {
                        if (compiledAsset == null)
                        {
                            var expr_8A = new CompiledAsset();
                            ProtoReader.NoteObject(expr_8A, protoReader);
                            compiledAsset = expr_8A;
                        }

                        protoReader.SkipField();
                    }
                    else
                    {
                        if (compiledAsset == null)
                        {
                            var expr_4C = new CompiledAsset();
                            ProtoReader.NoteObject(expr_4C, protoReader);
                            compiledAsset = expr_4C;
                        }

                        PlatformData arg_63_0 = compiledAsset.PlatformData;
                        SubItemToken token    = ProtoReader.StartSubItem(protoReader);
                        PlatformData arg_6F_0 = Read(arg_63_0, protoReader);
                        ProtoReader.EndSubItem(token, protoReader);
                        PlatformData platformData = arg_6F_0;
                        if (platformData != null)
                        {
                            compiledAsset.PlatformData = platformData;
                        }
                    }
                }
                else
                {
                    if (compiledAsset == null)
                    {
                        var expr_19 = new CompiledAsset();
                        ProtoReader.NoteObject(expr_19, protoReader);
                        compiledAsset = expr_19;
                    }

                    string text = protoReader.ReadString();
                    if (text != null)
                    {
                        compiledAsset.Loader = text;
                    }
                }
            }

            if (compiledAsset == null)
            {
                var expr_B2 = new CompiledAsset();
                ProtoReader.NoteObject(expr_B2, protoReader);
                compiledAsset = expr_B2;
            }

            return(compiledAsset);
        }
        /// <summary>
        /// The write.
        /// </summary>
        /// <param name="platformData">
        /// The platform data.
        /// </param>
        /// <param name="writer">
        /// The writer.
        /// </param>
        private static void Write(PlatformData platformData, ProtoWriter writer)
        {
            if (platformData.GetType() != typeof(PlatformData))
            {
                ThrowUnexpectedSubtype(typeof(PlatformData), platformData.GetType());
            }

            TargetPlatform expr_2D = platformData.Platform;

            if (expr_2D != TargetPlatform.Windows)
            {
                ProtoWriter.WriteFieldHeader(1, WireType.Variant, writer);
                TargetPlatform targetPlatform = expr_2D;
                if (targetPlatform != TargetPlatform.Windows)
                {
                    if (targetPlatform != TargetPlatform.Xbox360)
                    {
                        if (targetPlatform != TargetPlatform.WindowsPhone)
                        {
                            if (targetPlatform != TargetPlatform.iOS)
                            {
                                if (targetPlatform != TargetPlatform.Android)
                                {
                                    if (targetPlatform != TargetPlatform.Linux)
                                    {
                                        if (targetPlatform != TargetPlatform.MacOSX)
                                        {
                                            if (targetPlatform != TargetPlatform.WindowsStoreApp)
                                            {
                                                if (targetPlatform != TargetPlatform.NativeClient)
                                                {
                                                    if (targetPlatform != TargetPlatform.Ouya)
                                                    {
                                                        if (targetPlatform != TargetPlatform.PlayStationMobile)
                                                        {
                                                            if (targetPlatform != TargetPlatform.WindowsPhone8)
                                                            {
                                                                if (targetPlatform != TargetPlatform.RaspberryPi)
                                                                {
                                                                    ProtoWriter.ThrowEnumException(
                                                                        writer,
                                                                        targetPlatform);
                                                                }
                                                                else
                                                                {
                                                                    ProtoWriter.WriteInt32(12, writer);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                ProtoWriter.WriteInt32(11, writer);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ProtoWriter.WriteInt32(10, writer);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ProtoWriter.WriteInt32(9, writer);
                                                    }
                                                }
                                                else
                                                {
                                                    ProtoWriter.WriteInt32(8, writer);
                                                }
                                            }
                                            else
                                            {
                                                ProtoWriter.WriteInt32(7, writer);
                                            }
                                        }
                                        else
                                        {
                                            ProtoWriter.WriteInt32(6, writer);
                                        }
                                    }
                                    else
                                    {
                                        ProtoWriter.WriteInt32(5, writer);
                                    }
                                }
                                else
                                {
                                    ProtoWriter.WriteInt32(4, writer);
                                }
                            }
                            else
                            {
                                ProtoWriter.WriteInt32(3, writer);
                            }
                        }
                        else
                        {
                            ProtoWriter.WriteInt32(2, writer);
                        }
                    }
                    else
                    {
                        ProtoWriter.WriteInt32(1, writer);
                    }
                }
                else
                {
                    ProtoWriter.WriteInt32(0, writer);
                }
            }

            byte[] expr_143 = platformData.Data;
            if (expr_143 != null)
            {
                ProtoWriter.WriteFieldHeader(2, WireType.String, writer);
                ProtoWriter.WriteBytes(expr_143, writer);
            }
        }