Properly link flecs library
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef EXCLUSIVE_RELATIONS_H
|
||||
#define EXCLUSIVE_RELATIONS_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "exclusive_relations/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 EXCLUSIVE_RELATIONS_BAKE_CONFIG_H
|
||||
#define EXCLUSIVE_RELATIONS_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include <flecs.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "exclusive_relations",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"public": false,
|
||||
"language": "c++"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <exclusive_relations.h>
|
||||
#include <iostream>
|
||||
|
||||
// Type for Platoon relationship
|
||||
struct Platoon { };
|
||||
|
||||
int main(int, char*[]) {
|
||||
flecs::world ecs;
|
||||
|
||||
// Register Platoon as exclusive relationship. This ensures that an entity
|
||||
// can only belong to a single Platoon.
|
||||
ecs.component<Platoon>()
|
||||
.add(flecs::Exclusive);
|
||||
|
||||
// Create two platoons
|
||||
flecs::entity platoon_1 = ecs.entity();
|
||||
flecs::entity platoon_2 = ecs.entity();
|
||||
|
||||
// Create a unit
|
||||
flecs::entity unit = ecs.entity();
|
||||
|
||||
// Add unit to platoon 1
|
||||
unit.add<Platoon>(platoon_1);
|
||||
|
||||
// Log platoon of unit
|
||||
std::cout << "Unit in platoon 1: " <<
|
||||
(unit.has<Platoon>(platoon_1) ? "true" : "false") << "\n";
|
||||
std::cout << "Unit in platoon 2: " <<
|
||||
(unit.has<Platoon>(platoon_2) ? "true" : "false") << "\n\n";
|
||||
|
||||
// Add unit to platoon 2. Because Platoon is an exclusive relationship, this
|
||||
// both removes (Platoon, platoon_1) and adds (Platoon, platoon_2) in a
|
||||
// single operation.
|
||||
unit.add<Platoon>(platoon_2);
|
||||
|
||||
std::cout << "Unit in platoon 1: " <<
|
||||
(unit.has<Platoon>(platoon_1) ? "true" : "false") << "\n";
|
||||
std::cout << "Unit in platoon 2: " <<
|
||||
(unit.has<Platoon>(platoon_2) ? "true" : "false") << "\n";
|
||||
|
||||
// Output:
|
||||
// Unit in platoon 1: true
|
||||
// Unit in platoon 2: false
|
||||
//
|
||||
// Unit in platoon 1: false
|
||||
// Unit in platoon 2: true
|
||||
}
|
||||
Reference in New Issue
Block a user