|
|
|
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;
|
|
|
|
}
|