예제 #1
0
        static WZProperty ParseExtendedProperty(WZReader reader, WZProperty parent, string name, bool maintainReader = false)
        {
            string       type = reader.ReadWZStringBlock(parent.Encrypted | parent.Container.Encrypted);
            PropertyType propType;

            switch (type)
            {
            case "Property":
                reader.BaseStream.Seek(2, SeekOrigin.Current);
                propType = PropertyType.SubProperty;
                break;

            case "Canvas":
                propType = PropertyType.Canvas;
                break;

            case "Shape2D#Vector2D":
                propType = PropertyType.Vector2;
                break;

            case "Shape2D#Convex2D":
                propType = PropertyType.Convex;
                break;

            case "Sound_DX8":
                propType = PropertyType.Audio;
                break;

            case "UOL":
                reader.BaseStream.Seek(1, SeekOrigin.Current);
                propType = PropertyType.UOL;
                break;

            default:
                throw new InvalidOperationException($"Unknown ExtendedProperty type {type}");
            }

            WZProperty result = new WZProperty(
                name,
                Path.Combine(parent.Path, name),
                parent.FileContainer,
                propType,
                parent,
                0,
                0,
                (uint)reader.BaseStream.Position
                );

            if (maintainReader)
            {
                return(Resolve(parent.FileContainer, result, reader));
            }
            else
            {
                return(Resolve(parent.FileContainer, result));
            }
        }
예제 #2
0
 public static WZProperty UOL(WZReader reader, WZProperty self)
 => new WZPropertyVal <string>(reader.ReadWZStringBlock(self.Encrypted | self.Container.Encrypted), self);
예제 #3
0
        public static IEnumerable <WZProperty> PropertyList(WZReader reader, WZProperty parent)
        {
            if (reader.BaseStream.Position + 4 >= reader.BaseStream.Length)
            {
                return(new WZProperty[0]);
            }
            return(Enumerable.Range(0, reader.ReadWZInt()).Select(i =>
            {
                uint position = (uint)reader.BaseStream.Position;
                if (position >= reader.BaseStream.Length)
                {
                    return null;
                }
                string name = reader.ReadWZStringBlock(parent.Encrypted | parent.Container.Encrypted);
                byte type = reader.ReadByte();
                switch (type)
                {
                case 0:
                    return new WZProperty(name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.Null, parent, 0, 0, position);

                case 0x10:
                    return new WZPropertyVal <sbyte>(reader.ReadSByte(), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.UInt16, parent, 1, 0, position);

                case 0x11:
                    return new WZPropertyVal <byte>(reader.ReadByte(), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.UInt16, parent, 1, 0, position);

                case 0x0B:
                case 2:
                case 0x12:
                    return new WZPropertyVal <UInt16>(reader.ReadUInt16(), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.UInt16, parent, 2, 0, position);

                case 3:
                    return new WZPropertyVal <Int32>(reader.ReadWZInt(), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.Int32, parent, 4, 0, position);

                case 19:
                    return new WZPropertyVal <Rgba32>(new Rgba32((uint)reader.ReadWZInt()), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.Int32, parent, 4, 0, position);

                case 4:
                    return new WZPropertyVal <Single>(reader.ReadWZSingle(), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.Single, parent, 4, 0, position);

                case 5:
                    return new WZPropertyVal <Double>(reader.ReadDouble(), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.Double, parent, 8, 0, position);

                case 8:
                    return new WZPropertyVal <string>(reader.ReadWZStringBlock(parent.Encrypted | parent.Container.Encrypted), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.String, parent, 0, 0, position);

                case 9:
                    uint blockLen = reader.ReadUInt32();
                    WZProperty result = reader.PeekFor(() => ParseExtendedProperty(reader, parent, name));
                    reader.BaseStream.Seek(blockLen, SeekOrigin.Current);
                    return result;

                case 20:
                    return new WZPropertyVal <long>(reader.ReadWZLong(), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.Int64, parent, 8, 0, position);

                case 21:
                    return new WZPropertyVal <ulong>((ulong)reader.ReadWZLong(), name, Path.Combine(parent.Path, name), parent.FileContainer, PropertyType.Int64, parent, 8, 0, position);

                default:
                    throw new Exception("Unknown property type at ParsePropertyList");
                }
            }));
        }