From 7e05ef3ce798b7eafcf45bc3a1244df0d81824fc Mon Sep 17 00:00:00 2001 From: Sander Mertens Date: Sat, 30 Sep 2023 23:45:19 -0700 Subject: [PATCH] Add calls to target() to relationship basics example --- examples/c/relationships/basics/src/main.c | 8 ++++++++ examples/cpp/relationships/basics/src/main.cpp | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/examples/c/relationships/basics/src/main.c b/examples/c/relationships/basics/src/main.c index 88c56a934f..c352e905c2 100644 --- a/examples/c/relationships/basics/src/main.c +++ b/examples/c/relationships/basics/src/main.c @@ -34,5 +34,13 @@ int main(int argc, char *argv[]) { printf("Bob's type: [%s]\n", type_str); ecs_os_free(type_str); + // Get first target of relationship + printf("Bob eats %s\n", + ecs_get_name(ecs, ecs_get_target(ecs, bob, Eats, 0))); + + // Get second target of relationship + printf("Bob also eats %s\n", + ecs_get_name(ecs, ecs_get_target(ecs, bob, Eats, 1))); + return ecs_fini(ecs); } diff --git a/examples/cpp/relationships/basics/src/main.cpp b/examples/cpp/relationships/basics/src/main.cpp index 9b80696891..f622501533 100644 --- a/examples/cpp/relationships/basics/src/main.cpp +++ b/examples/cpp/relationships/basics/src/main.cpp @@ -42,4 +42,10 @@ int main(int, char*[]) { bob.each(flecs::Wildcard, pears, [](flecs::id id) { std::cout << "Bob " << id.first().name() << " pears\n"; }); + + // Get first target of relationship + std::cout << "Bob eats " << bob.target().name() << "\n"; + + // Get second target of relationship + std::cout << "Bob also eats " << bob.target(1).name() << "\n"; }