|
|
|
using System;
|
|
|
|
using gaemstone.Utility;
|
|
|
|
using static flecs_hub.flecs;
|
|
|
|
|
|
|
|
namespace gaemstone.ECS;
|
|
|
|
|
|
|
|
public unsafe partial class World
|
|
|
|
: IDisposable
|
|
|
|
{
|
|
|
|
public ecs_world_t* Handle { get; }
|
|
|
|
|
|
|
|
// Flecs built-ins that are important to internals.
|
|
|
|
internal EntityRef ChildOf { get; }
|
|
|
|
internal EntityRef Disabled { get; }
|
|
|
|
|
|
|
|
public bool IsDeferred => ecs_is_deferred(this);
|
|
|
|
public bool IsQuitRequested => ecs_should_quit(this);
|
|
|
|
|
|
|
|
public World(params string[] args)
|
|
|
|
{
|
|
|
|
ecs_os_set_api_defaults();
|
|
|
|
var api = ecs_os_get_api();
|
|
|
|
api.abort_ = new FnPtr_Void { Pointer = &FlecsAbortException.Callback };
|
|
|
|
ecs_os_set_api(&api);
|
|
|
|
|
|
|
|
Handle = ecs_init_w_args(args.Length, null);
|
|
|
|
|
|
|
|
ChildOf = LookupByPathOrThrow("/flecs/core/ChildOf");
|
|
|
|
Disabled = LookupByPathOrThrow("/flecs/core/Disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
=> ecs_fini(this);
|
|
|
|
|
|
|
|
|
|
|
|
public EntityBuilder New(EntityPath? path = null)
|
|
|
|
=> new(this, default, path);
|
|
|
|
|
|
|
|
public EntityBuilder New(EntityRef? parent, EntityPath? path = null)
|
|
|
|
=> new(this, parent, 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;
|
|
|
|
}
|