Roblox-File-Format/BinaryFormat/Chunks/PRNT.cs

36 lines
1.0 KiB
C#
Raw Normal View History

namespace RobloxFiles.BinaryFormat.Chunks
{
public class PRNT
{
public readonly byte Format;
public readonly int NumRelations;
public readonly int[] ChildrenIds;
public readonly int[] ParentIds;
2019-05-19 04:44:51 +00:00
public PRNT(BinaryRobloxFileChunk chunk)
{
2019-05-19 04:44:51 +00:00
using (BinaryRobloxFileReader reader = chunk.GetDataReader())
{
Format = reader.ReadByte();
NumRelations = reader.ReadInt32();
ChildrenIds = reader.ReadInstanceIds(NumRelations);
ParentIds = reader.ReadInstanceIds(NumRelations);
}
}
public void Assemble(BinaryRobloxFile file)
{
for (int i = 0; i < NumRelations; i++)
{
int childId = ChildrenIds[i];
int parentId = ParentIds[i];
Instance child = file.Instances[childId];
2019-05-19 04:44:51 +00:00
child.Parent = (parentId >= 0 ? file.Instances[parentId] : file);
}
}
}
}