31 lines
968 B
C#
31 lines
968 B
C#
using ExampleWorld.wit.imports.lyra.api;
|
|
|
|
namespace LyraApi.Ecs;
|
|
|
|
public readonly struct ComponentInfo
|
|
{
|
|
internal readonly IEcs.ComponentInfo info;
|
|
|
|
public readonly string? HostName => info.hostName;
|
|
public readonly ulong Size => info.size;
|
|
public readonly ulong Alignment => info.alignment;
|
|
public readonly ulong TypeId => info.typeId.inner.Item1;
|
|
|
|
public ComponentInfo(IEcs.ComponentInfo info)
|
|
{
|
|
this.info = info;
|
|
}
|
|
|
|
public ComponentInfo(string hostName, ulong size, ulong alignment, ulong typeId)
|
|
{
|
|
var wasmTypeId = new IEcs.WasmTypeId((typeId, 0));
|
|
this.info = new IEcs.ComponentInfo(hostName, size, alignment, wasmTypeId);
|
|
}
|
|
|
|
public static ComponentInfo FromType<T>() where T : IComponent
|
|
{
|
|
var typeId = new IEcs.WasmTypeId((T.TypeId, 0));
|
|
var info = new IEcs.ComponentInfo(T.HostName, T.HostSize, T.HostAlignment, typeId);
|
|
return new ComponentInfo(info);
|
|
}
|
|
} |