How knightfemale/gdextensionecs works
Project type and purpose
• This is an open-source Godot plugin (a GDExtension) that implements a minimal-intrusion ECS (Entity-Component-System) framework in C++.
• Its purpose is to let Godot 4.x users compose game logic via an ECS architecture, using sparse sets for component storage, and register custom native nodes in the Godot editor.
File structure
Top-level items:
• SConstruct – build script (SCons) for compiling the GDExtension.
• godot-cpp (git submodule) – Godot’s C++ binding generator and runtime headers.
• src/ – core C++ ECS source files and generated binding code:
– gde_entity, gde_component, gde_system, gde_system_manager, sparse_set (the heart of ECS).
– gen/ (doc_data.gen.cpp, register_types.cpp/h) for Godot type registration.
• demo/ – two demo projects: one using GDExtension (bin/*.gdextension) and one in GDScript (DEMO0-GDS).
• doc_classes/ – XML documentation exported for each ECS element.
• README.md, LICENSE, .gitignore – metadata.
Extract architecture hints from the README
• The framework is built from scratch around sparse sets to overcome Godot’s type-registration quirks.
• You compile via SCons into a .gdextension, open demo in Godot 4.4.1 to see usage.
• Future roadmap: multithreading, version compatibility.
1. Godot Engine / Editor
2. GDExtension Loader (.gdextension plugin)
3. Native ECS Module (C++ code)
• Entity Manager (GdeEntity)
• Component Storage (sparse set)
• Component base class & derived Components
• System base class & user-defined Systems
• System Manager (GdeSystemManager)
4. Generated Bindings (register_types)
5. Demo Scenes (DEMO0 & GDScript version)
6. Build System (SCons + godot-cpp submodule)
• Engine → GDExtension Loader: load plugin at startup.
• Loader → register_types: register native types with Godot.
• Godot Scenes instantiate GdeSystemManager node.
• SystemManager → Entities & Components: create and manage entities, attach components at run time.
• Systems iterate each frame: read/write component data in sparse sets.
• Component events propagate back to Godot API (e.g., transform changes).
c. Architectural patterns & principles:
• ECS: separation of data (Components) from behavior (Systems).
• Data-oriented design: sparse sets for fast component storage & iteration.
• Godot plugin pattern: native nodes registered via GDExtension binding.
• Minimal intrusion: components are Godot Nodes, users write only scenes and scripts.
d. Key technologies & frameworks:
• Godot 4.x, GDExtension API, godot-cpp bindings
• C++, SCons build system, conda/Python for build environment
• .tscn scene files for demo
• XML documentation in doc_classes
Detail
• C++ class or group of related classes (entity, component, system, manager).
• How generated files in src/gen feed into the plugin.
• Demo’s two branches (native vs. GDScript) hooking into the same ECS core.
• Don’t omit the build pipeline: SCons + godot-cpp → output .gdextension loaded by Godot.