-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start implementing flecs library, included as a static lib via FetchContent
- Loading branch information
1 parent
9aebc92
commit 00ebfc6
Showing
15 changed files
with
168 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function(get_and_link_flecs TARGET TAG) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
flecs | ||
GIT_REPOSITORY https://github.com/SanderMertens/flecs | ||
GIT_TAG ${TAG} | ||
GIT_SUBMODULES_RECURSE 1 | ||
) | ||
FetchContent_MakeAvailable(flecs) | ||
|
||
set_target_properties(flecs PROPERTIES | ||
CXX_VISIBILITY_PRESET hidden | ||
VISIBILITY_INLINES_HIDDEN ON | ||
) | ||
# Turn on LTO and export compile commands for VSCode to use | ||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON) | ||
|
||
target_link_libraries(${TARGET} PRIVATE flecs::flecs_static) | ||
|
||
endfunction() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://cmsfs2w7fgkbs"] | ||
|
||
[ext_resource type="Script" path="res://scripts/node.gd" id="1_dng8d"] | ||
[ext_resource type="Script" path="res://scripts/world.gd" id="2_n3jn6"] | ||
|
||
[node name="Node" type="Node"] | ||
script = ExtResource("1_dng8d") | ||
|
||
[node name="FlecsWorld" type="FlecsWorld" parent="."] | ||
script = ExtResource("2_n3jn6") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class_name test_script extends FlecsWorld | ||
|
||
var field_1: int | ||
var field_2: float | ||
|
||
#func _ready(): | ||
#for prop in get_property_list(): | ||
#if prop["usage"] & PROPERTY_USAGE_SCRIPT_VARIABLE != 0: | ||
#print(prop) | ||
#pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "component.hpp" | ||
|
||
using namespace godot; | ||
|
||
auto FlecsComponent::_bind_methods() -> void { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
|
||
#include <godot_cpp/classes/object.hpp> | ||
#include <flecs.h> | ||
|
||
class World; | ||
|
||
class FlecsComponent : public godot::Object { | ||
GDCLASS(FlecsComponent, godot::Object) | ||
friend World; | ||
public: | ||
FlecsComponent() = default; | ||
~FlecsComponent() override = default; | ||
|
||
protected: | ||
|
||
|
||
static auto _bind_methods() -> void; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "world.hpp" | ||
|
||
#include <godot_cpp/classes/script.hpp> | ||
#include <godot_cpp/variant/utility_functions.hpp> | ||
|
||
using namespace godot; | ||
|
||
void FlecsWorld::_ready() { | ||
|
||
Ref<Script> script = get_script(); | ||
if(script.is_valid() && script->is_class("GDScript")) { | ||
|
||
|
||
UtilityFunctions::prints("Script name: ", script->get_global_name()); | ||
TypedArray<Dictionary> properties = get_property_list(); | ||
for(int i = 0; i < properties.size(); i++) | ||
{ | ||
Dictionary property = properties[i]; | ||
int usage = property["usage"]; | ||
if((usage & PROPERTY_USAGE_SCRIPT_VARIABLE) == PROPERTY_USAGE_SCRIPT_VARIABLE) | ||
{ | ||
UtilityFunctions::prints("-- Name:", property["name"],"- Type:", property["type"], "- Usage:", property["usage"]); | ||
} | ||
} | ||
} | ||
|
||
// For every GD entity | ||
// For every GD component | ||
// Make Flecs entity | ||
// Make Flecs component | ||
} | ||
|
||
auto FlecsWorld::component_registered(const String& commponent_name) const -> bool { | ||
return _registered_components.count(commponent_name); | ||
} | ||
|
||
auto FlecsWorld::register_new_component() -> void { | ||
|
||
} | ||
|
||
|
||
void FlecsWorld::_bind_methods() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
|
||
#include <godot_cpp/classes/node.hpp> | ||
#include <flecs.h> | ||
|
||
class FlecsWorld : public godot::Node { | ||
GDCLASS(FlecsWorld, godot::Node) | ||
public: | ||
FlecsWorld() = default; | ||
~FlecsWorld() override = default; | ||
|
||
void _ready() override; | ||
|
||
protected: | ||
auto component_registered(const godot::String& commponent_name) const -> bool; | ||
auto register_new_component() -> void; | ||
|
||
static auto _bind_methods() -> void; | ||
|
||
private: | ||
flecs::world _world; | ||
std::map<godot::String, flecs::entity> _registered_components; | ||
}; |