Пример #1
0
        public XmlConfigTransformDefinition(string definition)
        {
            if (definition.Contains("=>"))
            {
                Advanced = true;
                var separators = new[] { "=>" };
                var parts      = definition.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                TransformPattern = parts[0].Trim();
                SourcePattern    = parts[1].Trim();

                if (TransformPattern.StartsWith("*."))
                {
                    Wildcard         = true;
                    TransformPattern = TransformPattern.Remove(0, 2);
                }

                if (SourcePattern.StartsWith("*."))
                {
                    Wildcard      = true;
                    SourcePattern = SourcePattern.Remove(0, 2);
                }
            }
            else
            {
                TransformPattern = definition;
            }
        }
            void UnpackSystem(ref BitPack pack)
            {
                CRC            = pack.UnpackUInt();
                PartFlags      = pack.UnpackUInt();
                Pattern        = (SourcePattern)pack.UnpackByte();
                MaxAge         = pack.UnpackFixed(false, 8, 8);
                StartAge       = pack.UnpackFixed(false, 8, 8);
                InnerAngle     = pack.UnpackFixed(false, 3, 5);
                OuterAngle     = pack.UnpackFixed(false, 3, 5);
                BurstRate      = pack.UnpackFixed(false, 8, 8);
                BurstRadius    = pack.UnpackFixed(false, 8, 8);
                BurstSpeedMin  = pack.UnpackFixed(false, 8, 8);
                BurstSpeedMax  = pack.UnpackFixed(false, 8, 8);
                BurstPartCount = pack.UnpackByte();
                float x = pack.UnpackFixed(true, 8, 7);
                float y = pack.UnpackFixed(true, 8, 7);
                float z = pack.UnpackFixed(true, 8, 7);

                AngularVelocity = new Vector3(x, y, z);
                x = pack.UnpackFixed(true, 8, 7);
                y = pack.UnpackFixed(true, 8, 7);
                z = pack.UnpackFixed(true, 8, 7);
                PartAcceleration = new Vector3(x, y, z);
                Texture          = pack.UnpackUUID();
                Target           = pack.UnpackUUID();
            }
Пример #3
0
        private void UnpackSystem(BitPacker pack)
        {
            CRC            = pack.UnpackUnsignedBits(32);
            PartFlags      = pack.UnpackUnsignedBits(32);
            Pattern        = (SourcePattern)pack.ByteValue;
            MaxAge         = pack.UnpackFixed(false, 8, 8);
            StartAge       = pack.UnpackFixed(false, 8, 8);
            InnerAngle     = pack.UnpackFixed(false, 3, 5);
            OuterAngle     = pack.UnpackFixed(false, 3, 5);
            BurstRate      = pack.UnpackFixed(false, 8, 8);
            BurstRadius    = pack.UnpackFixed(false, 8, 8);
            BurstSpeedMin  = pack.UnpackFixed(false, 8, 8);
            BurstSpeedMax  = pack.UnpackFixed(false, 8, 8);
            BurstPartCount = pack.ByteValue;
            float x = pack.UnpackFixed(true, 8, 7);
            float y = pack.UnpackFixed(true, 8, 7);
            float z = pack.UnpackFixed(true, 8, 7);

            AngularVelocity = new Vector3(x, y, z);
            x = pack.UnpackFixed(true, 8, 7);
            y = pack.UnpackFixed(true, 8, 7);
            z = pack.UnpackFixed(true, 8, 7);
            PartAcceleration = new Vector3(x, y, z);
            Texture          = pack.UuidValue;
            Target           = pack.UuidValue;
        }
Пример #4
0
 public override bool IsValid(out string error)
 {
     error = null;
     if (string.IsNullOrEmpty(SourcePattern) || string.IsNullOrEmpty(DeployTarget))
     {
         error = ToStringDescription() + " : The source .pl pattern or relative path in the .pl is empty";
         return(false);
     }
     if (Step < 2)
     {
         error = ToStringDescription() + " : The DeleteInProlib rule can only applied to steps >= 1 for safety reasons";
         return(false);
     }
     if (!SourcePattern.EndsWith(ArchiveExt))
     {
         error = ToStringDescription() + " : The rule has an incorrect source pattern, it should end with the extension " + ArchiveExt;
         return(false);
     }
     return(true);
 }
