Project behavior item refs as typed keys
This commit is contained in:
parent
2d3172887b
commit
e173989b3d
160 changed files with 314 additions and 211 deletions
Binary file not shown.
|
|
@ -919,11 +919,7 @@ internal static class LegacyCatalogReader
|
|||
{
|
||||
bool boolValue => new AetheriaBehaviorValue { Kind = "bool", BoolValue = boolValue },
|
||||
string stringValue => new AetheriaBehaviorValue { Kind = "string", StringValue = stringValue },
|
||||
byte[] bytes when bytes.Length == 16 => new AetheriaBehaviorValue
|
||||
{
|
||||
Kind = "legacy-id",
|
||||
LegacyIdValue = new Guid(bytes).ToString("D")
|
||||
},
|
||||
byte[] bytes when bytes.Length == 16 => ReadLegacyBehaviorId(bytes),
|
||||
byte[] bytes => new AetheriaBehaviorValue
|
||||
{
|
||||
Kind = "binary",
|
||||
|
|
@ -955,9 +951,25 @@ internal static class LegacyCatalogReader
|
|||
Kind = "unknown",
|
||||
StringValue = value.ToString() ?? ""
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaBehaviorValue ReadLegacyBehaviorId(byte[] bytes)
|
||||
{
|
||||
var legacyId = new Guid(bytes);
|
||||
return new AetheriaBehaviorValue
|
||||
{
|
||||
Kind = "legacy-id",
|
||||
LegacyIdValue = legacyId.ToString("D"),
|
||||
ItemKeyValue = ProjectLegacyItemKey(legacyId)
|
||||
};
|
||||
}
|
||||
|
||||
private static string ProjectLegacyItemKey(Guid legacyItemId)
|
||||
{
|
||||
return legacyItemId == Guid.Empty ? "" : $"aetheria.item_definition:legacy:{legacyItemId:D}";
|
||||
}
|
||||
|
||||
private static Dictionary<int, string> CreateEnumMap(string[] names)
|
||||
{
|
||||
return names
|
||||
|
|
|
|||
|
|
@ -101,6 +101,15 @@ if (behaviorPayload.Fields.Count == 0)
|
|||
throw new InvalidOperationException($"Runtime behavior payload has no fields for {behaviorHost.Name}.");
|
||||
}
|
||||
|
||||
var behaviorItemRefsMissingItemKeys = packageCatalog.Items
|
||||
.SelectMany(item => item.BehaviorPayloads)
|
||||
.Sum(CountRequiredBehaviorItemRefsMissingItemKeys);
|
||||
if (behaviorItemRefsMissingItemKeys > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Runtime behavior payload item refs missing item-key projections: {behaviorItemRefsMissingItemKeys}.");
|
||||
}
|
||||
|
||||
var equipment = catalog.EquipmentItems.First();
|
||||
if (!catalog.FindItemsByHardpoint(equipment.HardpointType).Any())
|
||||
{
|
||||
|
|
@ -990,3 +999,34 @@ static void AssertPendingCultCacheEnvelope(string path, string expectedSchemaId)
|
|||
throw new InvalidOperationException($"Pending file {path} does not publish a typed CultCache record for {expectedSchemaId}.");
|
||||
}
|
||||
}
|
||||
|
||||
static int CountRequiredBehaviorItemRefsMissingItemKeys(AetheriaRuntimeBehaviorPayload payload)
|
||||
{
|
||||
return payload.Fields.Count(field =>
|
||||
IsBehaviorItemRefField(payload.Kind, field.Key) &&
|
||||
IsNonEmptyLegacyRefMissingItemKey(field.Value));
|
||||
}
|
||||
|
||||
static bool IsBehaviorItemRefField(string behaviorKind, int fieldKey)
|
||||
{
|
||||
return (string.Equals(behaviorKind, "ItemUsage", StringComparison.OrdinalIgnoreCase) && fieldKey == 1) ||
|
||||
(IsWeaponBehavior(behaviorKind) && fieldKey == 12);
|
||||
}
|
||||
|
||||
static bool IsWeaponBehavior(string behaviorKind)
|
||||
{
|
||||
return behaviorKind is "GuidedWeapon" or "InstantWeapon" or "ConstantWeapon" or "ChargedWeapon" or "AutoWeapon" or "LockWeapon";
|
||||
}
|
||||
|
||||
static bool IsNonEmptyLegacyRefMissingItemKey(AetheriaRuntimeBehaviorValue value)
|
||||
{
|
||||
return string.Equals(value.Kind, "legacy-id", StringComparison.OrdinalIgnoreCase) &&
|
||||
!IsEmptyLegacyId(value.LegacyIdValue) &&
|
||||
string.IsNullOrWhiteSpace(value.ItemKeyValue);
|
||||
}
|
||||
|
||||
static bool IsEmptyLegacyId(string legacyId)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(legacyId) ||
|
||||
(Guid.TryParse(legacyId, out var parsed) && parsed == Guid.Empty);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ internal static class AetheriaRuntimeCatalogSnapshotMapper
|
|||
value.NumberValue,
|
||||
value.BoolValue,
|
||||
value.LegacyIdValue,
|
||||
value.ItemKeyValue,
|
||||
value.Children.Select(FromState).ToArray(),
|
||||
value.MapEntries.Select(FromState).ToArray());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ var behaviorLegacyRefCount = items
|
|||
.SelectMany(item => item.BehaviorPayloads)
|
||||
.SelectMany(behavior => behavior.Fields)
|
||||
.Count(field => ContainsBehaviorValueKind(field.Value, "legacy-id"));
|
||||
var behaviorItemRefsMissingItemKeys = items
|
||||
.SelectMany(item => item.BehaviorPayloads)
|
||||
.Sum(CountRequiredBehaviorItemRefsMissingItemKeys);
|
||||
var hardpointItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HardpointType));
|
||||
var hullItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HullType));
|
||||
var hullPrefabItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HullPrefab));
|
||||
|
|
@ -243,6 +246,12 @@ if (behaviorPayloadItems != behaviorItems || behaviorPayloadCount == 0 || behavi
|
|||
$"Typed behavior payload import mismatch: payloadItems={behaviorPayloadItems}, behaviorItems={behaviorItems}, payloads={behaviorPayloadCount}, fields={behaviorFieldCount}.");
|
||||
}
|
||||
|
||||
if (behaviorItemRefsMissingItemKeys > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Typed behavior payload item refs missing item-key projections: {behaviorItemRefsMissingItemKeys}.");
|
||||
}
|
||||
|
||||
foreach (var item in items.Where(item => item.BehaviorPayloads.Length > 0))
|
||||
{
|
||||
if (item.BehaviorPayloads.Length != item.BehaviorCount)
|
||||
|
|
@ -441,6 +450,37 @@ static bool ContainsBehaviorValueKind(AetheriaBehaviorValue value, string kind)
|
|||
value.MapEntries.Any(entry => ContainsBehaviorValueKind(entry.Value, kind));
|
||||
}
|
||||
|
||||
static int CountRequiredBehaviorItemRefsMissingItemKeys(AetheriaBehaviorPayload payload)
|
||||
{
|
||||
return payload.Fields.Count(field =>
|
||||
IsBehaviorItemRefField(payload.Kind, field.Key) &&
|
||||
IsNonEmptyLegacyRefMissingItemKey(field.Value));
|
||||
}
|
||||
|
||||
static bool IsBehaviorItemRefField(string behaviorKind, int fieldKey)
|
||||
{
|
||||
return (string.Equals(behaviorKind, "ItemUsage", StringComparison.OrdinalIgnoreCase) && fieldKey == 1) ||
|
||||
(IsWeaponBehavior(behaviorKind) && fieldKey == 12);
|
||||
}
|
||||
|
||||
static bool IsWeaponBehavior(string behaviorKind)
|
||||
{
|
||||
return behaviorKind is "GuidedWeapon" or "InstantWeapon" or "ConstantWeapon" or "ChargedWeapon" or "AutoWeapon" or "LockWeapon";
|
||||
}
|
||||
|
||||
static bool IsNonEmptyLegacyRefMissingItemKey(AetheriaBehaviorValue value)
|
||||
{
|
||||
return string.Equals(value.Kind, "legacy-id", StringComparison.OrdinalIgnoreCase) &&
|
||||
!IsEmptyLegacyId(value.LegacyIdValue) &&
|
||||
string.IsNullOrWhiteSpace(value.ItemKeyValue);
|
||||
}
|
||||
|
||||
static bool IsEmptyLegacyId(string legacyId)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(legacyId) ||
|
||||
(Guid.TryParse(legacyId, out var parsed) && parsed == Guid.Empty);
|
||||
}
|
||||
|
||||
static async Task RequireLegacyLookupAsync<T>(
|
||||
string legacyId,
|
||||
Func<Task<T?>> lookup,
|
||||
|
|
|
|||
|
|
@ -312,4 +312,7 @@ public sealed class AetheriaBehaviorValue
|
|||
|
||||
[Key(6)]
|
||||
public AetheriaBehaviorMapEntry[] MapEntries { get; set; } = [];
|
||||
|
||||
[Key(7)]
|
||||
public string ItemKeyValue { get; set; } = "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,16 +103,16 @@ gameplay, HUD, inventory, trade, ship, and zone helper lookups use `ItemKey`
|
|||
directly instead of deriving `ItemId` and searching by legacy GUID.
|
||||
The shared runtime item catalog reader is also item-key-only now: its GUID index,
|
||||
`GetRuntimeItem(Guid)` entry point, raw GUID string fallback,
|
||||
`AetheriaRuntimeItemReference(Guid)` constructor, and reverse legacy-GUID
|
||||
projections have been deleted. `FromLegacyId` remains only as an explicit
|
||||
migration/projection helper.
|
||||
`AetheriaRuntimeItemReference(Guid)` constructor, `FromLegacyId`, and reverse
|
||||
legacy-GUID projections have been deleted.
|
||||
The old generic `RuntimeCatalogLink<T>` abstraction, `ItemManager.GetData`
|
||||
hydration path, vague `ItemInstance.Data` identity field, and old
|
||||
`RuntimeItemReference.Projection` cache have been deleted; runtime item facts
|
||||
come from typed catalog rows.
|
||||
ItemManager's behavior payload bridge no longer exposes a generic GUID reader;
|
||||
migrated legacy-id behavior payload fields cross only through the explicit
|
||||
item-key projection helper.
|
||||
ItemManager's behavior payload bridge no longer exposes a generic GUID reader
|
||||
or item GUID projection helper. Migrated legacy-id behavior payload fields carry
|
||||
`LegacyIdValue` as provenance/backfill only; gameplay item behavior config reads
|
||||
the typed `ItemKeyValue` emitted by import/runtime projection.
|
||||
Loadout generation now applies typed catalog prefilters for item category,
|
||||
hardpoint type, shape fit, hull type, and behavior kind, then instantiates
|
||||
generated equipment directly from typed runtime rows.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using Unity.Mathematics;
|
||||
|
||||
public interface INamedEntry
|
||||
|
|
@ -12,8 +11,6 @@ public interface INamedEntry
|
|||
|
||||
public class AetheriaRuntimeItemReference
|
||||
{
|
||||
private const string LegacyItemDefinitionPrefix = "aetheria.item_definition:legacy:";
|
||||
|
||||
public string ItemKey;
|
||||
|
||||
public AetheriaRuntimeItemReference()
|
||||
|
|
@ -25,10 +22,6 @@ public class AetheriaRuntimeItemReference
|
|||
ItemKey = itemKey;
|
||||
}
|
||||
|
||||
public static string FromLegacyId(Guid legacyItemId)
|
||||
{
|
||||
return legacyItemId == Guid.Empty ? "" : $"{LegacyItemDefinitionPrefix}{legacyItemId:D}";
|
||||
}
|
||||
}
|
||||
|
||||
public interface ITintInspector
|
||||
|
|
|
|||
|
|
@ -415,9 +415,8 @@ public class ItemManager
|
|||
public string ItemKey(int key, string fallback = "")
|
||||
{
|
||||
return _fields.TryGetValue(key, out var value) &&
|
||||
System.Guid.TryParse(value.LegacyIdValue, out var itemId) &&
|
||||
itemId != System.Guid.Empty
|
||||
? AetheriaRuntimeItemReference.FromLegacyId(itemId)
|
||||
!string.IsNullOrWhiteSpace(value.ItemKeyValue)
|
||||
? value.ItemKeyValue
|
||||
: fallback;
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue