Skip to content

Commit

Permalink
Fix relationship example by specifying inout.
Browse files Browse the repository at this point in the history
  • Loading branch information
garrett-is-a-swann committed Dec 29, 2023
1 parent 7b25032 commit 7aa5655
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit 7aa5655

Please sign in to comment.