Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix relationship example by specifying inout. #1107

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions examples/cpp/relationships/union/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ int main(int argc, char *argv[]) {
ecs.component<Direction>().add(flecs::Union);

// Create a query that subscribes for all entities that have a Direction
// and that are walking
// and that are walking.
// with<T>() requests no data by default, so we must specify what we want.
// in() requests Read-Only
flecs::query<> q = ecs.query_builder()
.with(Walking)
.with<Direction>(flecs::Wildcard)
.with(Walking).in()
.with<Direction>(flecs::Wildcard).in()
.build();

// Create a few entities with various state combinations
Expand All @@ -61,8 +63,8 @@ int main(int argc, char *argv[]) {
q.iter([&](const flecs::iter& it) {
// Get the column with direction states. This is stored as an array
// with identifiers to the individual states
auto movement = it.field<flecs::entity_t>(1);
auto direction = it.field<flecs::entity_t>(2);
auto movement = it.field<const flecs::entity_t>(1);
auto direction = it.field<const flecs::entity_t>(2);

for (auto i : it) {
// Movement will always be Walking, Direction can be any state
Expand Down