Exemplo n.º 1
0
 public PropertyBase(ArkArchive archive, PropertyArgs args)
 {
     Name     = args.Name;
     TypeName = args.TypeName;
     DataSize = archive.GetInt();
     Index    = archive.GetInt();
 }
Exemplo n.º 2
0
        public PropertyArray(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false) : base(archive, args, propertyIsExcluded)
        {
            if (propertyIsExcluded)
            {
                archive.SkipName();
                archive.Position += DataSize;
                return;
            }

            ArrayType = archive.GetName();

            var position = archive.Position;

            try
            {
                _value = ArkArrayRegistry.read(archive, ArrayType, DataSize);

                if (_value == null)
                {
                    throw new UnreadablePropertyException();
                }
            }
            catch (UnreadablePropertyException)
            {
                archive.Position += DataSize;
                _logger.Error($"Unreadable ArrayProperty with name {Name}, skipping.");
                throw new UnreadablePropertyException();
            }
        }
Exemplo n.º 3
0
        public PropertyText(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false) : base(archive, args, propertyIsExcluded)
        {
            if (propertyIsExcluded)
            {
                archive.Position += DataSize;
                return;
            }

            _value = System.Convert.ToBase64String((byte[])(Array)archive.GetBytes(DataSize));
        }
Exemplo n.º 4
0
        public PropertyName(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false) : base(archive, args, propertyIsExcluded)
        {
            if (propertyIsExcluded)
            {
                archive.SkipName();
                return;
            }

            _value = archive.GetName();
        }
Exemplo n.º 5
0
        public PropertyBool(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false) : base(archive, args, propertyIsExcluded)
        {
            if (propertyIsExcluded)
            {
                archive.Position += 1;
                return;
            }

            _value = archive.GetByte() != 0;
        }
Exemplo n.º 6
0
        public PropertyInt32(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false) : base(archive, args, propertyIsExcluded)
        {
            if (propertyIsExcluded)
            {
                archive.Position += 4;
                return;
            }

            _value = archive.GetInt();
        }
Exemplo n.º 7
0
        public PropertyObject(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false) : base(archive, args, propertyIsExcluded)
        {
            if (propertyIsExcluded)
            {
                archive.Position += DataSize;
                return;
            }


            _value = new ObjectReference(archive, DataSize);
        }
Exemplo n.º 8
0
        public PropertyBase(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false)
        {
            Name = args.Name;
            //TypeName = args.TypeName;
            DataSize = archive.GetInt();

            if (propertyIsExcluded)
            {
                archive.Position += 4;
                return;
            }

            Index = archive.GetInt();
        }
Exemplo n.º 9
0
        public PropertyStruct(ArkArchive archive, PropertyArgs args) : base(archive, args)
        {
            var structType = archive.GetName();
            var position   = archive.Position;

            try
            {
                _value = StructRegistry.read(archive, structType);
            }
            catch (UnreadablePropertyException)
            {
                // skip struct
                archive.Position += DataSize;
            }
        }
Exemplo n.º 10
0
        public PropertyStruct(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false, ArkNameTree exclusivePropertyNameTree = null) : base(archive, args, propertyIsExcluded)
        {
            if (propertyIsExcluded)
            {
                archive.SkipName();
                archive.Position += DataSize;
                return;
            }

            var structType = archive.GetName();
            var position   = archive.Position;

            try
            {
                _value = StructRegistry.read(archive, structType, exclusivePropertyNameTree);
            }
            catch (UnreadablePropertyException)
            {
                // skip struct
                archive.Position += DataSize;
            }
        }
Exemplo n.º 11
0
        public static IProperty readProperty(ArkArchive archive)
        {
            var name = archive.GetName();

            if (name == null || name.Equals(ArkName.EMPTY_NAME))
            {
                _logger.Error($"Property name is {(name == null ? "null" : "empty")}. Ignoring remaining properties.");
                throw new UnreadablePropertyException();
            }

            if (name.Equals(ArkName.NONE_NAME))
            {
                return(null);
            }

            var type = archive.GetName();
            var args = new PropertyArgs(name, type);

            if (type.Equals(_int) || type.Equals(_uint32))
            {
                return(new PropertyInt32(archive, args));
            }
            else if (type.Equals(_bool))
            {
                return(new PropertyBool(archive, args));
            }
            else if (type.Equals(_byte))
            {
                return(new PropertyByte(archive, args));
            }
            else if (type.Equals(_float))
            {
                return(new PropertyFloat(archive, args));
            }
            else if (type.Equals(_double))
            {
                return(new PropertyDouble(archive, args));
            }
            else if (type.Equals(_int8))
            {
                return(new PropertyInt8(archive, args));
            }
            else if (type.Equals(_int16) || type.Equals(_uint16))
            {
                return(new PropertyInt16(archive, args));
            }
            else if (type.Equals(_uint64))
            {
                return(new PropertyInt64(archive, args));
            }
            else if (type.Equals(_name))
            {
                return(new PropertyName(archive, args));
            }
            else if (type.Equals(_object))
            {
                return(new PropertyObject(archive, args));
            }
            else if (type.Equals(_str))
            {
                return(new PropertyStr(archive, args));
            }
            else if (type.Equals(_struct))
            {
                return(new PropertyStruct(archive, args));
            }
            else if (type.Equals(_array))
            {
                return(new PropertyArray(archive, args));
            }
            else if (type.Equals(_text))
            {
                return(new PropertyText(archive, args));
            }
            else
            {
                _logger.Error($"Unknown property type {type} near {archive.Position:X}. Ignoring remaining properties.");
                throw new UnreadablePropertyException();
            }
        }
