Properly link flecs library

This commit is contained in:
2023-11-09 11:38:29 +01:00
parent dc585396c3
commit 8edcf9305c
1392 changed files with 390081 additions and 164 deletions

View File

@@ -0,0 +1,16 @@
#ifndef SINGLETON_H
#define SINGLETON_H
/* This generated file contains includes for project dependencies */
#include "singleton/bake_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -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 SINGLETON_BAKE_CONFIG_H
#define SINGLETON_BAKE_CONFIG_H
/* Headers of public dependencies */
#include <flecs.h>
#endif

View File

@@ -0,0 +1,11 @@
{
"id": "singleton",
"type": "application",
"value": {
"use": [
"flecs"
],
"language": "c++",
"public": false
}
}

View File

@@ -0,0 +1,47 @@
#include <singleton.h>
#include <iostream>
// This example shows how to use singleton components in queries.
// Singleton component
struct Gravity {
double value;
};
// Entity component
struct Velocity {
double x;
double y;
};
int main(int, char *[]) {
flecs::world world;
// Set singleton
world.set<Gravity>({ 9.81 });
// Set Velocity
world.entity("e1").set<Velocity>({0, 0});
world.entity("e2").set<Velocity>({0, 1});
world.entity("e3").set<Velocity>({0, 2});
// Create query that matches Gravity as singleton
flecs::query<Velocity, const Gravity> q =
world.query_builder<Velocity, const Gravity>()
.term_at(2).singleton()
.build();
// In a query string expression you can use the $ shortcut for singletons:
// Velocity, Gravity($)
q.each([](flecs::entity e, Velocity& v, const Gravity& g) {
v.y += g.value;
std::cout << e.path() << " velocity is {"
<< v.x << ", " << v.y << "}" << std::endl;
});
// Output
// ::e1 velocity is {0, 9.81}
// ::e2 velocity is {0, 10.81}
// ::e3 velocity is {0, 11.81}
}