public ObjectTreeLeaf(BinaryReaderEx input, int layerVersion) { Area = new MapArea(input, layerVersion >= 4); Color = input.ReadBytes(4); HashValue = input.ReadInt32(); ObjectTypeCount = input.ReadInt32(); ObjectTypeHashes = new int[ObjectTypeCount]; ObjectInfos = new ObjectInfo[ObjectTypeCount][]; for (int curObjType = 0; curObjType < ObjectTypeCount; curObjType++) { var nObjects = input.ReadInt32(); ObjectTypeHashes[curObjType] = input.ReadInt32(); ObjectInfos[curObjType] = new ObjectInfo[nObjects]; for (int obj = 0; obj < nObjects; obj++) { ObjectInfos[curObjType][obj] = new ObjectInfo(input); } } }
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; } } }