Skip to content

Component<T>

Namespace Mc.Scripting · Kind class (static)

public static class Component<T> where T : unmanaged

Per-type component id cache. Set by Ecs.RegisterComponent.

The cache is one slot per CLR type for the whole process, so a component type must be owned by a single plugin (declare your own struct; do not register a shared type such as Vec3d under different keys from different plugins). Registering a type that is already bound to another key throws. The binding is cleared when the registering plugin unloads.

You rarely use this type directly: Ecs.RegisterComponent<T>(key) fills it, and Entity.Get<T>() and friends read the cached id from it.

Member Description
static ulong Id { get; } ECS component id, 0 if not registered.
static string? Key { get; } The key the component type is registered under, null if unregistered.
public static ulong Id { get; }

ECS component id, 0 if not registered.

public static string? Key { get; }

The key the component type is registered under, null if unregistered.