Properly link flecs library
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef FIND_ENTITY_H
|
||||
#define FIND_ENTITY_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "find_entity/bake_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
)
|
||||
(.)
|
||||
.|.
|
||||
| |
|
||||
_.--| |--._
|
||||
.-'; ;`-'& ; `&.
|
||||
\ & ; & &_/
|
||||
|"""---...---"""|
|
||||
\ | | | | | | | /
|
||||
`---.|.|.|.---'
|
||||
|
||||
* This file is generated by bake.lang.c for your convenience. Headers of
|
||||
* dependencies will automatically show up in this file. Include bake_config.h
|
||||
* in your main project file. Do not edit! */
|
||||
|
||||
#ifndef FIND_ENTITY_BAKE_CONFIG_H
|
||||
#define FIND_ENTITY_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include <flecs.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "find_entity",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"language": "c++",
|
||||
"public": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <find_entity.h>
|
||||
#include <iostream>
|
||||
|
||||
struct Position {
|
||||
int x, y;
|
||||
};
|
||||
|
||||
int main() {
|
||||
flecs::world ecs;
|
||||
|
||||
ecs.entity("e1").set<Position>({10, 20});
|
||||
ecs.entity("e2").set<Position>({20, 30});
|
||||
|
||||
// Create a simple query for component Position
|
||||
flecs::query<Position> q = ecs.query<Position>();
|
||||
|
||||
// Find the entity for which Position.x is 20
|
||||
flecs::entity e = q.find([](Position& p) {
|
||||
return p.x == 20;
|
||||
});
|
||||
|
||||
if (e) {
|
||||
std::cout << "Found entity " << e.path() << std::endl;
|
||||
} else {
|
||||
std::cout << "No entity found" << std::endl;
|
||||
}
|
||||
|
||||
// Output
|
||||
// Found entity ::e2
|
||||
}
|
||||
Reference in New Issue
Block a user