// #nullable enable namespace GFramework.Game.Config.Generated; /// /// Auto-generated registration and lookup helpers for schema file 'monster.schema.json'. /// The helper centralizes table naming, config directory, schema path, and strongly-typed registry access so consumer projects do not need to duplicate the same conventions. /// public static class MonsterConfigBindings { /// /// Describes one schema property that declares x-gframework-ref-table metadata. /// public readonly struct ReferenceMetadata { /// /// Initializes one generated cross-table reference descriptor. /// /// Schema property path. /// Referenced runtime table name. /// Schema scalar type used by the reference value. /// Whether the property stores multiple reference keys. public ReferenceMetadata( string displayPath, string referencedTableName, string valueSchemaType, bool isCollection) { DisplayPath = displayPath ?? throw new global::System.ArgumentNullException(nameof(displayPath)); ReferencedTableName = referencedTableName ?? throw new global::System.ArgumentNullException(nameof(referencedTableName)); ValueSchemaType = valueSchemaType ?? throw new global::System.ArgumentNullException(nameof(valueSchemaType)); IsCollection = isCollection; } /// /// Gets the schema property path such as dropItems or phases[].monsterId. /// public string DisplayPath { get; } /// /// Gets the runtime registration name of the referenced config table. /// public string ReferencedTableName { get; } /// /// Gets the schema scalar type used by the referenced key value. /// public string ValueSchemaType { get; } /// /// Gets a value indicating whether the property stores multiple reference keys. /// public bool IsCollection { get; } } /// /// Groups the schema-derived metadata constants so consumer code can reuse one stable entry point. /// public static class Metadata { /// /// Gets the logical config domain derived from the schema base name. The current runtime convention keeps this value aligned with the generated table name. /// public const string ConfigDomain = "monster"; /// /// Gets the runtime registration name of the generated config table. /// public const string TableName = "monster"; /// /// Gets the config directory path expected by the generated registration helper. /// public const string ConfigRelativePath = "monster"; /// /// Gets the schema file path expected by the generated registration helper. /// public const string SchemaRelativePath = "schemas/monster.schema.json"; } /// /// Gets the logical config domain derived from the schema base name. The current runtime convention keeps this value aligned with the generated table name. /// public const string ConfigDomain = Metadata.ConfigDomain; /// /// Gets the runtime registration name of the generated config table. /// public const string TableName = Metadata.TableName; /// /// Gets the config directory path expected by the generated registration helper. /// public const string ConfigRelativePath = Metadata.ConfigRelativePath; /// /// Gets the schema file path expected by the generated registration helper. /// public const string SchemaRelativePath = Metadata.SchemaRelativePath; /// /// Exposes generated metadata for schema properties that declare x-gframework-ref-table. /// public static class References { /// /// Gets generated reference metadata for schema property path 'dropItems'. /// public static readonly ReferenceMetadata DropItems = new( "dropItems", "item", "string", true); /// /// Gets generated reference metadata for schema property path 'phases[].monsterId'. /// public static readonly ReferenceMetadata PhasesItemsMonsterId = new( "phases[].monsterId", "monster", "string", false); /// /// Gets all generated cross-table reference descriptors for the current schema. /// public static global::System.Collections.Generic.IReadOnlyList All { get; } = global::System.Array.AsReadOnly(new ReferenceMetadata[] { DropItems, PhasesItemsMonsterId, }); /// /// Tries to resolve generated reference metadata by schema property path. /// /// Schema property path. /// Resolved generated reference metadata when the path is known; otherwise the default value. /// True when the schema property path has generated cross-table metadata; otherwise false. public static bool TryGetByDisplayPath(string displayPath, out ReferenceMetadata metadata) { if (displayPath is null) { throw new global::System.ArgumentNullException(nameof(displayPath)); } if (string.Equals(displayPath, "dropItems", global::System.StringComparison.Ordinal)) { metadata = DropItems; return true; } if (string.Equals(displayPath, "phases[].monsterId", global::System.StringComparison.Ordinal)) { metadata = PhasesItemsMonsterId; return true; } metadata = default; return false; } } /// /// Registers the generated config table using the schema-derived runtime conventions. /// /// The target YAML config loader. /// Optional key comparer for the generated table registration. /// The same loader instance so registration can keep chaining. public static global::GFramework.Game.Config.YamlConfigLoader RegisterMonsterTable( this global::GFramework.Game.Config.YamlConfigLoader loader, global::System.Collections.Generic.IEqualityComparer? comparer = null) { if (loader is null) { throw new global::System.ArgumentNullException(nameof(loader)); } return loader.RegisterTable( Metadata.TableName, Metadata.ConfigRelativePath, Metadata.SchemaRelativePath, static config => config.Id, comparer); } /// /// Gets the generated config table wrapper from the registry. /// /// The source config registry. /// The generated strongly-typed table wrapper. /// When is null. public static MonsterTable GetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry) { if (registry is null) { throw new global::System.ArgumentNullException(nameof(registry)); } return new MonsterTable(registry.GetTable(Metadata.TableName)); } /// /// Tries to get the generated config table wrapper from the registry. /// /// The source config registry. /// The generated strongly-typed table wrapper when lookup succeeds; otherwise null. /// True when the generated table is registered and type-compatible; otherwise false. /// When is null. public static bool TryGetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry, out MonsterTable? table) { if (registry is null) { throw new global::System.ArgumentNullException(nameof(registry)); } if (registry.TryGetTable(Metadata.TableName, out var innerTable) && innerTable is not null) { table = new MonsterTable(innerTable); return true; } table = null; return false; } }