Table of Contents

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
object
Registry<T>
Implements

Constructors

Registry(string)

public Registry(string typeName)

Parameters

typeName string

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

key string

Returns

bool

Exists(ushort)

Check if numeric ID exists

public bool Exists(ushort id)

Parameters

id ushort

Returns

bool

Get(string)

Get entity by string key - use only during loading

public T Get(string key)

Parameters

key string

Returns

T

Get(ushort)

Get entity by numeric ID - primary runtime access method

public T Get(ushort id)

Parameters

id ushort

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

key string

Returns

ushort

Register(string, T)

Register a new entity with validation

public ushort Register(string key, T item)

Parameters

key string
item T

Returns

ushort

Replace(string, T)

Replace an existing entity (for mod support)

public void Replace(string key, T newItem)

Parameters

key string
newItem T

TryGet(string, out T)

Try get entity by string key

public bool TryGet(string key, out T item)

Parameters

key string
item T

Returns

bool

TryGetId(string, out ushort)

Try get ID by string key

public bool TryGetId(string key, out ushort id)

Parameters

key string
id ushort

Returns

bool