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
726 B
31 lines
726 B
using System; |
|
using gaemstone.Utility; |
|
using static flecs_hub.flecs; |
|
|
|
namespace gaemstone.ECS; |
|
|
|
public unsafe sealed class Rule |
|
: IDisposable |
|
{ |
|
public Universe Universe { get; } |
|
public ecs_rule_t* Handle { get; } |
|
|
|
public Rule(Universe universe, FilterDesc desc) |
|
{ |
|
using var alloc = TempAllocator.Use(); |
|
var flecsDesc = desc.ToFlecs(alloc); |
|
Universe = universe; |
|
Handle = ecs_rule_init(universe, &flecsDesc); |
|
} |
|
|
|
public void Dispose() |
|
=> ecs_rule_fini(this); |
|
|
|
public Iterator Iter() |
|
=> new(Universe, IteratorType.Rule, ecs_rule_iter(Universe, this)); |
|
|
|
public override string ToString() |
|
=> ecs_rule_str(Handle).FlecsToStringAndFree()!; |
|
|
|
public static implicit operator ecs_rule_t*(Rule q) => q.Handle; |
|
}
|
|
|