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 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

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

View File

@@ -0,0 +1,10 @@
{
"id": "wildcards",
"type": "application",
"value": {
"use": [
"flecs"
],
"public": false
}
}

View File

@@ -0,0 +1,50 @@
#include <wildcards.h>
#include <stdio.h>
// Queries can have wildcard terms that can match multiple instances of a
// relationship or relationship target.
typedef struct {
int amount;
} Eats;
int main(int argc, char *argv[]) {
ecs_world_t *ecs = ecs_init_w_args(argc, argv);
ECS_COMPONENT(ecs, Eats);
ECS_TAG(ecs, Apples);
ECS_TAG(ecs, Pears);
// Create a query that matches edible components
ecs_query_t *q = ecs_query(ecs, {
.filter.terms = {{ .id = ecs_pair(ecs_id(Eats), EcsWildcard ) }}
});
// Create a few entities that match the query
ecs_entity_t bob = ecs_new_entity(ecs, "Bob");
ecs_set_pair(ecs, bob, Eats, Apples, {10});
ecs_set_pair(ecs, bob, Eats, Pears, {5});
ecs_entity_t alice = ecs_new_entity(ecs, "Alice");
ecs_set_pair(ecs, alice, Eats, Apples, {4});
// Iterate the query
ecs_iter_t it = ecs_query_iter(ecs, q);
while (ecs_query_next(&it)) {
Eats *eats = ecs_field(&it, Eats, 1);
ecs_id_t pair = ecs_field_id(&it, 1);
ecs_entity_t food = ecs_pair_second(ecs, pair);
for (int i = 0; i < it.count; i ++) {
printf("%s eats %d %s\n", ecs_get_name(ecs, it.entities[i]),
eats[i].amount, ecs_get_name(ecs, food));
}
}
// Output:
// Bob eats 10 Apples
// Bob eats 5 Pears
// Alice eats 4 Apples
return ecs_fini(ecs);
}