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
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
Methods
Get(Type)
Gets the component info for a type, or null if not registered.
public ComponentInfo? Get(Type type)
Parameters
typeType
Returns
GetById(ComponentId)
Gets the component info by its ID, or null if the ID is invalid.
public ComponentInfo? GetById(ComponentId id)
Parameters
idComponentIdThe 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
namestringThe 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
isTagbool
Returns
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
Type Parameters
T
IsRegistered<T>()
Checks if a component type is registered.
public bool IsRegistered<T>() where T : struct, IComponent
Returns
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
isTagboolWhether this is a tag component.
Returns
- ComponentInfo
The component info for this type.
Type Parameters
TThe component type.
TryGetByName(string, out ComponentInfo?)
Tries to get the component info by type name.
public bool TryGetByName(string name, out ComponentInfo? info)
Parameters
namestringThe component type name to look up.
infoComponentInfoWhen this method returns, contains the component info if found; otherwise, null.
Returns
- bool
trueif a component with the specified name was found; otherwise,false.