Exemplo n.º 12
0
        public PropertyByte(ArkArchive archive, PropertyArgs args) : base(archive, args)
        {
            var enumName = archive.GetName();

            _value = new ArkByteValue(archive, enumName);
        }
Exemplo n.º 13
0
        public PropertyByte(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false) : base(archive, args, propertyIsExcluded)
        {
            var enumName = archive.GetName();

            _value = new ArkByteValue(archive, enumName, propertyIsExcluded);
        }
        public static IProperty readProperty(ArkArchive archive, ArkNameTree exclusivePropertyNameTree = null)
        {
            var name = archive.GetName();

            if (name == null || name.Equals(ArkName.EMPTY_NAME))
            {
                _logger.Error($"Property name is {(name == null ? "null" : "empty")}. Ignoring remaining properties.");
                throw new UnreadablePropertyException();
            }

            if (name.Equals(ArkName.NONE_NAME))
            {
                return(null);
            }

            var propertyIsExcluded = exclusivePropertyNameTree?.ContainsKey(name) == false;

            var type = archive.GetName();
            var args = new PropertyArgs(name, type);

            IProperty result = null;

            if (type.Equals(_int) || type.Equals(_uint32))
            {
                result = new PropertyInt32(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_bool))
            {
                result = new PropertyBool(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_byte))
            {
                result = new PropertyByte(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_float))
            {
                result = new PropertyFloat(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_double))
            {
                result = new PropertyDouble(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_int8))
            {
                result = new PropertyInt8(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_int16) || type.Equals(_uint16))
            {
                result = new PropertyInt16(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_uint64))
            {
                result = new PropertyInt64(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_name))
            {
                result = new PropertyName(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_object))
            {
                result = new PropertyObject(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_str))
            {
                result = new PropertyStr(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_struct))
            {
                result = new PropertyStruct(archive, args, propertyIsExcluded, exclusivePropertyNameTree == null || propertyIsExcluded ? null : exclusivePropertyNameTree[name]);
            }
            else if (type.Equals(_array))
            {
                result = new PropertyArray(archive, args, propertyIsExcluded);
            }
            else if (type.Equals(_text))
            {
                result = new PropertyText(archive, args, propertyIsExcluded);
            }
            else
            {
                _logger.Error($"Unknown property type {type} near {archive.Position:X}. Ignoring remaining properties.");
                throw new UnreadablePropertyException();
            }

            if (propertyIsExcluded)
            {
                return(ExcludedProperty.Instance);
            }

            return(result);
        }
Exemplo n.º 15
0
 public PropertyFloat(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = archive.GetFloat();
 }
Exemplo n.º 16
0
 public PropertyInt8(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = archive.GetByte();
 }
Exemplo n.º 17
0
 public PropertyInt16(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = archive.GetShort();
 }
Exemplo n.º 18
0
 public PropertyStr(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = archive.GetString();
 }
Exemplo n.º 19
0
 public PropertyInt64(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = archive.GetLong();
 }
Exemplo n.º 20
0
 public PropertyText(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = System.Convert.ToBase64String((byte[])(Array)archive.GetBytes(DataSize));
 }
Exemplo n.º 21
0
 public PropertyName(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = archive.GetName();
 }
Exemplo n.º 22
0
 public PropertyInt32(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = archive.GetInt();
 }
Exemplo n.º 23
0
 public PropertyObject(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = new ObjectReference(archive, DataSize);
 }
Exemplo n.º 24
0
 public PropertyBool(ArkArchive archive, PropertyArgs args) : base(archive, args)
 {
     _value = archive.GetByte() != 0;
 }