Properly link flecs library
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef WILDCARDS_H
|
||||
#define WILDCARDS_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "wildcards/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 WILDCARDS_BAKE_CONFIG_H
|
||||
#define WILDCARDS_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include <flecs.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "wildcards",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"language": "c++",
|
||||
"public": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <wildcards.h>
|
||||
#include <iostream>
|
||||
|
||||
// Queries can have wildcard terms that can match multiple instances of a
|
||||
// relationship or relationship target.
|
||||
|
||||
struct Eats {
|
||||
int amount;
|
||||
};
|
||||
|
||||
struct Apples { };
|
||||
struct Pears { };
|
||||
|
||||
int main(int, char *[]) {
|
||||
flecs::world ecs;
|
||||
|
||||
// Create a query that matches edible components
|
||||
flecs::query<Eats> q = ecs.query_builder<Eats>()
|
||||
.term_at(1).second(flecs::Wildcard) // Change first argument to (Eats, *)
|
||||
.build();
|
||||
|
||||
// Create a few entities that match the query
|
||||
ecs.entity("Bob")
|
||||
.set<Eats, Apples>({10})
|
||||
.set<Eats, Pears>({5});
|
||||
|
||||
ecs.entity("Alice")
|
||||
.set<Eats, Apples>({4});
|
||||
|
||||
// Iterate the query with a flecs::iter. This makes it possible to inspect
|
||||
// the pair that we are currently matched with.
|
||||
q.each([](flecs::iter& it, size_t index, Eats& eats) {
|
||||
flecs::entity e = it.entity(index);
|
||||
flecs::entity food = it.pair(1).second();
|
||||
|
||||
std::cout << e.name() << " eats "
|
||||
<< eats.amount << " " << food.name() << std::endl;
|
||||
});
|
||||
|
||||
// Output:
|
||||
// Bob eats 10 Apples
|
||||
// Bob eats 5 Pears
|
||||
// Alice eats 4 Apples
|
||||
}
|
||||
Reference in New Issue
Block a user