Ejemplo n.º 1
0
        void ReadImageProperties()
        {
            //Find the embedded game object with the data
            EmbeddedGameObjectTableHead result = null;

            foreach (var r in gameObjectEmbeds)
            {
                if (r.type == classname)
                {
                    result = r;
                }
            }

            //Crash if not correct
            if (result == null)
            {
                throw new Exception("Could not find image property data.");
            }

            //Go to
            stream.position = result.dataLocation;

            //Read
            properties = UProperty.ReadProperties(stream, this, null, false);
        }
Ejemplo n.º 2
0
        void ReadDefaultProperties()
        {
            //Find the embedded game object with the data
            EmbeddedGameObjectTableHead result = FindEmbeddedObjectByType($"Default__{classname}_C");

            //Go to
            stream.position = result.dataLocation;

            //Read
            properties = UProperty.ReadProperties(stream, this, null, false);
        }
Ejemplo n.º 3
0
        public static List <UProperty> ReadProperties(IOMemoryStream ms, UAssetFile f, string arrayType, bool isStruct)
        {
            //Read until none
            List <UProperty> output = new List <UProperty>();

            while (true)
            {
                UProperty p = ReadProp(ms, f, arrayType, isStruct);
                if (p == null)
                {
                    break;
                }
                output.Add(p);
            }
            return(output);
        }
Ejemplo n.º 4
0
        public T GetProperty <T>(string name, int index = -1)
        {
            //Get property
            UProperty p = GetProperty(name, index);

            //If it was not found, return default
            if (p == null)
            {
                return(default(T));
            }

            try
            {
                //Cast
                return((T)Convert.ChangeType(p, typeof(T)));
            } catch
            {
                return(default(T));
            }
        }
Ejemplo n.º 5
0
        public string GetPropertyStringOrName(string name, int index = -1)
        {
            UProperty p = GetProperty(name, index);

            if (p == null)
            {
                return(null);
            }

            if (p.GetType() == typeof(NameProperty))
            {
                NameProperty np = (NameProperty)p;
                return(np.data);
            }
            else if (p.GetType() == typeof(StrProperty))
            {
                StrProperty np = (StrProperty)p;
                return(np.data);
            }
            return(null);
        }
Ejemplo n.º 6
0
        void ReadMetadataProperties()
        {
            //Find the embedded game object with the data
            EmbeddedGameObjectTableHead result = FindEmbeddedObjectByType($"{classname}");

            //Go to
            stream.position = result.dataLocation;

            //Read
            metadata = UProperty.ReadProperties(stream, this, null, false);
            var reader = new PropertyReader(metadata);

            //Get parent class

            if (reader.HasProperty("ParentClass"))
            {
                ObjectProperty parent     = reader.GetProperty <ObjectProperty>("ParentClass");
                var            parentFile = parent.GetReferencedFile();
                if (parentFile != null)
                {
                    //The parent is an object we can read
                    parentClassname  = parentFile.classname;
                    parentPath       = parentFile.pathname;
                    hasParentUObject = true;
                }
                else
                {
                    //The parent is not a uobject
                    hasParentUObject = false;
                }
            }
            else
            {
                hasParentUObject = false;
            }
        }