-
Getting started with this library, and the very first system I tried to make seems to require a custom system setup. All I want is a system that can query entities with a certain tag, but QuerySystem seems to only support components as generic arguments (and you can't have zero generic arguments). It seems like I would have to make my own system base type, or make tags into components so I can query them normally... but both of these options feel wrong conceptually (since there are obvious abstractions for both in the library). Am I missing something? Queries themselves can have zero arguments and just be filtered by tag, but not in QuerySystems. I thought I could use BaseSystem to do what I want while retaining the whole "System" abstraction that currently exists, but there is no way to build / iterate over a simple query since no "current EntityStore" is passed into OnUpdateGroup, so the system would never know which EntityStore to run against. If I am approaching this all wrong, I would love to gain some insight. I think what is needed is the abstraction of QuerySystem but without the generic parameters. It would just let users provide a query directly. It might seem strange to iterate over entities with a tag without any data involved, but imagine a simple scenario like wanting entities to be destroyed at the end of the frame in a game engine. You could just throw a "DestroyAtEndOfFrameTag" on them and have a system take care of it. In my case, I simply want to know if any entities exist with a certain tag, but I would like to do it with the perf-debug features of BaseSystem. For now I will just make my own system base class, but maybe this could be considered. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
To filter the result set of a struct Pulsating : ITag { }
class PulseSystem : QuerySystem<Scale3>
{
public PulseSystem() => Filter.AnyTags(Tags.Get<Pulsating>());
protected override void OnUpdate() {
// ...
}
} In case you want to create a custom system by extending class CustomSystem : BaseSystem
{
protected override void OnUpdate() {
foreach (var store in SystemRoot.Stores) {
// iterate all entities in a store
foreach (var entity in store.Entities) { }
}
}
} You are right. A |
Beta Was this translation helpful? Give feedback.
To filter the result set of a
QuerySystem<>
with tags you can use itsFilter
property. E.g.In case you want to create a custom system by extending
BaseSystem
you can access the stores withSystemRoot.Stores
. E.g.You are right. A
QuerySy…