Bug fixes, debug tools for binary chunks.
This commit is contained in:
@ -1,15 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
{
|
||||
public class PRNT : IBinaryFileChunk
|
||||
{
|
||||
private const byte FORMAT = 0;
|
||||
private BinaryRobloxFile File;
|
||||
|
||||
public void Load(BinaryRobloxFileReader reader)
|
||||
{
|
||||
BinaryRobloxFile file = reader.File;
|
||||
File = file;
|
||||
|
||||
byte format = reader.ReadByte();
|
||||
int idCount = reader.ReadInt32();
|
||||
@ -32,6 +35,9 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
|
||||
public void Save(BinaryRobloxFileWriter writer)
|
||||
{
|
||||
var file = writer.File;
|
||||
File = file;
|
||||
|
||||
var postInstances = writer.PostInstances;
|
||||
var idCount = postInstances.Count;
|
||||
|
||||
@ -58,5 +64,29 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
writer.WriteInstanceIds(childIds);
|
||||
writer.WriteInstanceIds(parentIds);
|
||||
}
|
||||
|
||||
public void WriteInfo(StringBuilder builder)
|
||||
{
|
||||
var childIds = new List<int>();
|
||||
var parentIds = new List<int>();
|
||||
|
||||
foreach (Instance inst in File.GetDescendants())
|
||||
{
|
||||
Instance parent = inst.Parent;
|
||||
|
||||
int childId = int.Parse(inst.Referent);
|
||||
int parentId = -1;
|
||||
|
||||
if (parent != null)
|
||||
parentId = int.Parse(parent.Referent);
|
||||
|
||||
childIds.Add(childId);
|
||||
parentIds.Add(parentId);
|
||||
}
|
||||
|
||||
builder.AppendLine($"- Format: {FORMAT}");
|
||||
builder.AppendLine($"- ChildIds: {string.Join(", ", childIds)}");
|
||||
builder.AppendLine($"- ParentIds: {string.Join(", ", parentIds)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user