examples/cpp/game_mechanics/inventory_system/src/main.cpp
// Almost the same as item_kind, but return name of prefab vs item kind. This
// returns a more user-friendly name, like "WoodenSword" vs. just "Sword"
Almost the same as item_kind, but return name of prefab vs item kind. This
returns a more user-friendly name, like "WoodenSword" vs. just "Sword"
Almost the same as item_kind but return name of prefab vs item kind . This returns a more user - friendly name like " WoodenSword " vs . just " Sword "
const char* item_name(flecs::entity item) {
    flecs::world world = item.world();
    const char *result = NULL;
    item.each([&](flecs::id id) {
        if (id.is_entity()) { 
            if (id.entity().has(flecs::IsA, world.id<Item>())) {
                result = id.entity().name();
            }
        } else if (id.is_pair()) {
            if (id.first() == flecs::IsA) {
                flecs::entity base_kind = item_kind(id.second());
                if (base_kind) {
                    result = id.second().name();
                }
            }
        }
    });
    return result;
}
const char * item_name ( flecs :: entity item ) { flecs :: world world = item . world ( ) ; const char * result = NULL ; item . each ( [ & ] ( flecs :: id id ) { if ( id . is_entity ( ) ) { if ( id . entity ( ) . has ( flecs :: IsA , world . id < Item > ( ) ) ) { result = id . entity ( ) . name ( ) ; } } else if ( id . is_pair ( ) ) { if ( id . first ( ) == flecs :: IsA ) { flecs :: entity base_kind = item_kind ( id . second ( ) ) ; if ( base_kind ) { result = id . second ( ) . name ( ) ; } } } } ) ; return result ; }
Almost the same as item_kind, but return name of prefab vs item kind.
Almost the same as item_kind but return name of prefab vs item kind .