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.

31 lines
698 B

using System;
using gaemstone.Utility;
using static flecs_hub.flecs;
namespace gaemstone.ECS;
public unsafe sealed class Rule
: IDisposable
{
public World World { get; }
public ecs_rule_t* Handle { get; }
public Rule(World world, FilterDesc desc)
{
using var alloc = TempAllocator.Use();
var flecsDesc = desc.ToFlecs(alloc);
World = world;
Handle = ecs_rule_init(world, &flecsDesc);
}
public void Dispose()
=> ecs_rule_fini(this);
public Iterator Iter()
=> new(World, IteratorType.Rule, ecs_rule_iter(World, this));
public override string ToString()
=> ecs_rule_str(Handle).FlecsToStringAndFree()!;
public static implicit operator ecs_rule_t*(Rule q) => q.Handle;
}