internal static T ParseAsset <T>(BinaryReader reader, MapParseContext context, AssetParseCallback <T> parseCallback) where T : Asset { var assetVersion = reader.ReadUInt16(); var dataSize = reader.ReadUInt32(); var startPosition = reader.BaseStream.Position; var endPosition = dataSize + startPosition; context.PushAsset(typeof(T).Name, endPosition); var result = parseCallback(assetVersion); result.Version = assetVersion; context.PopAsset(); if (reader.BaseStream.Position != endPosition) { throw new InvalidDataException($"Error while parsing asset '{typeof(T).Name}'. Expected reader to be at position {endPosition}, but was at {reader.BaseStream.Position}."); } return(result); }
internal static T ParseAsset <T>(BinaryReader reader, MapParseContext context, AssetParseCallback <T> parseCallback) where T : Asset { return(ParseAsset(reader, context, (version, endPosition) => parseCallback(version))); }