using System.Text.Json; using Cthangover.Core.Mods; namespace Cthangover.Validator { /// /// Shared skeleton for implementations: /// iterates the envelope's items, resolves each entity id case-insensitively /// and records the declaration. Kinds that carry no extra structure (quests, /// skills, status effects) only override ; richer kinds /// override to add declared keys and references /// through . /// public abstract class EntityKindStrategy : IEntityKindStrategy { /// public abstract string Kind { get; } /// public void Collect(ValidationContext context, IModInfo mod, string file, JsonElement items) { foreach (var item in items.EnumerateArray()) { context.ThrowIfCancellationRequested(); var id = JsonReadHelper.GetString(item, "Id", "ID", "id"); if (string.IsNullOrWhiteSpace(id)) continue; CollectEntity(context, mod, file, id, item); } } /// /// Records one entity. The default implementation adds the declaration /// under , which doubles as the graph vocabulary /// (). /// protected virtual void CollectEntity(ValidationContext context, IModInfo mod, string file, string id, JsonElement item) { context.Graph.AddDeclaration(Kind, id, mod.Id, file, 0); } } }