Class Ecs
- Namespace
- Kiln
- Assembly
- Kiln.Game.dll
The game's ECS types, generated from its reflection table: Ecs.Health, Ecs.NetworkHealth,
Ecs.Enemy01_State. keen::ecs::X and keen::X are Ecs.X; keen::ns::X is
Ecs.Ns_X. Every struct has the engine's exact layout on the build it was generated for, its game name, hash,
size and layout hash as static members, and implements IGameStruct<TSelf> (components
IGameComponent<TSelf>, events IGameEvent<TSelf>).
public static class Ecs
- Inheritance
-
Ecs
- Inherited Members
Remarks
Generated types. Every type nested in Ecs except ObjectReference and GameGuid (its game structs, ECS
components and events, enums, bitmasks and StaticArrayN<T>) is generated when Kiln.Game is built:
tools/typegen/typegen.py writes them from a layout dump of the game's reflection table, taken from one verified game
build (the dump is named by the SHA-256 of that build's executable). Each struct has that build's exact layout. At
its first use each type is checked against the running game (its live type table, or else that SHA-256), and a type
that differs reads as nothing (Supports<T>() is false, WhyNot<T>() says what differs) instead of wrong bytes. Their
field and enum-value docs come from the game's names and are not written by hand. How they are generated, named and
checked: Typed game data (typegen.md).
Properties
Available
True when kiln.world is available on this build, so the typed reads below can work. When it is not,
they throw KilnUnavailableException for the capability kiln.world. Any thread.
Thread: any thread
[AnyThread]
public static bool Available { get; }
Property Value
Methods
All<T>()
Every entity carrying component T; empty when T is not
supported on the running game.
Thread: tick thread only
[TickThreadOnly]
public static IReadOnlyList<EntityId> All<T>() where T : unmanaged, IGameComponent<T>
Returns
Type Parameters
T
Exceptions
- KilnUnavailableException
kiln.world is not available.
Get<T>(EntityId)
The component, or null when the entity does not have it or T is not supported
on the running game.
Thread: tick thread only
[TickThreadOnly]
public static T? Get<T>(EntityId entity) where T : unmanaged, IGameComponent<T>
Parameters
entityEntityId
Returns
- T?
Type Parameters
T
Exceptions
- KilnUnavailableException
kiln.world is not available.
Has<T>(EntityId)
True if the entity has component T; false too when T is not
supported on the running game.
Thread: tick thread only
[TickThreadOnly]
public static bool Has<T>(EntityId entity) where T : unmanaged, IGameComponent<T>
Parameters
entityEntityId
Returns
Type Parameters
T
Exceptions
- KilnUnavailableException
kiln.world is not available.
Supports<T>()
The first-use check's answer for T: true when its generated layout equals the
running game's (the game's type table, recursively through every type inside it), or, with no type table,
when this Kiln.Game was generated for exactly the running exe. Checked once per type; any thread.
Thread: any thread
[AnyThread]
public static bool Supports<T>() where T : unmanaged, IGameStruct<T>
Returns
Type Parameters
T
TryGet<T>(EntityId, out T)
Reads component T of entity. False when the entity has no
such component, or when T's generated layout does not match the running game
(Supports<T>(); the mod's log then has one warning naming the type and the difference).
Thread: tick thread only
[TickThreadOnly]
public static bool TryGet<T>(EntityId entity, out T value) where T : unmanaged, IGameComponent<T>
Parameters
entityEntityIdvalueT
Returns
Type Parameters
T
Exceptions
- KilnUnavailableException
kiln.world is not available (Available).
WhyNot<T>()
Null when T is supported (Supports<T>()), else the difference: the
type, the field or value, the generated and the live value. Any thread.
Thread: any thread
[AnyThread]
public static string? WhyNot<T>() where T : unmanaged, IGameStruct<T>
Returns
Type Parameters
T