You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 12, 2021. It is now read-only.
Hello,
My system doesn't get any entity with getEntities(): class AISystem : public anax::System<anax::Requires<Components::Path, Components::Position, Components::MoveTo>>
In update(): auto entities = getEntities();
So, I have a function which create a character.
` inline anax::Entity make_character(anax::World& w, ...)
{
anax::Entity e = w.createEntity();
} And I use this in my "main" class:
//...
m_char = make_character(...);
m_char.activate();
m_world.refresh();
`
And I use AISystem::update() in the event loop.
But the vector of entities is always empty... Why ?
Thanks.
The text was updated successfully, but these errors were encountered:
I saw the problem !
(it wasn't activate())
When adding the system to the world after creating and entity and adding the components to it, the system doesn't detect the entity...
I have to add the system before creating the entity
So... it is a bug right ?
When you call world.refresh() it will notify all the systems you have attached currently, i.e. the systems getEntities() attribute will hold the invariant that they contain the appropriate entities. Any system not currently added will not work.
The only solution that I can think of to "resolve" this is either:
Add the systems beforehand
Change the implementation to query the entities each time a call to getEntities() is made
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
My system doesn't get any entity with getEntities():
class AISystem : public anax::System<anax::Requires<Components::Path, Components::Position, Components::MoveTo>>
In update():
auto entities = getEntities();
So, I have a function which create a character.
` inline anax::Entity make_character(anax::World& w, ...)
{
anax::Entity e = w.createEntity();
}
And I use this in my "main" class:
//...
m_char = make_character(...);
m_char.activate();
m_world.refresh();
`
And I use AISystem::update() in the event loop.
But the vector of entities is always empty... Why ?
Thanks.
The text was updated successfully, but these errors were encountered: