private CObject CreateObject(SObject obj) { var type = names[obj.typeID]; Type resType = Type.GetType($"CR2W.Types.W3.{type}"); if (resType == null) { throw new UnknownObjectTypeException($"{type} could not be found"); } if (!resType.IsSubclassOf(typeof(CObject))) { throw new InvalidOperationException($"{type} is not a CObject"); } BaseStream.Seek(obj.offset, SeekOrigin.Begin); CObject temp = (CObject)Activator.CreateInstance(resType); temp.Flags = obj.flags; temp.Template = obj.template; if (obj.parentID > 0) { objects[obj.parentID - 1].Children.Add(obj.index, temp); } temp.ParseBytes(this, obj.size); return(temp); }