Properly link flecs library
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "hierarchy",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"language": "c++",
|
||||
"public": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <hierarchy.h>
|
||||
#include <iostream>
|
||||
|
||||
// When a prefab has children, they are instantiated for an instance when the
|
||||
// IsA relationship to the prefab is added.
|
||||
|
||||
int main() {
|
||||
flecs::world ecs;
|
||||
|
||||
// Create a prefab hierarchy.
|
||||
flecs::entity SpaceShip = ecs.prefab("SpaceShip");
|
||||
ecs.prefab("Engine").child_of(SpaceShip);
|
||||
ecs.prefab("Cockpit").child_of(SpaceShip);
|
||||
|
||||
// Instantiate the prefab. This also creates an Engine and Cockpit child
|
||||
// for the instance.
|
||||
flecs::entity inst = ecs.entity("my_spaceship").is_a(SpaceShip);
|
||||
flecs::entity inst_engine = inst.lookup("Engine");
|
||||
flecs::entity inst_cockpit = inst.lookup("Cockpit");
|
||||
|
||||
std::cout << "instance engine: " << inst_engine.path() << "\n";
|
||||
std::cout << "instance cockpit: " << inst_cockpit.path() << "\n";
|
||||
|
||||
// Output:
|
||||
// instance engine: ::my_spaceship::Engine
|
||||
// instance cockpit: ::my_spaceship::Cockpit
|
||||
}
|
||||
Reference in New Issue
Block a user