コード例 #1
0
        void ReadInfos(NomadObject obj)
        {
            var sizesAttr       = obj.GetAttribute("sizes");
            var rootNodeIdsAttr = obj.GetAttribute("rootNodeIds");

            var sizes       = Utils.UnpackArray(sizesAttr, BitConverter.ToInt32, 4, out int nSizes);
            var rootNodeIds = Utils.UnpackArray(rootNodeIdsAttr, BitConverter.ToInt32, 4, out int nRootNodeIds);

            if (nSizes != nRootNodeIds)
            {
                throw new InvalidDataException("Yikes!");
            }

            var count = (nSizes & nRootNodeIds);

            for (int i = 0; i < count; i++)
            {
                var size       = sizes[i];
                var rootNodeId = rootNodeIds[i];

                var info = new MoveResourceInfo(rootNodeId, size);

                Infos.Add(info);
            }
        }
コード例 #2
0
        FixupInfo ParseFixup(NomadObject obj)
        {
            var offsetAttr = obj.GetAttribute("offset");
            var hashAttr   = obj.GetAttribute("hash");

            var offset = Utils.UnpackData(offsetAttr, BitConverter.ToInt32);
            var hash   = Utils.UnpackData(hashAttr, BitConverter.ToInt32);

            return(new FixupInfo(hash, offset));
        }
コード例 #3
0
        public void Deserialize(NomadObject root)
        {
            RootNodeId = Utils.UnpackData(root.GetAttribute("rootNodeId"), BitConverter.ToInt32);
            MoveData   = root.GetAttribute("data").Data.Buffer;

            foreach (var param in AllParams)
            {
                param.Deserialize(root);
            }
        }
コード例 #4
0
        void ReadFixups(NomadObject obj)
        {
            var offsetsAttr = obj.GetAttribute("offsetsArray");
            var hashesAttr  = obj.GetAttribute("hashesArray");

            if ((offsetsAttr != null) && (hashesAttr != null))
            {
                var offsets = Utils.UnpackArray(offsetsAttr, BitConverter.ToInt32, 4, out int nOffsets);
                var hashes  = Utils.UnpackArray(hashesAttr, BitConverter.ToInt32, 4, out int nHashes);

                if (nOffsets != nHashes)
                {
                    throw new InvalidDataException("Yikes!");
                }

                // doesn't matter which one we use
                // but we'll be verbose anyways :)
                var count = (nOffsets & nHashes);

                Fixups = new List <FixupInfo>(count);

                for (int i = 0; i < count; i++)
                {
                    var offset = offsets[i];
                    var hash   = hashes[i];

                    var fixup = new FixupInfo(hash, offset);

                    Fixups.Add(fixup);
                }
            }
            else
            {
                foreach (var child in obj.Children)
                {
                    if (child.Id != "FIXUP")
                    {
                        throw new InvalidDataException($"Expected a FIXUP but got '{child.Id}' instead.");
                    }

                    var fixup = ParseFixup(child);

                    Fixups.Add(fixup);
                }
            }
        }