Table of Contents

Class ComponentRegistry

Namespace
KeenEyes
Assembly
KeenEyes.Core.dll

Registry that tracks component types for a specific World. Each World has its own registry, allowing isolated ECS instances.

public sealed class ComponentRegistry : IComponentRegistry
Inheritance
ComponentRegistry
Implements
IComponentRegistry
Inherited Members

Remarks

This class is thread-safe: component registration and lookup can be called concurrently from multiple threads.

Properties

All

All registered component types.

public IReadOnlyList<ComponentInfo> All { get; }

Property Value

IReadOnlyList<ComponentInfo>

Remarks

Returns a snapshot to allow safe iteration while other threads may register components.

Count

Number of registered component types.

public int Count { get; }

Property Value

int

Methods

Get(Type)

Gets the component info for a type, or null if not registered.

public ComponentInfo? Get(Type type)

Parameters

type Type

Returns

ComponentInfo

GetById(ComponentId)

Gets the component info by its ID, or null if the ID is invalid.

public ComponentInfo? GetById(ComponentId id)

Parameters

id ComponentId

The component ID to look up.

Returns

ComponentInfo

The component info, or null if the ID is out of range.

GetByName(string)

Gets the component info by type name (short name or full name).

public ComponentInfo? GetByName(string name)

Parameters

name string

The component type name (e.g., "Position" or "MyGame.Components.Position").

Returns

ComponentInfo

The component info, or null if no component with that name is registered.

Remarks

This method performs a case-insensitive search, first matching against the type's short name (e.g., "Position"), then against the full name (e.g., "MyGame.Components.Position").

This is useful for runtime tooling, debugging, and MCP tools where component types are specified by name rather than by generic type parameter.

GetOrRegister<T>(bool)

Gets or registers a component type.

public ComponentInfo GetOrRegister<T>(bool isTag = false) where T : struct, IComponent

Parameters

isTag bool

Returns

ComponentInfo

Type Parameters

T

Get<T>()

Gets the component info for a type, or null if not registered.

public ComponentInfo? Get<T>() where T : struct, IComponent

Returns

ComponentInfo

Type Parameters

T

IsRegistered<T>()

Checks if a component type is registered.

public bool IsRegistered<T>() where T : struct, IComponent

Returns

bool

Type Parameters

T

Register<T>(bool)

Registers a component type and returns its info. If already registered, returns the existing info.

public ComponentInfo Register<T>(bool isTag = false) where T : struct, IComponent

Parameters

isTag bool

Whether this is a tag component.

Returns

ComponentInfo

The component info for this type.

Type Parameters

T

The component type.

TryGetByName(string, out ComponentInfo?)

Tries to get the component info by type name.

public bool TryGetByName(string name, out ComponentInfo? info)

Parameters

name string

The component type name to look up.

info ComponentInfo

When this method returns, contains the component info if found; otherwise, null.

Returns

bool

true if a component with the specified name was found; otherwise, false.