Пример #5
0
            /// <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)
            {
                // TODO: Not sure exactly how many bytes we need here, so partial
                // (truncated) data will cause an exception to be thrown
                if (data.Length > 0)
                {
                    BitPack pack = new BitPack(data, pos);

                    CRC            = pack.UnpackUBits(32);
                    PartFlags      = pack.UnpackUBits(32);
                    Pattern        = (SourcePattern)pack.UnpackByte();
                    MaxAge         = pack.UnpackFixed(false, 8, 8);
                    StartAge       = pack.UnpackFixed(false, 8, 8);
                    InnerAngle     = pack.UnpackFixed(false, 3, 5);
                    OuterAngle     = pack.UnpackFixed(false, 3, 5);
                    BurstRate      = pack.UnpackFixed(false, 8, 8);
                    BurstRadius    = pack.UnpackFixed(false, 8, 8);
                    BurstSpeedMin  = pack.UnpackFixed(false, 8, 8);
                    BurstSpeedMax  = pack.UnpackFixed(false, 8, 8);
                    BurstPartCount = pack.UnpackByte();
                    float x = pack.UnpackFixed(true, 8, 7);
                    float y = pack.UnpackFixed(true, 8, 7);
                    float z = pack.UnpackFixed(true, 8, 7);
                    AngularVelocity = new Vector3(x, y, z);
                    x = pack.UnpackFixed(true, 8, 7);
                    y = pack.UnpackFixed(true, 8, 7);
                    z = pack.UnpackFixed(true, 8, 7);
                    PartAcceleration = new Vector3(x, y, z);
                    Texture          = pack.UnpackUUID();
                    Target           = pack.UnpackUUID();

                    PartDataFlags = (ParticleDataFlags)pack.UnpackUBits(32);
                    PartMaxAge    = pack.UnpackFixed(false, 8, 8);
                    byte r = pack.UnpackByte();
                    byte g = pack.UnpackByte();
                    byte b = pack.UnpackByte();
                    byte a = pack.UnpackByte();
                    PartStartColor = new Color4(r, g, b, a);
                    r               = pack.UnpackByte();
                    g               = pack.UnpackByte();
                    b               = pack.UnpackByte();
                    a               = pack.UnpackByte();
                    PartEndColor    = new Color4(r, g, b, a);
                    PartStartScaleX = pack.UnpackFixed(false, 3, 5);
                    PartStartScaleY = pack.UnpackFixed(false, 3, 5);
                    PartEndScaleX   = pack.UnpackFixed(false, 3, 5);
                    PartEndScaleY   = pack.UnpackFixed(false, 3, 5);
                }
                else
                {
                    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;
                }
            }
Пример #6
0
            /// <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)
            {
                // TODO: Not sure exactly how many bytes we need here, so partial
                // (truncated) data will cause an exception to be thrown
                if (data.Length > 0)
                {
                    BitPack pack = new BitPack(data, pos);

                    CRC = pack.UnpackUBits(32);
                    PartFlags = pack.UnpackUBits(32);
                    Pattern = (SourcePattern)pack.UnpackByte();
                    MaxAge = pack.UnpackFixed(false, 8, 8);
                    StartAge = pack.UnpackFixed(false, 8, 8);
                    InnerAngle = pack.UnpackFixed(false, 3, 5);
                    OuterAngle = pack.UnpackFixed(false, 3, 5);
                    BurstRate = pack.UnpackFixed(false, 8, 8);
                    BurstRadius = pack.UnpackFixed(false, 8, 8);
                    BurstSpeedMin = pack.UnpackFixed(false, 8, 8);
                    BurstSpeedMax = pack.UnpackFixed(false, 8, 8);
                    BurstPartCount = pack.UnpackByte();
                    float x = pack.UnpackFixed(true, 8, 7);
                    float y = pack.UnpackFixed(true, 8, 7);
                    float z = pack.UnpackFixed(true, 8, 7);
                    AngularVelocity = new Vector3(x, y, z);
                    x = pack.UnpackFixed(true, 8, 7);
                    y = pack.UnpackFixed(true, 8, 7);
                    z = pack.UnpackFixed(true, 8, 7);
                    PartAcceleration = new Vector3(x, y, z);
                    Texture = pack.UnpackUUID();
                    Target = pack.UnpackUUID();

                    PartDataFlags = (ParticleDataFlags)pack.UnpackUBits(32);
                    PartMaxAge = pack.UnpackFixed(false, 8, 8);
                    byte r = pack.UnpackByte();
                    byte g = pack.UnpackByte();
                    byte b = pack.UnpackByte();
                    byte a = pack.UnpackByte();
                    PartStartColor = new Color4(r, g, b, a);
                    r = pack.UnpackByte();
                    g = pack.UnpackByte();
                    b = pack.UnpackByte();
                    a = pack.UnpackByte();
                    PartEndColor = new Color4(r, g, b, a);
                    PartStartScaleX = pack.UnpackFixed(false, 3, 5);
                    PartStartScaleY = pack.UnpackFixed(false, 3, 5);
                    PartEndScaleX = pack.UnpackFixed(false, 3, 5);
                    PartEndScaleY = pack.UnpackFixed(false, 3, 5);
                }
                else
                {
                    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;
                }
            }
