Alternative managed wrapper around flecs-cs bindings for using the ECS framework Flecs in modern .NET.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using System;
|
|
|
|
using static flecs_hub.flecs;
|
|
|
|
|
|
|
|
namespace gaemstone.ECS;
|
|
|
|
|
|
|
|
public unsafe partial class World
|
|
|
|
{
|
|
|
|
public ecs_world_t* Handle { get; }
|
|
|
|
|
|
|
|
// Flecs built-ins that are important to internals.
|
|
|
|
internal EntityRef ChildOf { get; }
|
|
|
|
internal EntityRef Disabled { get; }
|
|
|
|
internal EntityRef DependsOn { get; }
|
|
|
|
|
|
|
|
public bool IsDeferred => ecs_is_deferred(this);
|
|
|
|
public bool IsQuitRequested => ecs_should_quit(this);
|
|
|
|
|
|
|
|
public World(params string[] args)
|
|
|
|
{
|
|
|
|
Handle = ecs_init_w_args(args.Length, null);
|
|
|
|
|
|
|
|
ChildOf = LookupByPathOrThrow("/flecs/core/ChildOf");
|
|
|
|
Disabled = LookupByPathOrThrow("/flecs/core/Disabled");
|
|
|
|
DependsOn = LookupByPathOrThrow("/flecs/core/DependsOn");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
=> ecs_fini(this);
|
|
|
|
|
|
|
|
public EntityBuilder New(EntityPath? path = null)
|
|
|
|
=> new(this, path);
|
|
|
|
|
|
|
|
public bool Progress(TimeSpan delta)
|
|
|
|
=> ecs_progress(this, (float)delta.TotalSeconds);
|
|
|
|
|
|
|
|
public void Quit()
|
|
|
|
=> ecs_quit(this);
|
|
|
|
|
|
|
|
public static implicit operator ecs_world_t*(World w) => w.Handle;
|
|
|
|
}
|