Replace runtime MessagePack DTO keys

This commit is contained in:
Meta Vens 2026-06-13 15:02:32 +01:00
commit 066597e70b
41 changed files with 298 additions and 314 deletions

View file

@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using GameCult.Aetheria.State.Unity;
using MessagePack;
using Unity.Mathematics;
public interface IRuntimeItemCatalogReader
@ -223,9 +222,9 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader
{
return type
.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Select(field => (attribute: field.GetCustomAttribute<KeyAttribute>(), field))
.Where(entry => entry.attribute?.IntKey != null)
.Select(entry => (entry.attribute.IntKey.GetValueOrDefault(), entry.field));
.Select(field => (attribute: field.GetCustomAttribute<RuntimeCatalogKeyAttribute>(), field))
.Where(entry => entry.attribute != null)
.Select(entry => (entry.attribute.Key, entry.field));
}
private static object ConvertValue(AetheriaRuntimeBehaviorValue value, Type targetType)
@ -253,7 +252,7 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader
return ConvertList(value, targetType);
}
if (targetType.GetCustomAttribute<MessagePackObjectAttribute>() != null)
if (GetKeyedFields(targetType).Any())
{
return ConvertKeyedObject(value, targetType);
}