namespace LyraApi.Ecs; using ExampleWorld.wit.imports.lyra.api; using LyraApi; public class World(IEcs.EcsWorld world) { private IEcs.EcsWorld Inner { get; set; } = world; private Entity Spawn(List infos, params object[] comps) { byte[] bytes = comps.SelectMany(c => MarshalUtils.GetBytes(c)).ToArray(); return new Entity(Inner.Spawn(bytes, infos)); } public Entity Spawn(T1 c1) where T1 : IComponent { List infos = [ComponentInfo.FromType().info]; return Spawn(infos, c1); } public IEnumerable<(Entity, T1)> View() where T1 : IComponent { List comps = [Component.FromComponent()]; List infos = comps.Select(c => c.GetComponentInfo().info).ToList(); IEcs.EcsDynamicView dynamicView = Inner.View(infos); return new ViewResult(comps, dynamicView).Get(); } public T? GetResource() where T : IResource { IEcs.WorldResourceResult result = Inner.GetResource(Utils.ToWasmTypeId(T.TypeId)); return (T?) T.FromWasmResult(result); } }