Class Registry<T>
- Namespace
- Core.Registries
- Assembly
- Core.dll
Generic registry implementation for game entities Provides O(1) lookups for both string keys and numeric IDs Follows data-linking-architecture.md specifications
public class Registry<T> : IRegistry<T> where T : class
Type Parameters
T
- Inheritance
-
objectRegistry<T>
- Implements
-
IRegistry<T>
Constructors
Registry(string)
public Registry(string typeName)
Parameters
typeNamestring
Properties
Count
Get the count of registered entities
public int Count { get; }
Property Value
- int
TypeName
Get the type name for error messages
public string TypeName { get; }
Property Value
- string
Methods
Exists(string)
Check if string key exists
public bool Exists(string key)
Parameters
keystring
Returns
- bool
Exists(ushort)
Check if numeric ID exists
public bool Exists(ushort id)
Parameters
idushort
Returns
- bool
Get(string)
Get entity by string key - use only during loading
public T Get(string key)
Parameters
keystring
Returns
- T
Get(ushort)
Get entity by numeric ID - primary runtime access method
public T Get(ushort id)
Parameters
idushort
Returns
- T
GetAll()
Get all entities (excluding null at index 0)
public IEnumerable<T> GetAll()
Returns
- IEnumerable<T>
GetAllIds()
Get all valid IDs (excluding 0)
public IEnumerable<ushort> GetAllIds()
Returns
- IEnumerable<ushort>
GetDiagnostics()
Get diagnostic information
public string GetDiagnostics()
Returns
- string
GetId(string)
Get numeric ID for string key
public ushort GetId(string key)
Parameters
keystring
Returns
- ushort
Register(string, T)
Register a new entity with validation
public ushort Register(string key, T item)
Parameters
keystringitemT
Returns
- ushort
Replace(string, T)
Replace an existing entity (for mod support)
public void Replace(string key, T newItem)
Parameters
keystringnewItemT
TryGet(string, out T)
Try get entity by string key
public bool TryGet(string key, out T item)
Parameters
keystringitemT
Returns
- bool
TryGetId(string, out ushort)
Try get ID by string key
public bool TryGetId(string key, out ushort id)
Parameters
keystringidushort
Returns
- bool