-
-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55e1611
commit a016e60
Showing
12 changed files
with
606 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
24 changes: 24 additions & 0 deletions
24
examples/cpp/queries/find_entity/include/find_entity/bake_config.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"id": "find_entity", | ||
"type": "application", | ||
"value": { | ||
"use": [ | ||
"flecs" | ||
], | ||
"language": "c++", | ||
"public": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <find_entity.h> | ||
#include <iostream> | ||
|
||
struct Position { | ||
double 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.0; | ||
}); | ||
|
||
if (e) { | ||
std::cout << "Found entity " << e.path() << std::endl; | ||
} else { | ||
std::cout << "No entity found" << std::endl; | ||
} | ||
|
||
// Output | ||
// Found entity ::e2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.