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 YIELD_EXISTING_H
#define YIELD_EXISTING_H
/* This generated file contains includes for project dependencies */
#include "yield_existing/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 YIELD_EXISTING_BAKE_CONFIG_H
#define YIELD_EXISTING_BAKE_CONFIG_H
/* Headers of public dependencies */
#include <flecs.h>
#endif

View File

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

View File

@@ -0,0 +1,36 @@
#include <yield_existing.h>
#include <iostream>
// Observers can enable a "yield_existing" feature that upon creation of the
// observer produces events for all entities that match the observer query. The
// feature is only implemented for the builtin EcsOnAdd and EcsOnSet events.
//
// Custom events can also implement behavior for yield_existing by adding the
// Iterable component to the event (see EcsIterable for more details).
struct Position {
double x, y;
};
int main(int, char *[]) {
flecs::world ecs;
// Create existing entities with Position component
ecs.entity("e1").set<Position>({10, 20});
ecs.entity("e2").set<Position>({20, 30});
// Create an observer for three events
ecs.observer<Position>()
.event(flecs::OnSet)
.yield_existing() // Trigger for existing matching entities
.each([](flecs::iter& it, size_t i, Position& p) {
std::cout << " - " << it.event().name() << ": "
<< it.event_id().str() << ": "
<< it.entity(i).name()
<< ": {" << p.x << ", " << p.y << "}\n";
});
// Output
// - OnSet: Position: e1: {10, 20}
// - OnSet: Position: e2: {20, 30}
}