lyra-wasm-scripting-test/guests/csharp/dotnet-guest-test/ExampleWorldImpl.cs

32 lines
943 B
C#

namespace ExampleWorld;
using ExampleWorld.wit.imports.lyra.api;
using LyraApi.Ecs;
using LyraApi.Engine;
using LyraApi.Math;
public class ExampleWorldImpl : IExampleWorld
{
public static void OnInit(IEcs.EcsWorld gameWorld, IEcs.Entity owningEntity)
{
var world = new World(gameWorld);
Entity entity = world.Spawn(new Vec3(7.0f, 30.0f, 18.0f));
Console.WriteLine("C#: Spawned entity with id {0}", entity.Id);
foreach ((Entity en, Vec3 comp) in world.View<Vec3>())
{
Console.WriteLine("C#: Found entity at ({0}, {1}, {2})", comp.X, comp.Y, comp.Z);
}
DeltaTime? dt = world.GetResource<DeltaTime>();
if (dt != null) {
Console.WriteLine($"C#: Delta time: {dt?.Seconds:0.##}");
}
}
public static void OnUpdate(IEcs.EcsWorld gameWorld, IEcs.Entity owningEntity)
{
throw new NotImplementedException();
}
}