Пример #1
0
 public ALEffectLib(LeafNode node)
 {
     using (var reader = new BinaryReader(new MemoryStream(node.ByteArrayData))) {
         Version = reader.ReadSingle();
         var effectCount = reader.ReadInt32();
         Effects = new List <ALEffect> (effectCount);
         for (int ef = 0; ef < effectCount; ef++)
         {
             ushort nameLen = reader.ReadUInt16();
             var    name    = Encoding.ASCII.GetString(reader.ReadBytes(nameLen)).TrimEnd('\0');
             reader.BaseStream.Seek((nameLen & 1), SeekOrigin.Current);
             if (Version == 1.1f)
             {
                 //Skip 4 unused floats
                 reader.BaseStream.Seek(4 * sizeof(float), SeekOrigin.Current);
             }
             int fxCount = reader.ReadInt32();
             var refs    = new List <AlchemyNodeRef> (fxCount);
             for (int i = 0; i < fxCount; i++)
             {
                 refs.Add(new AlchemyNodeRef(
                              reader.ReadUInt32(),
                              reader.ReadUInt32(),
                              reader.ReadUInt32(),
                              reader.ReadUInt32()
                              ));
             }
             int pairsCount = reader.ReadInt32();
             var pairs      = new List <Tuple <uint, uint> > (pairsCount);
             for (int i = 0; i < pairsCount; i++)
             {
                 pairs.Add(new Tuple <uint, uint> (reader.ReadUInt32(), reader.ReadUInt32()));
             }
             Effects.Add(
                 new ALEffect()
             {
                 Name  = name,
                 CRC   = CrcTool.FLAleCrc(name),
                 Fx    = refs,
                 Pairs = pairs
             }
                 );
         }
     }
 }
Пример #2
0
        public FxNode(AlchemyNode ale)
        {
            Name = ale.Name;
            AleParameter temp;

            if (ale.TryGetParameter("Node_Name", out temp))
            {
                NodeName = (string)temp.Value;
                CRC      = CrcTool.FLAleCrc(NodeName);
            }
            if (ale.TryGetParameter("Node_Transform", out temp))
            {
                Transform = (AlchemyTransform)temp.Value;
            }
            else
            {
                Transform = new AlchemyTransform();
            }
            if (ale.TryGetParameter("Node_LifeSpan", out temp))
            {
                NodeLifeSpan = (float)temp.Value;
            }
        }
Пример #3
0
        public AlchemyNodeLibrary(LeafNode utfleaf)
        {
            using (var reader = new BinaryReader(new MemoryStream(utfleaf.ByteArrayData))) {
                Version = reader.ReadSingle();
                int nodeCount = reader.ReadInt32();
                for (int nc = 0; nc < nodeCount; nc++)
                {
                    ushort nameLen  = reader.ReadUInt16();
                    var    nodeName = Encoding.ASCII.GetString(reader.ReadBytes(nameLen)).TrimEnd('\0');
                    reader.BaseStream.Seek(nameLen & 1, SeekOrigin.Current);                     //padding
                    var node = new AlchemyNode()
                    {
                        Name = nodeName
                    };
                    node.CRC = CrcTool.FLAleCrc(nodeName);
                    uint id, crc;
                    while (true)
                    {
                        id = reader.ReadUInt16();
                        if (id == 0)
                        {
                            break;
                        }
                        AleTypes type = (AleTypes)(id & 0x7FFF);
                        crc = reader.ReadUInt32();
                        string efname;
                        if (!AleCrc.FxCrc.TryGetValue(crc, out efname))
                        {
                            efname = string.Format("CRC: 0x{0:X}", crc);
                        }
                        object value = null;
                        switch (type)
                        {
                        case AleTypes.Boolean:
                            value = (id & 0x8000) != 0 ? true : false;
                            break;

                        case AleTypes.Integer:
                            value = reader.ReadUInt32();
                            break;

                        case AleTypes.Float:
                            value = reader.ReadSingle();
                            break;

                        case AleTypes.Name:
                            var vallen = reader.ReadUInt16();
                            if (vallen != 0)
                            {
                                value = Encoding.ASCII.GetString(reader.ReadBytes(vallen)).TrimEnd('\0');
                            }
                            reader.BaseStream.Seek(vallen & 1, SeekOrigin.Current);                             //padding
                            break;

                        case AleTypes.IPair:
                            value = new Tuple <uint, uint> (reader.ReadUInt32(), reader.ReadUInt32());
                            break;

                        case AleTypes.Transform:
                            value = new AlchemyTransform(reader);
                            break;

                        case AleTypes.FloatAnimation:
                            value = new AlchemyFloatAnimation(reader);
                            break;

                        case AleTypes.ColorAnimation:
                            value = new AlchemyColorAnimation(reader);
                            break;

                        case AleTypes.CurveAnimation:
                            value = new AlchemyCurveAnimation(reader);
                            break;

                        default:
                            throw new InvalidDataException("Invalid ALE Type: 0x" + (id & 0x7FFF).ToString("x"));
                        }
                        node.Parameters.Add(new AleParameter()
                        {
                            Name = efname, Value = value
                        });
                    }
                    AleParameter temp;
                    if (node.TryGetParameter("Node_Name", out temp))
                    {
                        var nn = (string)temp.Value;
                        node.CRC = CrcTool.FLAleCrc(nn);
                    }
                    Nodes.Add(node);
                }
            }
        }