Added memoryOffset value to DNAFieldAttribute, regenerated files.

This commit is contained in:
Samuele Lorefice
2025-02-20 21:00:55 +01:00
parent b171b65aa5
commit f383debd18
939 changed files with 9636 additions and 9605 deletions

View File

@@ -72,7 +72,6 @@ public class Reader {
foreach (var block in blend.Blocks) {
//We need to read all blocks of data regardless of the type
//if (block.Code != "DATA") continue;
//Checks if the block has a known SDNA type, meaning that we know how it is structured
if (!dnaTypes.ContainsKey((int)block.SdnaIndex)) continue;
@@ -113,14 +112,25 @@ public class Reader {
private long GetBlockFieldDataOffset(long blockAddress, int fieldIndex, FieldInfo[] fieldMetadata) =>
blockAddress + GetFieldDataOffset(fieldIndex, fieldMetadata);
/// <summary>
/// Gets the offset of the data of a field in a block
/// </summary>
/// <param name="fieldIndex">index of the field in the structure</param>
/// <param name="fieldMetadata"><see cref="FieldInfo"/> array of metadata</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private long GetFieldDataOffset(int fieldIndex, FieldInfo[] fieldMetadata) =>
private long GetFieldDataOffset(int fieldIndex, FieldInfo[] fieldMetadata) =>
fieldMetadata.Where(f => f.GetCustomAttribute<DNAFieldAttribute>()!.OriginalIndex < fieldIndex)
.Sum(f => f.GetCustomAttribute<DNAFieldAttribute>()!.Size);
/// <summary>
/// Creates an instance of a given type
/// </summary>
/// <param name="type">A <see cref="string"/> containing the name of the type to create</param>
/// <returns>An object of the type specified in the parameter or null</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private object? ActivateInstance(string type) => dnaTypesDb.TryGetValue(type, out Type? t) ? Activator.CreateInstance(t) : null;
/// <summary>
/// Filles a given object with the data from a block, starting to read it from the specified offset
/// </summary>