diff --git a/src/flecs-cs b/src/flecs-cs
index 2e82db1..a204798 160000
--- a/src/flecs-cs
+++ b/src/flecs-cs
@@ -1 +1 @@
-Subproject commit 2e82db165948e073b813ac712bedd00c70627d03
+Subproject commit a2047983917aa462a8c2f34d5315aea48502f4d8
diff --git a/src/gaemstone/ECS/Filter.cs b/src/gaemstone/ECS/Filter.cs
index c62f02a..a1cf8bf 100644
--- a/src/gaemstone/ECS/Filter.cs
+++ b/src/gaemstone/ECS/Filter.cs
@@ -25,7 +25,7 @@ public unsafe sealed class Filter
public static void RunOnce(Universe universe, Delegate action)
{
var gen = IterActionGenerator.GetOrBuild(universe, action.Method);
- var desc = new FilterDesc(gen.Terms.ToArray()) { Name = action.Method.Name };
+ var desc = new FilterDesc(gen.Terms.ToArray());
using var filter = new Filter(universe, desc);
foreach (var iter in filter.Iter()) gen.RunWithTryCatch(action.Target, iter);
}
@@ -48,12 +48,6 @@ public class FilterDesc
public string? Expression { get; }
- ///
- /// Optional name of filter, used for debugging. If a filter is created
- /// for a system, the provided name should match the system name.
- ///
- public string? Name { get; set; }
-
///
/// When true, terms returned by an iterator may either contain 1 or N
/// elements, where terms with N elements are owned, and terms with 1
@@ -63,6 +57,11 @@ public class FilterDesc
///
public bool Instanced { get; set; }
+ ///
+ /// Entity associated with query (optional).
+ ///
+ public Entity Entity { get; set; }
+
public FilterDesc(params Term[] terms)
=> Terms = terms;
public FilterDesc(string expression) : this()
@@ -71,9 +70,9 @@ public class FilterDesc
public unsafe ecs_filter_desc_t ToFlecs(IAllocator allocator)
{
var desc = new ecs_filter_desc_t {
- name = allocator.AllocateCString(Name),
- expr = allocator.AllocateCString(Expression),
+ expr = allocator.AllocateCString(Expression),
instanced = Instanced,
+ entity = Entity,
};
var span = desc.terms;
if (Terms.Count > span.Length) {
diff --git a/src/gaemstone/ECS/Observer.cs b/src/gaemstone/ECS/Observer.cs
index ae001d1..6f6b9d1 100644
--- a/src/gaemstone/ECS/Observer.cs
+++ b/src/gaemstone/ECS/Observer.cs
@@ -20,12 +20,12 @@ public class ObserverAttribute : ObserverAttribute
public static class ObserverExtensions
{
public static unsafe EntityRef RegisterObserver(this Universe universe,
- FilterDesc filter, Entity @event, Action callback)
+ string? name, FilterDesc filter, Entity @event, Action callback)
{
using var alloc = TempAllocator.Use();
var desc = new ecs_observer_desc_t {
filter = filter.ToFlecs(alloc),
- entity = universe.New((filter.Name != null) ? new(filter.Name) : null).Build(),
+ entity = universe.New((name != null) ? EntityPath.Parse(name) : null).Build(),
binding_ctx = (void*)CallbackContextHelper.Create((universe, callback)),
callback = new() { Data = new() { Pointer = &Callback } },
};
@@ -55,9 +55,8 @@ public static class ObserverExtensions
iterAction = iter => gen.RunWithTryCatch(instance, iter);
}
- filter.Name = method.Name;
var @event = universe.LookupOrThrow(attr.Event);
- return universe.RegisterObserver(filter, @event, iterAction);
+ return universe.RegisterObserver(method.Name, filter, @event, iterAction);
}
[UnmanagedCallersOnly]
diff --git a/src/gaemstone/ECS/System.cs b/src/gaemstone/ECS/System.cs
index b708e2a..4f3d490 100644
--- a/src/gaemstone/ECS/System.cs
+++ b/src/gaemstone/ECS/System.cs
@@ -30,12 +30,12 @@ public class ExpressionAttribute : Attribute
public static class SystemExtensions
{
private static unsafe EntityRef RegisterSystem(this Universe universe,
- QueryDesc query, Entity phase, CallbackContext callback)
+ string? name, QueryDesc query, Entity phase, CallbackContext callback)
{
using var alloc = TempAllocator.Use();
var desc = new ecs_system_desc_t {
- query = query.ToFlecs(alloc),
- entity = universe.New((query.Name != null) ? new(query.Name) : null)
+ query = query.ToFlecs(alloc),
+ entity = universe.New((name != null) ? EntityPath.Parse(name) : null)
.Add(phase).Add(phase).Build(),
binding_ctx = (void*)CallbackContextHelper.Create(callback),
// TODO: Use binding_ctx_free to remove clear the context.
@@ -59,9 +59,9 @@ public static class SystemExtensions
callback = iter => gen.RunWithTryCatch(action.Target, iter);
}
- query.Name = action.Method.Name;
var phase = universe.LookupOrThrow(attr?.Phase ?? typeof(SystemPhase.OnUpdate));
- return universe.RegisterSystem(query, phase, new(universe, action.Method, callback));
+ return universe.RegisterSystem(action.Method.Name,
+ query, phase, new(universe, action.Method, callback));
}
public static EntityRef RegisterSystem(this Universe universe,
@@ -83,9 +83,9 @@ public static class SystemExtensions
callback = iter => gen.RunWithTryCatch(instance, iter);
}
- query.Name = method.Name;
var phase = universe.LookupOrThrow(attr?.Phase ?? typeof(SystemPhase.OnUpdate));
- return universe.RegisterSystem(query, phase, new(universe, method, callback));
+ return universe.RegisterSystem(method.Name,
+ query, phase, new(universe, method, callback));
}
private class CallbackContext