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

View File

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

View File

@@ -0,0 +1,38 @@
#include <hierarchy.h>
#include <stdio.h>
// When a prefab has children, they are instantiated for an instance when the
// IsA relationship to the prefab is added.
int main(int argc, char *argv[]) {
ecs_world_t *ecs = ecs_init_w_args(argc, argv);
// Create a prefab hierarchy.
ecs_entity_t SpaceShip = ecs_new_prefab(ecs, "SpaceShip");
ecs_entity_t SpaceShipEngine = ecs_new_prefab(ecs, "Engine");
ecs_add_pair(ecs, SpaceShipEngine, EcsChildOf, SpaceShip);
ecs_entity_t SpaceShipCockpit = ecs_new_prefab(ecs, "Cockpit");
ecs_add_pair(ecs, SpaceShipCockpit, EcsChildOf, SpaceShip);
// Instantiate the prefab. This also creates an Engine and Cockpit child
// for the instance.
ecs_entity_t inst = ecs_new_entity(ecs, "my_spaceship");
ecs_add_pair(ecs, inst, EcsIsA, SpaceShip);
ecs_entity_t inst_engine = ecs_lookup_child(ecs, inst, "Engine");
ecs_entity_t inst_cockpit = ecs_lookup_child(ecs, inst, "Cockpit");
char *path = ecs_get_fullpath(ecs, inst_engine);
printf("instance engine: %s\n", path);
ecs_os_free(path);
path = ecs_get_fullpath(ecs, inst_cockpit);
printf("instance cockpit: %s\n", path);
ecs_os_free(path);
// Output:
// instance engine: my_spaceship.Engine
// instance cockpit: my_spaceship.Cockpit
return ecs_fini(ecs);
}