Пример #7
0
        /// <summary>
        /// Creates a file mapping between a set of source patterns and a target pattern. All patterns should have a matching order and number of wildcards.
        /// </summary>
        /// <param name="Files">Files to use for the mapping</param>
        /// <param name="SourcePatterns">List of source patterns</param>
        /// <param name="TargetPattern">Matching output pattern</param>
        /// <param name="Filter">Filter to apply to source files</param>
        /// <param name="TargetFileToSourceFile">Dictionary to receive a mapping from target file to source file. An exception is thrown if multiple source files map to one target file, or a source file is also used as a target file.</param>
        public static bool TryCreateMapping(HashSet <FileReference> Files, FilePattern SourcePattern, FilePattern TargetPattern, out Dictionary <FileReference, FileReference> OutTargetFileToSourceFile)
        {
            bool bResult = true;

            // If the source pattern ends in a directory separator, or a set of input files are specified and it doesn't contain wildcards, treat it as a full directory match
            if (SourcePattern.EndsWithDirectorySeparator())
            {
                SourcePattern = new FilePattern(SourcePattern.BaseDirectory, String.Join("", SourcePattern.Tokens) + "...");
            }
            else if (Files != null)
            {
                SourcePattern = SourcePattern.AsDirectoryPattern();
            }

            // If we have multiple potential source files, but no wildcards in the output pattern, assume it's a directory and append the pattern from the source.
            if (SourcePattern.ContainsWildcards() && !TargetPattern.ContainsWildcards())
            {
                StringBuilder NewPattern = new StringBuilder();
                foreach (string Token in TargetPattern.Tokens)
                {
                    NewPattern.Append(Token);
                }
                if (NewPattern.Length > 0 && NewPattern[NewPattern.Length - 1] != Path.DirectorySeparatorChar)
                {
                    NewPattern.Append(Path.DirectorySeparatorChar);
                }
                foreach (string Token in SourcePattern.Tokens)
                {
                    NewPattern.Append(Token);
                }
                TargetPattern = new FilePattern(TargetPattern.BaseDirectory, NewPattern.ToString());
            }

            // If the target pattern ends with a directory separator, treat it as a full directory match if it has wildcards, or a copy of the source pattern if not
            if (TargetPattern.EndsWithDirectorySeparator())
            {
                TargetPattern = new FilePattern(TargetPattern.BaseDirectory, String.Join("", TargetPattern.Tokens) + "...");
            }

            // Handle the case where source and target pattern are both individual files
            Dictionary <FileReference, FileReference> TargetFileToSourceFile = new Dictionary <FileReference, FileReference>();

            if (SourcePattern.ContainsWildcards() || TargetPattern.ContainsWildcards())
            {
                // Check the two patterns are compatible
                if (!SourcePattern.IsCompatibleWith(TargetPattern))
                {
                    CommandUtils.LogError("File patterns '{0}' and '{1}' do not have matching wildcards", SourcePattern, TargetPattern);
                    OutTargetFileToSourceFile = null;
                    return(false);
                }

                // Create a filter to match the source files
                FileFilter Filter = new FileFilter(FileFilterType.Exclude);
                Filter.Include(String.Join("", SourcePattern.Tokens));

                // Apply it to the source directory
                List <FileReference> SourceFiles;
                if (Files == null)
                {
                    SourceFiles = Filter.ApplyToDirectory(SourcePattern.BaseDirectory, true);
                }
                else
                {
                    SourceFiles = CheckInputFiles(Files, SourcePattern.BaseDirectory, ref bResult);
                }

                // Map them onto output files
                FileReference[] TargetFiles = new FileReference[SourceFiles.Count];

                // Get the source and target regexes
                string SourceRegex = SourcePattern.GetRegexPattern();
                string TargetRegex = TargetPattern.GetRegexReplacementPattern();
                for (int Idx = 0; Idx < SourceFiles.Count; Idx++)
                {
                    string SourceRelativePath = SourceFiles[Idx].MakeRelativeTo(SourcePattern.BaseDirectory);
                    string TargetRelativePath = Regex.Replace(SourceRelativePath, SourceRegex, TargetRegex);
                    TargetFiles[Idx] = FileReference.Combine(TargetPattern.BaseDirectory, TargetRelativePath);
                }

                // Add them to the output map
                for (int Idx = 0; Idx < TargetFiles.Length; Idx++)
                {
                    FileReference ExistingSourceFile;
                    if (TargetFileToSourceFile.TryGetValue(TargetFiles[Idx], out ExistingSourceFile) && ExistingSourceFile != SourceFiles[Idx])
                    {
                        CommandUtils.LogError("Output file '{0}' is mapped from '{1}' and '{2}'", TargetFiles[Idx], ExistingSourceFile, SourceFiles[Idx]);
                        bResult = false;
                    }
                    TargetFileToSourceFile[TargetFiles[Idx]] = SourceFiles[Idx];
                }
            }
            else
            {
                // Just copy a single file
                FileReference SourceFile = SourcePattern.GetSingleFile();
                if (SourceFile.Exists())
                {
                    FileReference TargetFile = TargetPattern.GetSingleFile();
                    TargetFileToSourceFile[TargetFile] = SourceFile;
                }
                else
                {
                    CommandUtils.LogError("Source file '{0}' does not exist", SourceFile);
                    bResult = false;
                }
            }

            // Check that no source file is also destination file
            foreach (FileReference SourceFile in TargetFileToSourceFile.Values)
            {
                if (TargetFileToSourceFile.ContainsKey(SourceFile))
                {
                    CommandUtils.LogError("'{0}' is listed as a source and target file", SourceFile);
                    bResult = false;
                }
            }

            // Set the output map
            if (bResult)
            {
                OutTargetFileToSourceFile = TargetFileToSourceFile;
                return(true);
            }
            else
            {
                OutTargetFileToSourceFile = null;
                return(false);
            }
        }
