예제 #1
0
            public ALB_List(BinaryReaderEx input, int?layerVersion = null)
            {
                size = input.ReadInt32();
                var nEntries = input.ReadInt32();

                if (nEntries > 0 && (size - 4 == nEntries))
                {
                    if (!layerVersion.HasValue)
                    {
                        throw new FormatException("No layerVersion specified before reading ObjectTree");
                    }
                    treeRoot = new ObjectTreeNode(input, layerVersion.Value);
                }
                else
                {
                    entries = Enumerable.Range(0, nEntries).Select(_ => new ALB_Entry(input)).ToArray();
                }
            }
예제 #2
0
 public void ExtractObjectData(ObjectTreeNode node, LinkedList <ObjectTreeLeaf> list)
 {
     if (node.NodeType == 16)
     {
         for (int i = 0; i < 4; i++)
         {
             if (node.Objects[i] != null)
             {
                 list.AddLast(node.Objects[i]);
             }
         }
     }
     else
     {
         for (int i = 0; i < 4; i++)
         {
             if (node.Childs[i] != null)
             {
                 ExtractObjectData(node.Childs[i], list);
             }
         }
     }
 }
예제 #3
0
        public ObjectTreeNode(BinaryReaderEx input, int layerVersion)
        {
            NodeType = input.ReadSByte();

            Area = new MapArea(input, layerVersion >= 4);

            Level = input.ReadInt32();
            Color = Enumerable.Range(0, 4).Select(_ => input.ReadByte()).ToArray();
            flags = input.ReadByte();

            if (NodeType == 16)
            {
                Objects = new ObjectTreeLeaf[4];
                var isChild = flags;
                for (int i = 0; i < 4; i++)
                {
                    if ((isChild & 1) == 1)
                    {
                        Objects[i] = new ObjectTreeLeaf(input, layerVersion);
                    }
                    isChild >>= 1;
                }
            }
            else
            {
                Childs = new ObjectTreeNode[4];
                var isChild = flags;
                for (int i = 0; i < 4; i++)
                {
                    if ((isChild & 1) == 1)
                    {
                        Childs[i] = new ObjectTreeNode(input, layerVersion);
                    }
                    isChild >>= 1;
                }
            }
        }