lyra-wasm-scripting-test/guests/csharp/LyraApi/Ecs/World.cs

14 lines
465 B
C#
Raw Normal View History

namespace LyraApi.Ecs;
using ImportsWorld.wit.imports.lyra.api;
using LyraApi;
public class World(IEcs.EcsWorld world) {
private IEcs.EcsWorld Inner { get; set; } = world;
public Entity Spawn(params IComponent[] comps) {
List<IEcs.ComponentInfo> infos = comps.Select(c => c.GetComponentInfo()).ToList();
byte[] bytes = comps.SelectMany(c => Marshalling.GetBytes(c)).ToArray();
return new Entity(Inner.Spawn(bytes, infos));
}
}