Пример #8
0
 void UnpackSystem(ref BitPack pack)
 {
     CRC = pack.UnpackUBits(32);
     PartFlags = pack.UnpackUBits(32);
     Pattern = (SourcePattern)pack.UnpackByte();
     MaxAge = pack.UnpackFixed(false, 8, 8);
     StartAge = pack.UnpackFixed(false, 8, 8);
     InnerAngle = pack.UnpackFixed(false, 3, 5);
     OuterAngle = pack.UnpackFixed(false, 3, 5);
     BurstRate = pack.UnpackFixed(false, 8, 8);
     BurstRadius = pack.UnpackFixed(false, 8, 8);
     BurstSpeedMin = pack.UnpackFixed(false, 8, 8);
     BurstSpeedMax = pack.UnpackFixed(false, 8, 8);
     BurstPartCount = pack.UnpackByte();
     float x = pack.UnpackFixed(true, 8, 7);
     float y = pack.UnpackFixed(true, 8, 7);
     float z = pack.UnpackFixed(true, 8, 7);
     AngularVelocity = new Vector3(x, y, z);
     x = pack.UnpackFixed(true, 8, 7);
     y = pack.UnpackFixed(true, 8, 7);
     z = pack.UnpackFixed(true, 8, 7);
     PartAcceleration = new Vector3(x, y, z);
     Texture = pack.UnpackUUID();
     Target = pack.UnpackUUID();
 }
Пример #9
0
            /// <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.UnpackBits(32);
                    if (sysSize != SysDataSize) return; // unkown particle system data size
                    UnpackSystem(ref pack);
                    int dataSize = pack.UnpackBits(32);
                    UnpackLegacyData(ref pack);

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

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

                }
            }
            /// <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();
                    }
                }
            }
