예제 #1
0
        public int readblock(byte[] blockdata, int offset)
        {
            BitPack input = new BitPack(blockdata, offset);
            mLocation = input.UnpackInt();
            mLength = input.UnpackInt();
            mAccessTime = input.UnpackInt();
            mFileID = input.UnpackUUID();
            int filetype = input.UnpackShort();
            mAssetType = (AssetType)filetype;
            mSize = input.UnpackInt();
            offset += 34;

            Logger.Log(String.Format("Found header for {0} type {1} length {2} at {3}", mFileID, mAssetType, mSize, mLocation), Helpers.LogLevel.Info);

            return offset;
        }
            /// <summary>
            /// Decodes a byte[] array into a ParticleSystem Object
            /// </summary>
            /// <param name="data">ParticleSystem object</param>
            /// <param name="pos">Start position for BitPacker</param>
            public ParticleSystem(byte[] data, int pos)
            {
                PartStartGlow   = 0f;
                PartEndGlow     = 0f;
                BlendFuncSource = (byte)BlendFunc.SourceAlpha;
                BlendFuncDest   = (byte)BlendFunc.OneMinusSourceAlpha;

                CRC               = PartFlags = 0;
                Pattern           = SourcePattern.None;
                MaxAge            = StartAge = InnerAngle = OuterAngle = BurstRate = BurstRadius = BurstSpeedMin =
                    BurstSpeedMax = 0.0f;
                BurstPartCount    = 0;
                AngularVelocity   = PartAcceleration = Vector3.Zero;
                Texture           = Target = UUID.Zero;
                PartDataFlags     = ParticleDataFlags.None;
                PartMaxAge        = 0.0f;
                PartStartColor    = PartEndColor = Color4.Black;
                PartStartScaleX   = PartStartScaleY = PartEndScaleX = PartEndScaleY = 0.0f;

                int     size = data.Length - pos;
                BitPack pack = new BitPack(data, pos);

                if (size == LegacyDataBlockSize)
                {
                    UnpackSystem(ref pack);
                    UnpackLegacyData(ref pack);
                }
                else if (size > LegacyDataBlockSize && size <= MaxDataBlockSize)
                {
                    int sysSize = pack.UnpackInt();
                    if (sysSize != SysDataSize)
                    {
                        return;                         // unkown particle system data size
                    }
                    UnpackSystem(ref pack);
                    int dataSize = pack.UnpackInt();
                    UnpackLegacyData(ref pack);

                    if ((PartDataFlags & ParticleDataFlags.DataGlow) == ParticleDataFlags.DataGlow)
                    {
                        if (pack.Data.Length - pack.BytePos < 2)
                        {
                            return;
                        }
                        uint glow = pack.UnpackByte();
                        PartStartGlow = glow / 255f;
                        glow          = pack.UnpackByte();
                        PartEndGlow   = glow / 255f;
                    }

                    if ((PartDataFlags & ParticleDataFlags.DataBlend) == ParticleDataFlags.DataBlend)
                    {
                        if (pack.Data.Length - pack.BytePos < 2)
                        {
                            return;
                        }
                        BlendFuncSource = pack.UnpackByte();
                        BlendFuncDest   = pack.UnpackByte();
                    }
                }
            }