//
#nullable enable
namespace GFramework.Game.Config.Generated;
///
/// Auto-generated table wrapper for schema file 'monster.schema.json'.
/// The wrapper keeps generated call sites strongly typed while delegating actual storage to the runtime config table implementation.
///
public sealed partial class MonsterTable : global::GFramework.Game.Abstractions.Config.IConfigTable
{
private readonly global::GFramework.Game.Abstractions.Config.IConfigTable _inner;
private readonly global::System.Lazy>> _nameIndex;
///
/// Creates a generated table wrapper around the runtime config table instance.
///
/// The runtime config table instance.
public MonsterTable(global::GFramework.Game.Abstractions.Config.IConfigTable inner)
{
_inner = inner ?? throw new global::System.ArgumentNullException(nameof(inner));
_nameIndex = new global::System.Lazy>>(
BuildNameIndex,
global::System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
}
///
public global::System.Type KeyType => _inner.KeyType;
///
public global::System.Type ValueType => _inner.ValueType;
///
public int Count => _inner.Count;
///
public MonsterConfig Get(int key)
{
return _inner.Get(key);
}
///
public bool TryGet(int key, out MonsterConfig? value)
{
return _inner.TryGet(key, out value);
}
///
public bool ContainsKey(int key)
{
return _inner.ContainsKey(key);
}
///
public global::System.Collections.Generic.IReadOnlyCollection All()
{
return _inner.All();
}
///
/// Builds the exact-match lookup index declared for property 'name'.
///
/// A read-only lookup index keyed by Name.
private global::System.Collections.Generic.IReadOnlyDictionary> BuildNameIndex()
{
return BuildLookupIndex(static config => config.Name);
}
///
/// Materializes a read-only exact-match lookup index from the current table snapshot.
///
/// Indexed property type.
/// Selects the indexed property from one config entry.
/// A read-only dictionary whose values preserve snapshot iteration order.
private global::System.Collections.Generic.IReadOnlyDictionary> BuildLookupIndex(
global::System.Func keySelector)
where TProperty : notnull
{
var buckets = new global::System.Collections.Generic.Dictionary>();
// Capture the current table snapshot once so indexed lookups stay deterministic for this wrapper instance.
foreach (var candidate in All())
{
var key = keySelector(candidate);
if (!buckets.TryGetValue(key, out var matches))
{
matches = new global::System.Collections.Generic.List();
buckets.Add(key, matches);
}
matches.Add(candidate);
}
var materialized = new global::System.Collections.Generic.Dictionary>(buckets.Count, buckets.Comparer);
foreach (var pair in buckets)
{
materialized.Add(pair.Key, global::System.Array.AsReadOnly(pair.Value.ToArray()));
}
return new global::System.Collections.ObjectModel.ReadOnlyDictionary>(materialized);
}
///
/// Finds all config entries whose property 'name' equals the supplied value.
///
/// The property value to match.
/// A read-only snapshot containing every matching config entry.
///
/// This property declares x-gframework-index, so the generated helper resolves matches through a lazily materialized read-only lookup index built from the current table snapshot.
///
public global::System.Collections.Generic.IReadOnlyList FindByName(string value)
{
if (_nameIndex.Value.TryGetValue(value, out var matches))
{
return matches;
}
return global::System.Array.Empty();
}
///
/// Tries to find the first config entry whose property 'name' equals the supplied value.
///
/// The property value to match.
/// The first matching config entry when lookup succeeds; otherwise .
/// when a matching config entry is found; otherwise .
///
/// This property declares x-gframework-index, so the generated helper returns the first element from the lazily materialized exact-match bucket.
///
public bool TryFindFirstByName(string value, out MonsterConfig? result)
{
if (_nameIndex.Value.TryGetValue(value, out var matches) && matches.Count > 0)
{
result = matches[0];
return true;
}
result = null;
return false;
}
///
/// Finds all config entries whose property 'hp' equals the supplied value.
///
/// The property value to match.
/// A read-only snapshot containing every matching config entry.
///
/// The generated helper performs a deterministic linear scan over so it stays compatible with runtime hot reload and does not require secondary index infrastructure.
///
public global::System.Collections.Generic.IReadOnlyList FindByHp(int? value)
{
var matches = new global::System.Collections.Generic.List();
// Scan the current table snapshot on demand so generated helpers stay aligned with reloadable runtime data.
foreach (var candidate in All())
{
if (global::System.Collections.Generic.EqualityComparer.Default.Equals(candidate.Hp, value))
{
matches.Add(candidate);
}
}
return matches.Count == 0 ? global::System.Array.Empty() : matches.AsReadOnly();
}
///
/// Tries to find the first config entry whose property 'hp' equals the supplied value.
///
/// The property value to match.
/// The first matching config entry when lookup succeeds; otherwise .
/// when a matching config entry is found; otherwise .
///
/// The generated helper walks the same snapshot exposed by and returns the first match in iteration order.
///
public bool TryFindFirstByHp(int? value, out MonsterConfig? result)
{
// Keep the search path allocation-free for the first-match case by exiting as soon as one entry matches.
foreach (var candidate in All())
{
if (global::System.Collections.Generic.EqualityComparer.Default.Equals(candidate.Hp, value))
{
result = candidate;
return true;
}
}
result = null;
return false;
}
}