ThingDomain.Present and Items; every constructor, factory and key builder passes each non-nullable reference parameter through Present (refusal names the slot, never a value) and each list through Items (a private read-only copy, nil items refused). Lists are IReadOnlyList on every type. TextInputNode's slot 2 property and parameter are InputKind, matching Rust input_kind. Tests: NilPositionTests reads the Rust vector row by row; PresenceTests and ReadOnlyListTests walk every door by reflection; InputKindNameTests. NameSetTests and the unit-arm rewrite follow. Unit-arm statics are still present in this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using GameCult.Caching;
|
|
using MessagePack;
|
|
|
|
namespace GameCult.Thing.Contract;
|
|
|
|
[MessagePackObject]
|
|
public sealed class AssetEntry
|
|
{
|
|
[Key(0)] public string Id { get; }
|
|
[Key(1)] public string MediaType { get; }
|
|
[Key(2)] public string Uri { get; }
|
|
[Key(3)] public int Width { get; }
|
|
[Key(4)] public int Height { get; }
|
|
|
|
public AssetEntry(string id, string mediaType, string uri, int width, int height)
|
|
{
|
|
Id = ThingDomain.Present(id, "Id");
|
|
MediaType = ThingDomain.Present(mediaType, "MediaType");
|
|
Uri = ThingDomain.Present(uri, "Uri");
|
|
Width = ThingDomain.Count(width);
|
|
Height = ThingDomain.Count(height);
|
|
}
|
|
}
|
|
|
|
[CultDocument("gamecult.thing.asset_catalog", "gamecult.thing.asset_catalog.v1")]
|
|
[MessagePackObject]
|
|
public sealed class AssetCatalog
|
|
{
|
|
[Key(0)] public string ProviderId { get; }
|
|
[Key(1)] public string CatalogId { get; }
|
|
[Key(2)] public long Version { get; }
|
|
[Key(3)] public IReadOnlyList<AssetEntry> Assets { get; }
|
|
|
|
public AssetCatalog(string providerId, string catalogId, long version, IReadOnlyList<AssetEntry> assets)
|
|
{
|
|
ProviderId = ThingDomain.Present(providerId, "ProviderId");
|
|
CatalogId = ThingDomain.Segment(catalogId);
|
|
Version = ThingDomain.Version(version);
|
|
Assets = ThingDomain.Items(assets, "Assets");
|
|
}
|
|
|
|
[IgnoreMember] public string RecordKey => ThingKeys.AssetCatalogKey(ProviderId, CatalogId);
|
|
}
|