Properly link flecs library
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef WITHOUT_H
|
||||
#define WITHOUT_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "without/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 WITHOUT_BAKE_CONFIG_H
|
||||
#define WITHOUT_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include <flecs.h>
|
||||
|
||||
#endif
|
||||
|
||||
11
engine/libs/flecs/examples/cpp/queries/without/project.json
Normal file
11
engine/libs/flecs/examples/cpp/queries/without/project.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "without",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"language": "c++",
|
||||
"public": false
|
||||
}
|
||||
}
|
||||
46
engine/libs/flecs/examples/cpp/queries/without/src/main.cpp
Normal file
46
engine/libs/flecs/examples/cpp/queries/without/src/main.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <without.h>
|
||||
#include <iostream>
|
||||
|
||||
struct Position {
|
||||
double x, y;
|
||||
};
|
||||
|
||||
struct Npc { };
|
||||
|
||||
int main(int, char *[]) {
|
||||
flecs::world ecs;
|
||||
|
||||
// Create a query for Position, !Npc. By adding the Npc component using the
|
||||
// "without" method, the component is not a part of the query type, and as a
|
||||
// result does not become part of the function signatures of each and iter.
|
||||
// This is useful for things like tags, which because they don't have a
|
||||
// value are less useful to pass to the each/iter functions as argument.
|
||||
//
|
||||
// The without method is short for:
|
||||
// .term<Npc>().not_()
|
||||
flecs::query<Position> q = ecs.query_builder<Position>()
|
||||
.without<Npc>()
|
||||
.build();
|
||||
|
||||
// Create a few test entities for the Position query
|
||||
ecs.entity("e1")
|
||||
.set<Position>({10, 20});
|
||||
|
||||
ecs.entity("e2")
|
||||
.set<Position>({10, 20});
|
||||
|
||||
// This entity will not match as it has Npc
|
||||
ecs.entity("e3")
|
||||
.set<Position>({10, 20})
|
||||
.add<Npc>();
|
||||
|
||||
|
||||
// Note how the Npc tag is not part of the each signature
|
||||
q.each([](flecs::entity e, Position& p) {
|
||||
std::cout << e.name() << ": {" << p.x << ", " << p.y << "}\n";
|
||||
});
|
||||
|
||||
// Output:
|
||||
// e1: {10, 20}
|
||||
// e2: {10, 20}
|
||||
}
|
||||
Reference in New Issue
Block a user