internal static Group ReadGroup(Module module)
{
BinaryReader reader = module.Reader;
string type = reader.ReadId4();
if (type != "GRUP")
throw new InvalidDataException(string.Format("Expected GRUP; received {0}.", type));
uint contentSize = checked(reader.ReadUInt32() - 24);
uint label = reader.ReadUInt32();
string labelId = Extensions.ToId4((int)label);
ModuleGroupType groupType = (ModuleGroupType)reader.ReadInt32();
switch (groupType) {
case ModuleGroupType.Top:
switch(labelId) {
case "CELL":
case "WRLD":
case "DIAL":
return new GroupTopGroup(module, contentSize, label);
default:
return new RecordTopGroup(module, contentSize, label);
}
default:
throw new NotImplementedException("Group type " + groupType + " is not implemented.");
}
}