Пример #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <param name="pos"></param>
        private void FromBytes(byte[] data, int pos)
        {
            int i = pos;

            if (data.Length == 0)
            {
                return;
            }

            Serial = (uint)(data[i++] + (data[i++] << 8) +
                            (data[i++] << 16) + (data[i++] << 24));

            StartTick = (uint)(data[i++] + (data[i++] << 8) +
                               (data[i++] << 16) + (data[i++] << 24));

            SrcPattern = (SourcePattern)data[i++];

            SrcMaxAge = (data[i++] + (data[i++] << 8)) / 256.0f;

            // TODO: Unknown
            i += 2;

            SrcAngleBegin = (data[i++] / 100.0f) * (float)Math.PI;
            SrcAngleEnd   = (data[i++] / 100.0f) * (float)Math.PI;

            SrcBurstRate      = (data[i++] + (data[i++] << 8)) / 256.0f;
            SrcBurstRadius    = (data[i++] + (data[i++] << 8)) / 256.0f;
            SrcBurstSpeedMin  = (data[i++] + (data[i++] << 8)) / 256.0f;
            SrcBurstSpeedMax  = (data[i++] + (data[i++] << 8)) / 256.0f;
            SrcBurstPartCount = data[i++];

            SrcOmega   = new LLVector3();
            SrcOmega.X = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;
            SrcOmega.Y = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;
            SrcOmega.Z = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;

            SrcAccel   = new LLVector3();
            SrcAccel.X = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;
            SrcAccel.Y = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;
            SrcAccel.Z = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;

            SrcTexture   = new LLUUID(data, i);
            i           += 16;
            SrcTargetKey = new LLUUID(data, i);
            i           += 16;

            PartFlags = (ParticleFlags)(data[i++] + (data[i++] << 8));

            PartMaxAge = (data[i++] + (data[i++] << 8)) / 256.0f;

            // TODO: Unknown
            i += 2;

            PartStartRGBA = (uint)(data[i++] + (data[i++] << 8) +
                                   (data[i++] << 16) + (data[i++] << 24));

            PartEndRGBA = (uint)(data[i++] + (data[i++] << 8) +
                                 (data[i++] << 16) + (data[i++] << 24));

            PartStartScale   = new LLVector3();
            PartStartScale.X = data[i++] / 32.0f;
            PartStartScale.Y = data[i++] / 32.0f;

            PartEndScale   = new LLVector3();
            PartEndScale.X = data[i++] / 32.0f;
            PartEndScale.Y = data[i++] / 32.0f;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="pos"></param>
        private void FromBytes(byte[] data, int pos)
        {
            int i = pos;

            if (data.Length == 0)
                return;

            Serial = (uint)(data[i++] + (data[i++] << 8) +
                    (data[i++] << 16) + (data[i++] << 24));

            StartTick = (uint)(data[i++] + (data[i++] << 8) +
                    (data[i++] << 16) + (data[i++] << 24));

            SrcPattern = (SourcePattern)data[i++];

            SrcMaxAge = (data[i++] + (data[i++] << 8)) / 256.0f;

            // TODO: Unknown
            i += 2;

            SrcAngleBegin = (data[i++] / 100.0f) * (float)Math.PI;
            SrcAngleEnd = (data[i++] / 100.0f) * (float)Math.PI;

            SrcBurstRate = (data[i++] + (data[i++] << 8)) / 256.0f;
            SrcBurstRadius = (data[i++] + (data[i++] << 8)) / 256.0f;
            SrcBurstSpeedMin = (data[i++] + (data[i++] << 8)) / 256.0f;
            SrcBurstSpeedMax = (data[i++] + (data[i++] << 8)) / 256.0f;
            SrcBurstPartCount = data[i++];

            SrcOmega = new LLVector3();
            SrcOmega.X = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;
            SrcOmega.Y = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;
            SrcOmega.Z = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;

            SrcAccel = new LLVector3();
            SrcAccel.X = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;
            SrcAccel.Y = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;
            SrcAccel.Z = (data[i++] + (data[i++] << 8)) / 128.0f - 256.0f;

            SrcTexture = new LLUUID(data, i);
            i += 16;
            SrcTargetKey = new LLUUID(data, i);
            i += 16;

            PartFlags = (ParticleFlags)(data[i++] + (data[i++] << 8));

            PartMaxAge = (data[i++] + (data[i++] << 8)) / 256.0f;

            // TODO: Unknown
            i += 2;

            PartStartRGBA = (uint)(data[i++] + (data[i++] << 8) +
                    (data[i++] << 16) + (data[i++] << 24));

            PartEndRGBA = (uint)(data[i++] + (data[i++] << 8) +
                    (data[i++] << 16) + (data[i++] << 24));

            PartStartScale = new LLVector3();
            PartStartScale.X = data[i++] / 32.0f;
            PartStartScale.Y = data[i++] / 32.0f;

            PartEndScale = new LLVector3();
            PartEndScale.X = data[i++] / 32.0f;
            PartEndScale.Y = data[i++] / 32.0f;
        }