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

41 lines
1.1 KiB
C#
Raw Normal View History

namespace RobloxFiles.BinaryFormat.Chunks
{
public class INST
{
public readonly int TypeIndex;
public readonly string TypeName;
public readonly bool IsService;
public readonly int NumInstances;
public readonly int[] InstanceIds;
public override string ToString()
{
return TypeName;
}
2019-05-19 04:44:51 +00:00
public INST(BinaryRobloxFileChunk chunk)
{
2019-05-19 04:44:51 +00:00
using (BinaryRobloxFileReader reader = chunk.GetDataReader())
{
TypeIndex = reader.ReadInt32();
TypeName = reader.ReadString();
IsService = reader.ReadBoolean();
NumInstances = reader.ReadInt32();
InstanceIds = reader.ReadInstanceIds(NumInstances);
}
}
public void Allocate(BinaryRobloxFile file)
{
foreach (int instId in InstanceIds)
{
2019-05-19 04:44:51 +00:00
Instance inst = new Instance() { ClassName = TypeName };
file.Instances[instId] = inst;
}
file.Types[TypeIndex] = this;
}
}
}