public StructPropertyList(ArkArchive archive, ArkName structType, ArkNameTree exclusivePropertyNameTree = null) : this(structType)
        {
            Properties = new Dictionary <ArkName, IProperty>();

            var property = PropertyRegistry.readProperty(archive, exclusivePropertyNameTree);
            while (property != null)
            {
                if (property != ExcludedProperty.Instance)
                {
                    Properties.Add(ArkName.Create(property.Name.Token, property.Index), property);
                }

                property = PropertyRegistry.readProperty(archive, exclusivePropertyNameTree);
            }
        }
 public static IStruct read(ArkArchive archive, ArkName structType, ArkNameTree exclusivePropertyNameTree = null)
 {
     if (structType.Equals(_itemNetId) || structType.Equals(_transform) ||
         structType.Equals(_primalPlayerDataStruct) || structType.Equals(_primalPlayerCharacterConfigStruct) ||
         structType.Equals(_primalPersistentCharacterStatsStruct) || structType.Equals(_tribeData) ||
         structType.Equals(_tribeGovernment) || structType.Equals(_terrainInfo) ||
         structType.Equals(_itemNetInfo) || structType.Equals(_arkInventoryData) ||
         structType.Equals(_dinoOrderGroup) || structType.Equals(_arkDinoData))
     {
         return(new StructPropertyList(archive, structType, exclusivePropertyNameTree));
     }
     else if (structType.Equals(_vector) || structType.Equals(_rotator))
     {
         return(new StructVector(archive, structType));
     }
     else if (structType.Equals(_vector2d))
     {
         return(new StructVector2d(archive, structType));
     }
     else if (structType.Equals(_quat))
     {
         return(new StructQuat(archive, structType));
     }
     else if (structType.Equals(_color))
     {
         return(new StructColor(archive, structType));
     }
     else if (structType.Equals(_linearColor))
     {
         return(new StructLinearColor(archive, structType));
     }
     else if (structType.Equals(_uniqueNetIdRepl))
     {
         return(new StructUniqueNetIdRepl(archive, structType));
     }
     else
     {
         _logger.Warn($"Unknown Struct Type {structType} at {archive.Position:X} trying to read as StructPropertyList");
         return(new StructPropertyList(archive, structType));
     }
 }
        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);
        }
Esempio n. 4
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;
            }
        }