Class ContentQueries
Allocation-free indexes over ContentDB — the queries that replace Addressables.LoadAssetsAsync(label)
in gameplay code (plan P3).
Why indexes instead of filtering on demand: the callers are hot paths (a loot roll, a spawn table pick) and the project forbids LINQ/allocation churn there. Indexes are rebuilt lazily after each content (re)load, so a mod reload is picked up without restarting.
Nothing here touches an asset: every answer comes from the generated index, which is the whole point (values without prefabs).
public static class ContentQueries
- Inheritance
-
objectContentQueries
Methods
- Invalidate()
Marks the indexes stale; the next query rebuilds them.
- ItemsOfLootCategory(string, int)
Items in a loot category (single flag name, e.g. "Weapon") at a quality level.
- ItemsOfQuality(int)
Items of a quality level (never null).
- MonstersOfRank(string)
Monsters of a rank ("Normal", "Elite", "Boss", …) — the rank comes from MonsterRankBehaviour.
- Pick(IReadOnlyList<ContentDef>, Random)
Picks one entry with the game's deterministic random (never returns an item when the list is empty). Takes the Random explicitly so callers keep using the synchronised generator.
- WeaponsOfQuality(int)
Weapons of a quality level (never null).