├── .gitignore ├── Config ├── DefaultUnrealFlecs.ini └── FilterPlugin.ini ├── LICENSE ├── README.md ├── Resources └── Icon128.png ├── Source ├── FlecsLibrary │ ├── Fixtures │ │ └── FlecsLibraryWorldFixture.h │ ├── FlecsLibrary.Build.cs │ ├── Private │ │ ├── FlecsLibrary.cpp │ │ ├── addons │ │ │ ├── alerts.c │ │ │ ├── app.c │ │ │ ├── doc.c │ │ │ ├── flecs_cpp.c │ │ │ ├── http.c │ │ │ ├── journal.c │ │ │ ├── journal.h │ │ │ ├── json │ │ │ │ ├── deserialize.c │ │ │ │ ├── deserialize_value.c │ │ │ │ ├── json.c │ │ │ │ ├── json.h │ │ │ │ ├── serialize_entity.c │ │ │ │ ├── serialize_field_info.c │ │ │ │ ├── serialize_iter.c │ │ │ │ ├── serialize_iter_result.c │ │ │ │ ├── serialize_iter_result_query.c │ │ │ │ ├── serialize_iter_result_table.c │ │ │ │ ├── serialize_query_info.c │ │ │ │ ├── serialize_type_info.c │ │ │ │ ├── serialize_value.c │ │ │ │ └── serialize_world.c │ │ │ ├── log.c │ │ │ ├── meta │ │ │ │ ├── c_utils.c │ │ │ │ ├── cursor.c │ │ │ │ ├── definitions.c │ │ │ │ ├── meta.c │ │ │ │ ├── meta.h │ │ │ │ ├── meta_api.c │ │ │ │ ├── rtt_lifecycle.c │ │ │ │ └── serialized.c │ │ │ ├── metrics.c │ │ │ ├── module.c │ │ │ ├── os_api_impl │ │ │ │ ├── os_api_impl.c │ │ │ │ ├── posix_impl.inl │ │ │ │ └── windows_impl.inl │ │ │ ├── parser │ │ │ │ ├── grammar.h │ │ │ │ ├── parser.h │ │ │ │ ├── tokenizer.c │ │ │ │ └── tokenizer.h │ │ │ ├── pipeline │ │ │ │ ├── frame.c │ │ │ │ ├── pipeline.c │ │ │ │ ├── pipeline.h │ │ │ │ └── worker.c │ │ │ ├── query_dsl │ │ │ │ ├── query_dsl.h │ │ │ │ └── query_dsl_parser.c │ │ │ ├── rest.c │ │ │ ├── script │ │ │ │ ├── ast.c │ │ │ │ ├── ast.h │ │ │ │ ├── expr │ │ │ │ │ ├── ast_expr.c │ │ │ │ │ ├── ast_expr.h │ │ │ │ │ ├── expr_expr.h │ │ │ │ │ ├── parser_expr.c │ │ │ │ │ ├── stack_expr.c │ │ │ │ │ ├── stack_expr.h │ │ │ │ │ ├── util_expr.c │ │ │ │ │ ├── visit_eval_expr.c │ │ │ │ │ ├── visit_expr.h │ │ │ │ │ ├── visit_fold_expr.c │ │ │ │ │ ├── visit_free_expr.c │ │ │ │ │ ├── visit_to_str_expr.c │ │ │ │ │ └── visit_type_expr.c │ │ │ │ ├── function.c │ │ │ │ ├── functions_builtin.c │ │ │ │ ├── functions_math.c │ │ │ │ ├── parser.c │ │ │ │ ├── script.c │ │ │ │ ├── script.h │ │ │ │ ├── serialize.c │ │ │ │ ├── template.c │ │ │ │ ├── template.h │ │ │ │ ├── vars.c │ │ │ │ ├── visit.c │ │ │ │ ├── visit.h │ │ │ │ ├── visit_check.c │ │ │ │ ├── visit_eval.c │ │ │ │ ├── visit_eval.h │ │ │ │ ├── visit_free.c │ │ │ │ └── visit_to_str.c │ │ │ ├── stats │ │ │ │ ├── monitor.c │ │ │ │ ├── pipeline_monitor.c │ │ │ │ ├── stats.c │ │ │ │ ├── stats.h │ │ │ │ ├── system_monitor.c │ │ │ │ ├── world_monitor.c │ │ │ │ └── world_summary.c │ │ │ ├── system │ │ │ │ ├── system.c │ │ │ │ └── system.h │ │ │ ├── timer.c │ │ │ └── units.c │ │ ├── bootstrap.c │ │ ├── commands.c │ │ ├── commands.h │ │ ├── component_actions.c │ │ ├── component_actions.h │ │ ├── datastructures │ │ │ ├── allocator.c │ │ │ ├── bitset.c │ │ │ ├── block_allocator.c │ │ │ ├── hash.c │ │ │ ├── hashmap.c │ │ │ ├── map.c │ │ │ ├── name_index.c │ │ │ ├── name_index.h │ │ │ ├── sparse.c │ │ │ ├── stack_allocator.c │ │ │ ├── strbuf.c │ │ │ ├── switch_list.c │ │ │ └── vec.c │ │ ├── each.c │ │ ├── entity.c │ │ ├── entity.h │ │ ├── entity_name.c │ │ ├── entity_name.h │ │ ├── flecs.cpp │ │ ├── id.c │ │ ├── instantiate.c │ │ ├── instantiate.h │ │ ├── iter.c │ │ ├── iter.h │ │ ├── misc.c │ │ ├── observable.c │ │ ├── observable.h │ │ ├── observer.c │ │ ├── on_delete.c │ │ ├── os_api.c │ │ ├── poly.c │ │ ├── poly.h │ │ ├── private_api.h │ │ ├── query │ │ │ ├── api.c │ │ │ ├── cache │ │ │ │ ├── cache.c │ │ │ │ ├── cache.h │ │ │ │ ├── cache_iter.c │ │ │ │ ├── cache_iter.h │ │ │ │ ├── change_detection.c │ │ │ │ ├── change_detection.h │ │ │ │ ├── group.c │ │ │ │ ├── group.h │ │ │ │ ├── match.c │ │ │ │ ├── match.h │ │ │ │ └── order_by.c │ │ │ ├── compiler │ │ │ │ ├── compiler.c │ │ │ │ ├── compiler.h │ │ │ │ └── compiler_term.c │ │ │ ├── engine │ │ │ │ ├── engine.h │ │ │ │ ├── eval.c │ │ │ │ ├── eval_iter.c │ │ │ │ ├── eval_member.c │ │ │ │ ├── eval_pred.c │ │ │ │ ├── eval_sparse.c │ │ │ │ ├── eval_toggle.c │ │ │ │ ├── eval_trav.c │ │ │ │ ├── eval_union.c │ │ │ │ ├── eval_up.c │ │ │ │ ├── eval_utils.c │ │ │ │ ├── trav_cache.c │ │ │ │ ├── trav_cache.h │ │ │ │ ├── trav_down_cache.c │ │ │ │ ├── trav_up_cache.c │ │ │ │ ├── trivial_iter.c │ │ │ │ └── trivial_iter.h │ │ │ ├── query.h │ │ │ ├── types.h │ │ │ ├── util.c │ │ │ ├── util.h │ │ │ └── validator.c │ │ ├── ref.c │ │ ├── search.c │ │ ├── stage.c │ │ ├── stage.h │ │ ├── storage │ │ │ ├── component_index.c │ │ │ ├── component_index.h │ │ │ ├── entity_index.c │ │ │ ├── entity_index.h │ │ │ ├── ordered_children.c │ │ │ ├── ordered_children.h │ │ │ ├── sparse_storage.c │ │ │ ├── sparse_storage.h │ │ │ ├── table.c │ │ │ ├── table.h │ │ │ ├── table_cache.c │ │ │ ├── table_cache.h │ │ │ ├── table_graph.c │ │ │ └── table_graph.h │ │ ├── type_info.c │ │ ├── value.c │ │ ├── world.c │ │ └── world.h │ ├── Public │ │ ├── FlecsLibrary.h │ │ ├── flecs.h │ │ └── flecs │ │ │ ├── Unreal │ │ │ ├── FlecsScriptClassComponent.h │ │ │ ├── FlecsScriptEnumComponent.h │ │ │ ├── FlecsScriptStructComponent.h │ │ │ └── FlecsTypeMapComponent.h │ │ │ ├── addons │ │ │ ├── alerts.h │ │ │ ├── app.h │ │ │ ├── cpp │ │ │ │ ├── c_types.hpp │ │ │ │ ├── component.hpp │ │ │ │ ├── delegate.hpp │ │ │ │ ├── entity.hpp │ │ │ │ ├── entity_view.hpp │ │ │ │ ├── field.hpp │ │ │ │ ├── flecs.hpp │ │ │ │ ├── impl │ │ │ │ │ ├── field.hpp │ │ │ │ │ ├── iter.hpp │ │ │ │ │ └── world.hpp │ │ │ │ ├── iter.hpp │ │ │ │ ├── lifecycle_traits.hpp │ │ │ │ ├── log.hpp │ │ │ │ ├── mixins │ │ │ │ │ ├── alerts │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── builder_i.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── entity_view.inl │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── app │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── component │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── doc │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── entity_builder.inl │ │ │ │ │ │ ├── entity_view.inl │ │ │ │ │ │ └── impl.hpp │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── enum │ │ │ │ │ │ ├── entity_view.inl │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── event │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── entity_builder.inl │ │ │ │ │ │ ├── entity_view.inl │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── id │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── json │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── entity.inl │ │ │ │ │ │ ├── entity_builder.inl │ │ │ │ │ │ ├── entity_view.inl │ │ │ │ │ │ ├── iterable.inl │ │ │ │ │ │ ├── query.inl │ │ │ │ │ │ └── world.inl │ │ │ │ │ ├── meta │ │ │ │ │ │ ├── component.inl │ │ │ │ │ │ ├── cursor.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── entity_builder.inl │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ ├── opaque.hpp │ │ │ │ │ │ ├── untyped_component.inl │ │ │ │ │ │ └── world.inl │ │ │ │ │ ├── metrics │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ ├── mixin.inl │ │ │ │ │ │ └── untyped_component.inl │ │ │ │ │ ├── module │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── observer │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── builder_i.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── pipeline │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── builder_i.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── query │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── builder_i.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── rest │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ └── impl.hpp │ │ │ │ │ ├── script │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── stats │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ └── impl.hpp │ │ │ │ │ ├── system │ │ │ │ │ │ ├── builder.hpp │ │ │ │ │ │ ├── builder_i.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── term │ │ │ │ │ │ ├── builder_i.hpp │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ └── mixin.inl │ │ │ │ │ ├── timer │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ ├── impl.hpp │ │ │ │ │ │ ├── mixin.inl │ │ │ │ │ │ └── system_mixin.inl │ │ │ │ │ └── units │ │ │ │ │ │ ├── decl.hpp │ │ │ │ │ │ └── impl.hpp │ │ │ │ ├── pair.hpp │ │ │ │ ├── ref.hpp │ │ │ │ ├── table.hpp │ │ │ │ ├── type.hpp │ │ │ │ ├── utils │ │ │ │ │ ├── array.hpp │ │ │ │ │ ├── builder.hpp │ │ │ │ │ ├── enum.hpp │ │ │ │ │ ├── function_traits.hpp │ │ │ │ │ ├── iterable.hpp │ │ │ │ │ ├── node_builder.hpp │ │ │ │ │ ├── signature.hpp │ │ │ │ │ ├── string.hpp │ │ │ │ │ ├── stringstream.hpp │ │ │ │ │ └── utils.hpp │ │ │ │ └── world.hpp │ │ │ ├── deprecated.h │ │ │ ├── doc.h │ │ │ ├── flecs_c.h │ │ │ ├── flecs_cpp.h │ │ │ ├── http.h │ │ │ ├── json.h │ │ │ ├── log.h │ │ │ ├── meta.h │ │ │ ├── meta_c.h │ │ │ ├── metrics.h │ │ │ ├── module.h │ │ │ ├── pipeline.h │ │ │ ├── rest.h │ │ │ ├── script.h │ │ │ ├── script_math.h │ │ │ ├── stats.h │ │ │ ├── system.h │ │ │ ├── timer.h │ │ │ └── units.h │ │ │ ├── bake_config.h │ │ │ ├── datastructures │ │ │ ├── allocator.h │ │ │ ├── bitset.h │ │ │ ├── block_allocator.h │ │ │ ├── hashmap.h │ │ │ ├── map.h │ │ │ ├── sparse.h │ │ │ ├── stack_allocator.h │ │ │ ├── strbuf.h │ │ │ ├── switch_list.h │ │ │ └── vec.h │ │ │ ├── os_api.h │ │ │ └── private │ │ │ ├── addons.h │ │ │ ├── api_defines.h │ │ │ ├── api_flags.h │ │ │ ├── api_internals.h │ │ │ ├── api_support.h │ │ │ └── api_types.h │ └── Tests │ │ ├── Bake │ │ ├── FlecsTestTypes.cpp │ │ ├── FlecsTestTypes.h │ │ └── FlecsTestUtils.h │ │ └── Specs │ │ ├── FlecsDocTests.spec.cpp │ │ ├── FlecsEntityTests.spec.cpp │ │ ├── FlecsEnumTests.spec.cpp │ │ ├── FlecsEventTests.spec.cpp │ │ ├── FlecsIterableTests.spec.cpp │ │ ├── FlecsMetaTests.spec.cpp │ │ ├── FlecsModuleTests.spec.cpp │ │ ├── FlecsObserverTests.spec.cpp │ │ ├── FlecsOrderedChildrenTests.spec.cpp │ │ ├── FlecsPairsTests.spec.cpp │ │ ├── FlecsPathsTests.spec.cpp │ │ ├── FlecsQueryTests.spec.cpp │ │ ├── FlecsRefsTests.spec.cpp │ │ ├── FlecsSingletonTests.spec.cpp │ │ ├── FlecsSystemBuilder.spec.cpp │ │ ├── FlecsSystemTests.spec.cpp │ │ ├── FlecsTableTests.spec.cpp │ │ ├── FlecsUnionTests.spec.cpp │ │ ├── FlecsWorldFactoryTests.spec.cpp │ │ ├── FlecsWorldTests.spec.cpp │ │ └── project.json ├── UnrealFlecs │ ├── Collections │ │ ├── FlecsComponentCollectionObject.cpp │ │ └── FlecsComponentCollectionObject.h │ ├── Components │ │ ├── ComponentDefaultEntities.cpp │ │ ├── FlecsModuleComponent.h │ │ ├── FlecsPrimaryAssetComponent.h │ │ ├── FlecsUObjectComponent.h │ │ ├── FlecsWorldPtrComponent.h │ │ ├── ObjectTypes │ │ │ ├── FFlecsActorComponentTag.h │ │ │ ├── FFlecsModuleComponentTag.h │ │ │ ├── FFlecsSceneComponentTag.h │ │ │ ├── FFlecsUObjectTag.h │ │ │ └── FlecsActorTag.h │ │ └── UWorldPtrComponent.h │ ├── Entities │ │ ├── FFlecsMemberHandle.cpp │ │ ├── FFlecsMemberHandle.h │ │ ├── FlecsArchetype.h │ │ ├── FlecsComponentHandle.cpp │ │ ├── FlecsComponentHandle.h │ │ ├── FlecsDefaultEntitiesDeveloperSettings.h │ │ ├── FlecsDefaultEntityEngineSubsystem.cpp │ │ ├── FlecsDefaultEntityEngineSubsystem.h │ │ ├── FlecsEntityHandle.cpp │ │ ├── FlecsEntityHandle.h │ │ ├── FlecsEntityRecord.h │ │ └── FlecsId.h │ ├── GameFramework │ │ ├── Actor │ │ │ ├── FlecsEntityActorComponent.cpp │ │ │ └── FlecsEntityActorComponent.h │ │ ├── FlecsGameFrameworkModule.cpp │ │ ├── FlecsGameFrameworkModule.h │ │ └── UObject │ │ │ ├── UnrealFlecsObject.cpp │ │ │ └── UnrealFlecsObject.h │ ├── General │ │ ├── FlecsDeveloperSettings.cpp │ │ ├── FlecsDeveloperSettings.h │ │ ├── FlecsPrimaryDataAsset.cpp │ │ ├── FlecsPrimaryDataAsset.h │ │ └── FlecsStringConverters.h │ ├── Interfaces │ │ ├── FlecsEntityInterface.cpp │ │ └── FlecsEntityInterface.h │ ├── Libraries │ │ ├── DefaultEntitiesLibrary.h │ │ ├── EntityFunctionLibrary.cpp │ │ └── EntityFunctionLibrary.h │ ├── Logs │ │ └── FlecsCategories.h │ ├── Modules │ │ ├── FlecsAddons │ │ │ ├── FlecsRestModule.cpp │ │ │ └── FlecsRestModule.h │ │ ├── FlecsDependenciesComponent.h │ │ ├── FlecsModuleInitEvent.h │ │ ├── FlecsModuleInterface.cpp │ │ ├── FlecsModuleInterface.h │ │ ├── FlecsModuleObject.cpp │ │ ├── FlecsModuleObject.h │ │ ├── FlecsModuleProgressInterface.h │ │ ├── FlecsModuleSetDataAsset.cpp │ │ └── FlecsModuleSetDataAsset.h │ ├── Networking │ │ ├── FlecsNetworkIdComponent.h │ │ ├── FlecsNetworkMessage.h │ │ ├── FlecsNetworkTrait.h │ │ ├── FlecsNetworkingModule.cpp │ │ ├── FlecsNetworkingModule.h │ │ └── FlecsResimulatingComponent.h │ ├── Physics │ │ ├── FlecsPhysicsModule.cpp │ │ ├── FlecsPhysicsModule.h │ │ ├── FlecsPhysicsSceneComponent.h │ │ ├── FlecsPhysicsSettingsTrait.h │ │ └── TickerPhysicsHistoryComponent.h │ ├── Pipelines │ │ ├── FlecsDefaultGameLoop.cpp │ │ ├── FlecsDefaultGameLoop.h │ │ ├── FlecsGameLoopInterface.cpp │ │ ├── FlecsGameLoopInterface.h │ │ ├── FlecsGameLoopObject.cpp │ │ └── FlecsGameLoopObject.h │ ├── Prefabs │ │ ├── FlecsPrefabAsset.cpp │ │ ├── FlecsPrefabAsset.h │ │ ├── FlecsPrefabObject.cpp │ │ └── FlecsPrefabObject.h │ ├── Properties │ │ ├── FlecsComponentProperties.cpp │ │ └── FlecsComponentProperties.h │ ├── Queries │ │ ├── Enums │ │ │ ├── FlecsQueryCache.h │ │ │ ├── FlecsQueryInOut.h │ │ │ └── FlecsQueryOperators.h │ │ ├── Expressions │ │ │ ├── FlecsExpressionInOut.cpp │ │ │ ├── FlecsExpressionInOut.h │ │ │ ├── FlecsOperQueryExpression.cpp │ │ │ ├── FlecsOperQueryExpression.h │ │ │ ├── FlecsQueryExpression.cpp │ │ │ ├── FlecsQueryExpression.h │ │ │ ├── FlecsQueryFilterExpression.cpp │ │ │ ├── FlecsQueryFilterExpression.h │ │ │ ├── FlecsQueryNameExpression.cpp │ │ │ ├── FlecsQueryNameExpression.h │ │ │ ├── FlecsQueryOptionalExpression.cpp │ │ │ ├── FlecsQueryOptionalExpression.h │ │ │ ├── FlecsQueryScriptExpression.cpp │ │ │ ├── FlecsQueryScriptExpression.h │ │ │ ├── FlecsQuerySingletonExpression.cpp │ │ │ ├── FlecsQuerySingletonExpression.h │ │ │ ├── FlecsQuerySrcExpression.cpp │ │ │ ├── FlecsQuerySrcExpression.h │ │ │ ├── FlecsQueryTermExpression.cpp │ │ │ ├── FlecsQueryTermExpression.h │ │ │ ├── FlecsQueryVarExpression.cpp │ │ │ └── FlecsQueryVarExpression.h │ │ ├── FlecsQuery.cpp │ │ ├── FlecsQuery.h │ │ ├── FlecsQueryDefinition.cpp │ │ ├── FlecsQueryDefinition.h │ │ ├── FlecsQueryFlags.h │ │ ├── FlecsQueryInputType.h │ │ └── FlecsQueryScriptExpr.h │ ├── Rendering │ │ ├── FlecsRenderingModule.cpp │ │ └── FlecsRenderingModule.h │ ├── Systems │ │ ├── FlecsSystem.h │ │ ├── FlecsSystemActor.cpp │ │ ├── FlecsSystemActor.h │ │ ├── FlecsSystemInterface.cpp │ │ ├── FlecsSystemInterface.h │ │ ├── FlecsSystemObject.cpp │ │ ├── FlecsSystemObject.h │ │ └── FlecsSystemSettingsInfo.h │ ├── Ticker │ │ ├── FlecsTickerComponent.h │ │ ├── FlecsTickerDefaultEntities.cpp │ │ ├── FlecsTickerDefaultEntities.h │ │ ├── FlecsTickerGameLoop.cpp │ │ ├── FlecsTickerGameLoop.h │ │ ├── FlecsTickerModule.cpp │ │ └── FlecsTickerModule.h │ ├── Timers │ │ └── FlecsTimer.h │ ├── Transforms │ │ ├── FlecsTransformComponents.cpp │ │ ├── FlecsTransformComponents.h │ │ ├── FlecsTransformDefaultEntities.cpp │ │ ├── FlecsTransformDefaultEntities.h │ │ ├── FlecsTransformModule.cpp │ │ └── FlecsTransformModule.h │ ├── Translators │ │ ├── FlecsTranslationModule.cpp │ │ ├── FlecsTranslationModule.h │ │ └── FlecsTranslationSettingTraits.h │ ├── UnrealFlecs.Build.cs │ ├── UnrealFlecs.cpp │ ├── UnrealFlecs.h │ ├── Versioning │ │ └── UnrealFlecsVersion.h │ └── Worlds │ │ ├── FlecsAbstractWorldSubsystem.cpp │ │ ├── FlecsAbstractWorldSubsystem.h │ │ ├── FlecsOSAPI.h │ │ ├── FlecsWorld.cpp │ │ ├── FlecsWorld.h │ │ ├── FlecsWorldInfoSettings.cpp │ │ ├── FlecsWorldInfoSettings.h │ │ ├── FlecsWorldSettings.cpp │ │ ├── FlecsWorldSettings.h │ │ ├── FlecsWorldSettingsAsset.cpp │ │ ├── FlecsWorldSettingsAsset.h │ │ └── FlecsWorldSubsystem.h ├── UnrealFlecsEditor │ ├── Logs │ │ └── FlecsEditorCategory.h │ ├── UnrealFlecsEditor.Build.cs │ ├── UnrealFlecsEditor.cpp │ ├── UnrealFlecsEditor.h │ ├── UnrealFlecsEditorStyle.h │ └── Widgets │ │ └── EntityHandle │ │ ├── FlecsIdCustomization.cpp │ │ ├── FlecsIdCustomization.h │ │ ├── FlecsIdPinFactory.cpp │ │ ├── FlecsIdPinFactory.h │ │ ├── FlecsIdSelector.cpp │ │ ├── FlecsIdSelector.h │ │ ├── SGraphPinFlecsId.cpp │ │ └── SGraphPinFlecsId.h └── UnrealFlecsTests │ ├── Fixtures │ └── FlecsWorldFixture.h │ ├── Tests │ ├── Benchmarks │ │ └── Entities │ │ │ └── EntityBenchmarks.spec.cpp │ ├── Components │ │ ├── Collections │ │ │ └── ComponentCollectionTest.spec.cpp │ │ ├── Enums │ │ │ ├── ComponentTestEnums.h │ │ │ └── EnumComponentTests.spec.cpp │ │ ├── GameplayTags │ │ │ └── GameplayTagsTests.spec.cpp │ │ ├── Strings │ │ │ └── StringComponentTests.spec.cpp │ │ ├── Structs │ │ │ ├── ComponentTestStructs.h │ │ │ └── RegisteredComponentTests.spec.cpp │ │ └── UObjectComponent │ │ │ ├── FlecsUObjectComponentTestObject.h │ │ │ └── UObjectTests.spec.cpp │ ├── Entities │ │ ├── DefaultEntities │ │ │ ├── DefaultEntityDefinitions.cpp │ │ │ ├── DefaultEntityDefinitions.h │ │ │ └── DefaultEntityTests.spec.cpp │ │ ├── EntityBasicTests.spec.cpp │ │ └── Prefabs │ │ │ ├── EntityPrefabTests.spec.cpp │ │ │ ├── EntityRecordTestStructs.h │ │ │ └── EntityRecordTests.spec.cpp │ ├── OSAPI │ │ └── OS_API_Tests.spec.cpp │ ├── Queries │ │ └── Definitions │ │ │ ├── QueryDefinitionTestComponents.h │ │ │ └── QueryDefinitionTests.spec.cpp │ └── World │ │ └── FlecsWorldLifecycleTests.spec.cpp │ ├── UnrealFlecsTests.Build.cs │ ├── UnrealFlecsTests.cpp │ └── UnrealFlecsTests.h └── UnrealFlecs.uplugin /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio 2015 user specific files 2 | .vs/ 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | 22 | # Compiled Static libraries 23 | *.lai 24 | *.la 25 | *.a 26 | *.lib 27 | 28 | # Executables 29 | *.exe 30 | *.out 31 | *.app 32 | *.ipa 33 | 34 | # These project files can be generated by the engine 35 | *.xcodeproj 36 | *.xcworkspace 37 | *.sln 38 | *.suo 39 | *.opensdf 40 | *.sdf 41 | *.VC.db 42 | *.VC.opendb 43 | 44 | # Precompiled Assets 45 | SourceArt/**/*.png 46 | SourceArt/**/*.tga 47 | 48 | # Binary Files 49 | Binaries/* 50 | Plugins/*/Binaries/* 51 | 52 | # Builds 53 | Build/* 54 | 55 | # Whitelist PakBlacklist-.txt files 56 | !Build/*/ 57 | Build/*/** 58 | !Build/*/PakBlacklist*.txt 59 | 60 | # Don't ignore icon files in Build 61 | !Build/**/*.ico 62 | 63 | # Built data for maps 64 | *_BuiltData.uasset 65 | 66 | # Configuration files generated by the Editor 67 | Saved/* 68 | 69 | # Compiled source files for the engine to use 70 | Intermediate/* 71 | Plugins/*/Intermediate/* 72 | 73 | # Cache files for the editor to use 74 | DerivedDataCache/* 75 | 76 | .uet/ 77 | /.idea 78 | -------------------------------------------------------------------------------- /Config/DefaultUnrealFlecs.ini: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /Config/FilterPlugin.ini: -------------------------------------------------------------------------------- 1 | [FilterPlugin] 2 | ; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and 3 | ; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. 4 | ; 5 | ; Examples: 6 | ; /README.txt 7 | ; /Extras/... 8 | ; /Binaries/ThirdParty/*.dll 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Unreal Engine Flecs Integration 2 | 3 | Depends on [Solid-Macros](https://github.com/Reddy-dev/Solid-Macros) 4 | 5 | Many Features are not complete 6 | 7 | Only tested on Version: UE 5.5 MSVC 8 | 9 | Contributors to Unreal-Flecs: @Megafunk 10 | -------------------------------------------------------------------------------- /Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reddy-dev/Unreal-Flecs/9c4c14a11d2a664558aab09fe57969156d41e359/Resources/Icon128.png -------------------------------------------------------------------------------- /Source/FlecsLibrary/Fixtures/FlecsLibraryWorldFixture.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #if WITH_AUTOMATION_TESTS && defined(FLECS_TESTS) 6 | 7 | #include "CoreMinimal.h" 8 | #include "flecs.h" 9 | 10 | class FFlecsLibraryWorldFixture 11 | { 12 | TUniquePtr World = nullptr; 13 | 14 | public: 15 | void Setup() 16 | { 17 | World = MakeUnique(); 18 | } 19 | 20 | void TearDown() 21 | { 22 | World.Reset(); 23 | } 24 | 25 | }; // class FFlecsLibraryWorldFixture 26 | 27 | #define FLECS_LIBRARY_FIXTURE_LIFECYCLE(FixtureName) \ 28 | BeforeEach([this]() \ 29 | { \ 30 | FixtureName.SetUp(); \ 31 | }); \ 32 | AfterEach([this]() \ 33 | { \ 34 | FixtureName.TearDown(); \ 35 | }) 36 | 37 | #endif // #if WITH_AUTOMATION_TESTS && defined(FLECS_TESTS) 38 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/FlecsLibrary.cpp: -------------------------------------------------------------------------------- 1 | #include "FlecsLibrary.h" 2 | 3 | #define LOCTEXT_NAMESPACE "FFlecsLibraryModule" 4 | 5 | void FFlecsLibraryModule::StartupModule() 6 | { 7 | 8 | } 9 | 10 | void FFlecsLibraryModule::ShutdownModule() 11 | { 12 | 13 | } 14 | 15 | #undef LOCTEXT_NAMESPACE 16 | 17 | IMPLEMENT_MODULE(FFlecsLibraryModule, FlecsLibrary) -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/journal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/journal.h 3 | * @brief Journaling addon that logs API functions. 4 | * 5 | * The journaling addon traces API calls. The trace is formatted as runnable 6 | * C code, which allows for (partially) reproducing the behavior of an app 7 | * with the journaling trace. 8 | * 9 | * The journaling addon is disabled by default. Enabling it can have a 10 | * significant impact on performance. 11 | */ 12 | 13 | #ifdef FLECS_JOURNAL 14 | 15 | #ifndef FLECS_LOG 16 | #define FLECS_LOG 17 | #endif 18 | 19 | #ifndef FLECS_JOURNAL_H 20 | #define FLECS_JOURNAL_H 21 | 22 | /** 23 | * @defgroup c_addons_journal Journal 24 | * @ingroup c_addons 25 | * Journaling addon (disabled by default). 26 | * 27 | * 28 | * @{ 29 | */ 30 | 31 | /* Trace when log level is at or higher than level */ 32 | #define FLECS_JOURNAL_LOG_LEVEL (0) 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* Journaling API, meant to be used by internals. */ 39 | 40 | typedef enum ecs_journal_kind_t { 41 | EcsJournalNew, 42 | EcsJournalMove, 43 | EcsJournalClear, 44 | EcsJournalDelete, 45 | EcsJournalDeleteWith, 46 | EcsJournalRemoveAll, 47 | EcsJournalTableEvents 48 | } ecs_journal_kind_t; 49 | 50 | FLECS_DBG_API 51 | void flecs_journal_begin( 52 | ecs_world_t *world, 53 | ecs_journal_kind_t kind, 54 | ecs_entity_t entity, 55 | ecs_type_t *add, 56 | ecs_type_t *remove); 57 | 58 | FLECS_DBG_API 59 | void flecs_journal_end(void); 60 | 61 | #define flecs_journal(...)\ 62 | flecs_journal_begin(__VA_ARGS__);\ 63 | flecs_journal_end(); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif // __cplusplus 68 | /** @} */ 69 | #endif // FLECS_JOURNAL_H 70 | #else 71 | #define flecs_journal_begin(...) 72 | #define flecs_journal_end(...) 73 | #define flecs_journal(...) 74 | 75 | #endif // FLECS_JOURNAL 76 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/meta/meta.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/meta/meta.h 3 | * @brief Private functions for meta addon. 4 | */ 5 | 6 | #ifndef FLECS_META_PRIVATE_H 7 | #define FLECS_META_PRIVATE_H 8 | 9 | #include "../../private_api.h" 10 | 11 | #ifdef FLECS_META 12 | 13 | void ecs_meta_type_serialized_init( 14 | ecs_iter_t *it); 15 | 16 | void ecs_meta_dtor_serialized( 17 | EcsTypeSerializer *ptr); 18 | 19 | ecs_meta_type_op_kind_t flecs_meta_primitive_to_op_kind( 20 | ecs_primitive_kind_t kind); 21 | 22 | bool flecs_unit_validate( 23 | ecs_world_t *world, 24 | ecs_entity_t t, 25 | EcsUnit *data); 26 | 27 | void flecs_meta_import_definitions( 28 | ecs_world_t *world); 29 | 30 | int flecs_expr_ser_primitive( 31 | const ecs_world_t *world, 32 | ecs_primitive_kind_t kind, 33 | const void *base, 34 | ecs_strbuf_t *str, 35 | bool is_expr); 36 | 37 | void flecs_rtt_init_default_hooks( 38 | ecs_iter_t *it); 39 | 40 | int ecs_compare_string( 41 | const void *str_a, 42 | const void *str_b, 43 | const ecs_type_info_t *ti); 44 | 45 | bool ecs_equals_string( 46 | const void *str_a, 47 | const void *str_b, 48 | const ecs_type_info_t *ti); 49 | 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/os_api_impl/os_api_impl.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/os_api_impl/os_api_impl.c 3 | * @brief Builtin implementation for OS API. 4 | */ 5 | 6 | #include "../../private_api.h" 7 | 8 | #ifdef FLECS_OS_API_IMPL 9 | #ifdef ECS_TARGET_WINDOWS 10 | #include "windows_impl.inl" 11 | #else 12 | #include "posix_impl.inl" 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/parser/parser.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/parser/parser.h 3 | * @brief Parser addon. 4 | */ 5 | 6 | #ifndef FLECS_PARSER_H 7 | #define FLECS_PARSER_H 8 | 9 | #include "../../private_api.h" 10 | 11 | typedef struct ecs_script_impl_t ecs_script_impl_t; 12 | typedef struct ecs_script_scope_t ecs_script_scope_t; 13 | 14 | typedef struct ecs_parser_t { 15 | const char *name; 16 | const char *code; 17 | 18 | const char *pos; 19 | char *token_cur; 20 | char *token_keep; 21 | bool significant_newline; 22 | bool merge_variable_members; 23 | 24 | ecs_world_t *world; 25 | 26 | /* For script parser */ 27 | ecs_script_impl_t *script; 28 | ecs_script_scope_t *scope; 29 | 30 | /* For term parser */ 31 | ecs_term_t *term; 32 | ecs_oper_kind_t extra_oper; 33 | ecs_term_ref_t *extra_args; 34 | } ecs_parser_t; 35 | 36 | #include "tokenizer.h" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/query_dsl/query_dsl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/query_dsl/query_dsl.h 3 | * @brief Query DSL parser addon. 4 | */ 5 | 6 | #ifndef FLECS_QUERY_DSL_H 7 | #define FLECS_QUERY_DSL_H 8 | 9 | #include "../../private_api.h" 10 | 11 | int flecs_terms_parse( 12 | ecs_world_t *world, 13 | const char *name, 14 | const char *code, 15 | char *token_buffer, 16 | ecs_term_t *terms, 17 | int32_t *term_count_out); 18 | 19 | const char* flecs_term_parse( 20 | ecs_world_t *world, 21 | const char *name, 22 | const char *expr, 23 | char *token_buffer, 24 | ecs_term_t *term); 25 | 26 | const char* flecs_id_parse( 27 | const ecs_world_t *world, 28 | const char *name, 29 | const char *expr, 30 | ecs_id_t *id); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/script/expr/expr_expr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/script/expr/expr.h 3 | * @brief Script expression support. 4 | */ 5 | 6 | #ifndef FLECS_EXPR_SCRIPT_H 7 | #define FLECS_EXPR_SCRIPT_H 8 | 9 | #include "stack_expr.h" 10 | #include "ast_expr.h" 11 | #include "visit_expr.h" 12 | 13 | int flecs_value_copy_to( 14 | ecs_world_t *world, 15 | ecs_value_t *dst, 16 | const ecs_expr_value_t *src); 17 | 18 | int flecs_value_move_to( 19 | ecs_world_t *world, 20 | ecs_value_t *dst, 21 | ecs_value_t *src); 22 | 23 | int flecs_value_binary( 24 | const ecs_script_t *script, 25 | const ecs_value_t *left, 26 | const ecs_value_t *right, 27 | ecs_value_t *out, 28 | ecs_token_kind_t operator); 29 | 30 | int flecs_value_unary( 31 | const ecs_script_t *script, 32 | const ecs_value_t *expr, 33 | ecs_value_t *out, 34 | ecs_token_kind_t operator); 35 | 36 | const char* flecs_script_parse_expr( 37 | ecs_parser_t *parser, 38 | const char *pos, 39 | ecs_token_kind_t left_oper, 40 | ecs_expr_node_t **out); 41 | 42 | const char* flecs_script_parse_initializer( 43 | ecs_parser_t *parser, 44 | const char *pos, 45 | char until, 46 | ecs_expr_initializer_t **node_out); 47 | 48 | void flecs_expr_to_str_buf( 49 | const ecs_world_t *world, 50 | const ecs_expr_node_t *expr, 51 | ecs_strbuf_t *buf, 52 | bool colors); 53 | 54 | bool flecs_string_is_interpolated( 55 | const char *str); 56 | 57 | char* flecs_string_escape( 58 | char *str); 59 | 60 | bool flecs_value_is_0( 61 | const ecs_value_t *value); 62 | 63 | bool flecs_expr_is_type_integer( 64 | ecs_entity_t type); 65 | 66 | bool flecs_expr_is_type_number( 67 | ecs_entity_t type); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/script/expr/visit_expr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/script/exor_visit.h 3 | * @brief Script AST visitor utilities. 4 | */ 5 | 6 | #ifndef FLECS_EXPR_SCRIPT_VISIT_H 7 | #define FLECS_EXPR_SCRIPT_VISIT_H 8 | 9 | #include "../script.h" 10 | 11 | #define flecs_expr_visit_error(script, node, ...) \ 12 | ecs_parser_error( \ 13 | script->name, script->code, \ 14 | ((const ecs_expr_node_t*)node)->pos - script->code, \ 15 | __VA_ARGS__); 16 | 17 | int flecs_expr_visit_type( 18 | ecs_script_t *script, 19 | ecs_expr_node_t *node, 20 | const ecs_expr_eval_desc_t *desc); 21 | 22 | int flecs_expr_visit_fold( 23 | ecs_script_t *script, 24 | ecs_expr_node_t **node, 25 | const ecs_expr_eval_desc_t *desc); 26 | 27 | int flecs_expr_visit_eval( 28 | const ecs_script_t *script, 29 | ecs_expr_node_t *node, 30 | const ecs_expr_eval_desc_t *desc, 31 | ecs_value_t *out); 32 | 33 | void flecs_expr_visit_free( 34 | ecs_script_t *script, 35 | ecs_expr_node_t *node); 36 | 37 | ecs_script_var_t flecs_expr_find_var( 38 | ecs_script_t *script, 39 | const char *name); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/script/template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/script/template.h 3 | * @brief Script template implementation. 4 | */ 5 | 6 | #ifndef FLECS_SCRIPT_TEMPLATE_H 7 | #define FLECS_SCRIPT_TEMPLATE_H 8 | 9 | extern ECS_COMPONENT_DECLARE(EcsScriptTemplateSetEvent); 10 | 11 | struct ecs_script_template_t { 12 | /* Template handle */ 13 | ecs_entity_t entity; 14 | 15 | /* Template AST node */ 16 | ecs_script_template_node_t *node; 17 | 18 | /* Hoisted using statements */ 19 | ecs_vec_t using_; 20 | 21 | /* Hoisted variables */ 22 | ecs_script_vars_t *vars; 23 | 24 | /* Default values for props */ 25 | ecs_vec_t prop_defaults; 26 | 27 | /* Type info for template component */ 28 | const ecs_type_info_t *type_info; 29 | }; 30 | 31 | #define ECS_TEMPLATE_SMALL_SIZE (36) 32 | 33 | /* Event used for deferring template instantiation */ 34 | typedef struct EcsScriptTemplateSetEvent { 35 | ecs_entity_t template_entity; 36 | ecs_entity_t *entities; 37 | void *data; 38 | int32_t count; 39 | 40 | /* Storage for small template types */ 41 | int64_t _align; /* Align data storage to 8 bytes */ 42 | char data_storage[ECS_TEMPLATE_SMALL_SIZE]; 43 | ecs_entity_t entity_storage; 44 | } EcsScriptTemplateSetEvent; 45 | 46 | int flecs_script_eval_template( 47 | ecs_script_eval_visitor_t *v, 48 | ecs_script_template_node_t *template); 49 | 50 | ecs_script_template_t* flecs_script_template_init( 51 | ecs_script_impl_t *script); 52 | 53 | void flecs_script_template_fini( 54 | ecs_script_impl_t *script, 55 | ecs_script_template_t *template); 56 | 57 | void flecs_script_template_import( 58 | ecs_world_t *world); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/stats/stats.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/stats/stats.h 3 | * @brief Internal functions/types for stats addon. 4 | */ 5 | 6 | #ifndef FLECS_STATS_PRIVATE_H 7 | #define FLECS_STATS_PRIVATE_H 8 | 9 | #include "../../private_api.h" 10 | 11 | typedef struct { 12 | /* Statistics API interface */ 13 | void (*copy_last)(void *stats, void *src); 14 | void (*get)(ecs_world_t *world, ecs_entity_t res, void *stats); 15 | void (*reduce)(void *stats, void *src); 16 | void (*reduce_last)(void *stats, void *last, int32_t reduce_count); 17 | void (*repeat_last)(void* stats); 18 | void (*set_t)(void *stats, int32_t t); 19 | void (*fini)(void *stats); 20 | 21 | /* Size of statistics type */ 22 | ecs_size_t stats_size; 23 | 24 | /* Id of component that contains the statistics */ 25 | ecs_entity_t monitor_component_id; 26 | 27 | /* Id of component used to query for monitored resources (optional) */ 28 | ecs_id_t query_component_id; 29 | } ecs_stats_api_t; 30 | 31 | void flecs_stats_api_import( 32 | ecs_world_t *world, 33 | ecs_stats_api_t *api); 34 | 35 | void FlecsWorldSummaryImport( 36 | ecs_world_t *world); 37 | 38 | void FlecsWorldMonitorImport( 39 | ecs_world_t *world); 40 | 41 | void FlecsSystemMonitorImport( 42 | ecs_world_t *world); 43 | 44 | void FlecsPipelineMonitorImport( 45 | ecs_world_t *world); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/addons/system/system.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/system/system.h 3 | * @brief Internal types and functions for system addon. 4 | */ 5 | 6 | #ifndef FLECS_SYSTEM_PRIVATE_H 7 | #define FLECS_SYSTEM_PRIVATE_H 8 | 9 | #ifdef FLECS_SYSTEM 10 | 11 | #include "../../private_api.h" 12 | 13 | #define ecs_system_t_magic (0x65637383) 14 | #define ecs_system_t_tag EcsSystem 15 | 16 | extern ecs_mixins_t ecs_system_t_mixins; 17 | 18 | /* Invoked when system becomes active / inactive */ 19 | void ecs_system_activate( 20 | ecs_world_t *world, 21 | ecs_entity_t system, 22 | bool activate, 23 | const ecs_system_t *system_data); 24 | 25 | /* Internal function to run a system */ 26 | ecs_entity_t flecs_run_system( 27 | ecs_world_t *world, 28 | ecs_stage_t *stage, 29 | ecs_entity_t system, 30 | ecs_system_t *system_data, 31 | int32_t stage_current, 32 | int32_t stage_count, 33 | ecs_ftime_t delta_time, 34 | void *param); 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/datastructures/name_index.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file datastructures/name_index.h 3 | * @brief Data structure for resolving 64bit keys by string (name). 4 | */ 5 | 6 | #ifndef FLECS_NAME_INDEX_H 7 | #define FLECS_NAME_INDEX_H 8 | 9 | /** Type used for internal string hashmap */ 10 | typedef struct ecs_hashed_string_t { 11 | char *value; 12 | ecs_size_t length; 13 | uint64_t hash; 14 | } ecs_hashed_string_t; 15 | 16 | void flecs_name_index_init( 17 | ecs_hashmap_t *hm, 18 | ecs_allocator_t *allocator); 19 | 20 | void flecs_name_index_init_if( 21 | ecs_hashmap_t *hm, 22 | ecs_allocator_t *allocator); 23 | 24 | bool flecs_name_index_is_init( 25 | const ecs_hashmap_t *hm); 26 | 27 | ecs_hashmap_t* flecs_name_index_new( 28 | ecs_world_t *world, 29 | ecs_allocator_t *allocator); 30 | 31 | void flecs_name_index_fini( 32 | ecs_hashmap_t *map); 33 | 34 | void flecs_name_index_free( 35 | ecs_hashmap_t *map); 36 | 37 | ecs_hashmap_t* flecs_name_index_copy( 38 | ecs_hashmap_t *dst); 39 | 40 | ecs_hashed_string_t flecs_get_hashed_string( 41 | const char *name, 42 | ecs_size_t length, 43 | uint64_t hash); 44 | 45 | const uint64_t* flecs_name_index_find_ptr( 46 | const ecs_hashmap_t *map, 47 | const char *name, 48 | ecs_size_t length, 49 | uint64_t hash); 50 | 51 | uint64_t flecs_name_index_find( 52 | const ecs_hashmap_t *map, 53 | const char *name, 54 | ecs_size_t length, 55 | uint64_t hash); 56 | 57 | void flecs_name_index_ensure( 58 | ecs_hashmap_t *map, 59 | uint64_t id, 60 | const char *name, 61 | ecs_size_t length, 62 | uint64_t hash); 63 | 64 | void flecs_name_index_remove( 65 | ecs_hashmap_t *map, 66 | uint64_t id, 67 | uint64_t hash); 68 | 69 | void flecs_name_index_update_name( 70 | ecs_hashmap_t *map, 71 | uint64_t e, 72 | uint64_t hash, 73 | const char *name); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/entity_name.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file entity_name.h 3 | * @brief Utilities for looking up entities by name. 4 | */ 5 | 6 | #include "private_api.h" 7 | 8 | /* Called during bootstrap to register entity name logic with world. */ 9 | void flecs_bootstrap_entity_name( 10 | ecs_world_t *world); 11 | 12 | /* Update lookup index for entity names. */ 13 | void flecs_reparent_name_index( 14 | ecs_world_t *world, 15 | ecs_table_t *src, 16 | ecs_table_t *dst, 17 | int32_t offset, 18 | int32_t count); 19 | 20 | void flecs_unparent_name_index( 21 | ecs_world_t *world, 22 | ecs_table_t *src, 23 | int32_t offset, 24 | int32_t count); 25 | 26 | /* Hook (on_set/on_remove) for updating lookup index for entity names. */ 27 | void ecs_on_set(EcsIdentifier)( 28 | ecs_iter_t *it); 29 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/flecs.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "flecs.h" 3 | 4 | namespace flecs { 5 | namespace _ { 6 | 7 | FLECSLIBRARY_API robin_hood::unordered_map g_type_to_impl_data; 8 | 9 | //FLECSLIBRARY_API robin_hood::unordered_map g_enum_to_impl_data; 10 | } // namespace _ 11 | } // namespace flecs -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/instantiate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file instantiate.h 3 | * @brief Functions for instantiating prefabs (IsA relationship). 4 | */ 5 | 6 | #ifndef FLECS_INSTANTIATE_H 7 | #define FLECS_INSTANTIATE_H 8 | 9 | typedef struct ecs_instantiate_ctx_t { 10 | ecs_entity_t root_prefab; 11 | ecs_entity_t root_instance; 12 | } ecs_instantiate_ctx_t; 13 | 14 | /* Instantiate prefab for entity. Called when adding (IsA, prefab). */ 15 | void flecs_instantiate( 16 | ecs_world_t *world, 17 | ecs_entity_t base, 18 | ecs_entity_t instance, 19 | const ecs_instantiate_ctx_t *ctx); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/iter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file iter.h 3 | * @brief Iterator utilities. 4 | */ 5 | 6 | #ifndef FLECS_ITER_H 7 | #define FLECS_ITER_H 8 | 9 | /* Initialize iterator. */ 10 | void flecs_iter_init( 11 | const ecs_world_t *world, 12 | ecs_iter_t *it, 13 | bool alloc_resources); 14 | 15 | /* Deinitialize iterator. */ 16 | void flecs_iter_free( 17 | void *ptr, 18 | ecs_size_t size); 19 | 20 | /* Allocate zero initialized memory from iterator allocator. */ 21 | void* flecs_iter_calloc( 22 | ecs_iter_t *it, 23 | ecs_size_t size, 24 | ecs_size_t align); 25 | 26 | #define flecs_iter_calloc_t(it, T)\ 27 | flecs_iter_calloc(it, ECS_SIZEOF(T), ECS_ALIGNOF(T)) 28 | 29 | #define flecs_iter_calloc_n(it, T, count)\ 30 | flecs_iter_calloc(it, ECS_SIZEOF(T) * count, ECS_ALIGNOF(T)) 31 | 32 | #define flecs_iter_free_t(ptr, T)\ 33 | flecs_iter_free(ptr, ECS_SIZEOF(T)) 34 | 35 | #define flecs_iter_free_n(ptr, T, count)\ 36 | flecs_iter_free(ptr, ECS_SIZEOF(T) * count) 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/query/cache/cache_iter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file query/cache/iter.h 3 | * @brief Cache iterator functions. 4 | */ 5 | 6 | #include "../types.h" 7 | 8 | void flecs_query_cache_iter_init( 9 | ecs_iter_t *it, 10 | ecs_query_iter_t *qit, 11 | ecs_query_impl_t *impl); 12 | 13 | /* Cache search */ 14 | bool flecs_query_cache_search( 15 | const ecs_query_run_ctx_t *ctx); 16 | 17 | /* Cache search where entire query is cached */ 18 | bool flecs_query_is_cache_search( 19 | const ecs_query_run_ctx_t *ctx); 20 | 21 | /* Cache test */ 22 | bool flecs_query_cache_test( 23 | const ecs_query_run_ctx_t *ctx, 24 | bool redo); 25 | 26 | /* Cache test where entire query is cached */ 27 | bool flecs_query_is_cache_test( 28 | const ecs_query_run_ctx_t *ctx, 29 | bool redo); 30 | 31 | bool flecs_query_is_trivial_cache_search( 32 | const ecs_query_run_ctx_t *ctx); 33 | 34 | bool flecs_query_is_trivial_cache_test( 35 | const ecs_query_run_ctx_t *ctx, 36 | bool redo); 37 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/query/cache/change_detection.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file query/cache/change_detection.h 3 | * @brief Query change detection implementation. 4 | */ 5 | 6 | void flecs_query_sync_match_monitor( 7 | ecs_query_impl_t *impl, 8 | ecs_query_cache_match_t *match); 9 | 10 | void flecs_query_mark_fields_dirty( 11 | ecs_query_impl_t *impl, 12 | ecs_iter_t *it); 13 | 14 | bool flecs_query_check_table_monitor( 15 | ecs_query_impl_t *impl, 16 | ecs_query_cache_match_t *qm, 17 | int32_t term); 18 | 19 | void flecs_query_mark_fixed_fields_dirty( 20 | ecs_query_impl_t *impl, 21 | ecs_iter_t *it); 22 | 23 | bool flecs_query_update_fixed_monitor( 24 | ecs_query_impl_t *impl); 25 | 26 | bool flecs_query_check_fixed_monitor( 27 | ecs_query_impl_t *impl); 28 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/query/cache/group.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file query/cache/group.h 3 | * @brief Adding/removing tables to query groups 4 | */ 5 | 6 | ecs_query_cache_group_t* flecs_query_cache_get_group( 7 | const ecs_query_cache_t *cache, 8 | uint64_t group_id); 9 | 10 | ecs_query_cache_match_t* flecs_query_cache_add_table( 11 | ecs_query_cache_t *cache, 12 | ecs_table_t *table); 13 | 14 | ecs_query_cache_match_t* flecs_query_cache_ensure_table( 15 | ecs_query_cache_t *cache, 16 | ecs_table_t *table); 17 | 18 | void flecs_query_cache_remove_table( 19 | ecs_query_cache_t *cache, 20 | ecs_table_t *table); 21 | 22 | void flecs_query_cache_remove_all_tables( 23 | ecs_query_cache_t *cache); 24 | 25 | ecs_query_cache_table_t* flecs_query_cache_get_table( 26 | const ecs_query_cache_t *cache, 27 | ecs_table_t *table); 28 | 29 | ecs_query_cache_match_t* flecs_query_cache_match_from_table( 30 | const ecs_query_cache_t *cache, 31 | const ecs_query_cache_table_t *qt); 32 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/query/cache/match.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file query/cache/match.h 3 | * @brief Match table one or more times with query. 4 | */ 5 | 6 | void flecs_query_cache_match_fini( 7 | ecs_query_cache_t *cache, 8 | ecs_query_cache_match_t *qm); 9 | 10 | bool flecs_query_cache_match_next( 11 | ecs_query_cache_t *cache, 12 | ecs_iter_t *it); 13 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/query/engine/trivial_iter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file query/engine/trivial_iter.h 3 | * @brief Trivial iterator functions. 4 | */ 5 | 6 | #include "../types.h" 7 | 8 | /* Iterator for queries with trivial terms. */ 9 | bool flecs_query_trivial_search( 10 | const ecs_query_run_ctx_t *ctx, 11 | ecs_query_trivial_ctx_t *op_ctx, 12 | bool redo, 13 | ecs_flags64_t field_set); 14 | 15 | /* Iterator for queries with only trivial terms. */ 16 | bool flecs_query_is_trivial_search( 17 | const ecs_query_run_ctx_t *ctx, 18 | ecs_query_trivial_ctx_t *op_ctx, 19 | bool redo); 20 | 21 | /* Trivial test for constrained $this. */ 22 | bool flecs_query_trivial_test( 23 | const ecs_query_run_ctx_t *ctx, 24 | bool first, 25 | ecs_flags64_t field_set); 26 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/query/query.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file query/query.h 3 | * @brief Query implementation. 4 | */ 5 | 6 | #include "compiler/compiler.h" 7 | #include "cache/cache.h" 8 | #include "engine/engine.h" 9 | #include "util.h" 10 | 11 | #ifdef FLECS_DEBUG 12 | #define flecs_set_var_label(var, lbl) (var)->label = lbl 13 | #else 14 | #define flecs_set_var_label(var, lbl) 15 | #endif 16 | 17 | /* Fast function for finalizing simple queries */ 18 | bool flecs_query_finalize_simple( 19 | ecs_world_t *world, 20 | ecs_query_t *q, 21 | const ecs_query_desc_t *desc); 22 | 23 | /* Finalize query data & validate */ 24 | int flecs_query_finalize_query( 25 | ecs_world_t *world, 26 | ecs_query_t *q, 27 | const ecs_query_desc_t *desc); 28 | 29 | /* Copy terms, sizes and ids arrays from stack to heap */ 30 | void flecs_query_copy_arrays( 31 | ecs_query_t *q); 32 | 33 | /* Free terms, sizes and ids arrays */ 34 | void flecs_query_free_arrays( 35 | ecs_query_t *q); 36 | 37 | /* Internal function for creating iterator, doesn't run aperiodic tasks */ 38 | ecs_iter_t flecs_query_iter( 39 | const ecs_world_t *world, 40 | const ecs_query_t *q); 41 | 42 | /* Internal function for initializing an iterator after vars are constrained */ 43 | void flecs_query_iter_constrain( 44 | ecs_iter_t *it); 45 | 46 | /* Rematch query after cache could have been invalidated */ 47 | void flecs_query_rematch( 48 | ecs_world_t *world, 49 | ecs_query_t *q); 50 | 51 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/storage/ordered_children.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file storage/ordered_children.h 3 | * @brief Storage for ordered list of entity (child) ids. 4 | */ 5 | 6 | #ifndef FLECS_ORDERED_CHILDREN_H 7 | #define FLECS_ORDERED_CHILDREN_H 8 | 9 | /* Initialize ordered children storage. */ 10 | void flecs_ordered_children_init( 11 | ecs_world_t *world, 12 | ecs_component_record_t *cr); 13 | 14 | /* Free ordered children storage. */ 15 | void flecs_ordered_children_fini( 16 | ecs_world_t *world, 17 | ecs_component_record_t *cr); 18 | 19 | /* Populate ordered children storage with existing children. */ 20 | void flecs_ordered_children_populate( 21 | ecs_world_t *world, 22 | ecs_component_record_t *cr); 23 | 24 | /* Clear ordered children storage. */ 25 | void flecs_ordered_children_clear( 26 | ecs_component_record_t *cr); 27 | 28 | /* Reparent entities in ordered children storage. */ 29 | void flecs_ordered_children_reparent( 30 | ecs_world_t *world, 31 | const ecs_table_t *src, 32 | const ecs_table_t *dst, 33 | int32_t row, 34 | int32_t count); 35 | 36 | /* Unparent entities in ordered children storage. */ 37 | void flecs_ordered_children_unparent( 38 | ecs_world_t *world, 39 | const ecs_table_t *src, 40 | int32_t row, 41 | int32_t count); 42 | 43 | /* Reorder entities in ordered children storage. */ 44 | void flecs_ordered_children_reorder( 45 | ecs_world_t *world, 46 | ecs_component_record_t *cr, 47 | const ecs_entity_t *children, 48 | int32_t child_count); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Private/storage/sparse_storage.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file storage/sparse_storage.h 3 | * @brief Sparse component storage. 4 | */ 5 | 6 | #ifndef FLECS_SPARSE_STORAGE_H 7 | #define FLECS_SPARSE_STORAGE_H 8 | 9 | bool flecs_component_sparse_has( 10 | ecs_component_record_t *cr, 11 | ecs_entity_t entity); 12 | 13 | void* flecs_component_sparse_get( 14 | ecs_component_record_t *cr, 15 | ecs_entity_t entity); 16 | 17 | void* flecs_component_sparse_insert( 18 | ecs_world_t *world, 19 | ecs_component_record_t *cr, 20 | ecs_table_t *table, 21 | int32_t row); 22 | 23 | void* flecs_component_sparse_emplace( 24 | ecs_world_t *world, 25 | ecs_component_record_t *cr, 26 | ecs_table_t *table, 27 | int32_t row); 28 | 29 | void flecs_component_sparse_remove( 30 | ecs_world_t *world, 31 | ecs_component_record_t *cr, 32 | ecs_table_t *table, 33 | int32_t row); 34 | 35 | void flecs_component_sparse_remove_all( 36 | ecs_world_t *world, 37 | ecs_component_record_t *cr); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/FlecsLibrary.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | class FFlecsLibraryModule : public IModuleInterface 7 | { 8 | public: 9 | virtual void StartupModule() override; 10 | virtual void ShutdownModule() override; 11 | }; // class FFlecsLibraryModule 12 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/Unreal/FlecsScriptClassComponent.h: -------------------------------------------------------------------------------- 1 | // Solstice Games © 2024. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Standard/Hashing.h" 7 | #include "FlecsScriptClassComponent.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct FLECSLIBRARY_API FFlecsScriptClassComponent 11 | { 12 | GENERATED_BODY() 13 | 14 | NO_DISCARD FORCEINLINE friend uint32 GetTypeHash(const FFlecsScriptClassComponent& InScriptClassComponent) 15 | { 16 | return GetTypeHash(InScriptClassComponent.ScriptClass); 17 | } 18 | 19 | NO_DISCARD FORCEINLINE friend bool operator==(const FFlecsScriptClassComponent& Lhs, const FFlecsScriptClassComponent& Rhs) 20 | { 21 | return Lhs.ScriptClass == Rhs.ScriptClass; 22 | } 23 | 24 | NO_DISCARD FORCEINLINE friend bool operator!=(const FFlecsScriptClassComponent& Lhs, const FFlecsScriptClassComponent& Rhs) 25 | { 26 | return !(Lhs == Rhs); 27 | } 28 | 29 | FORCEINLINE operator TSubclassOf() const { return ScriptClass.Get(); } 30 | 31 | FORCEINLINE FFlecsScriptClassComponent(const TSubclassOf& InScriptClass = nullptr) : ScriptClass(InScriptClass) {} 32 | 33 | template 34 | NO_DISCARD FORCEINLINE TSubclassOf Get() const 35 | { 36 | return Cast(ScriptClass.Get()); 37 | } 38 | 39 | template 40 | NO_DISCARD FORCEINLINE TSubclassOf GetChecked() const 41 | { 42 | return CastChecked(ScriptClass.Get()); 43 | } 44 | 45 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Flecs") 46 | TSubclassOf ScriptClass; 47 | 48 | }; // struct FFlecsScriptClassComponent 49 | 50 | DEFINE_STD_HASH(FFlecsScriptClassComponent) 51 | 52 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/Unreal/FlecsScriptEnumComponent.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Standard/Hashing.h" 7 | #include "FlecsScriptEnumComponent.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct FLECSLIBRARY_API FFlecsScriptEnumComponent 11 | { 12 | GENERATED_BODY() 13 | 14 | NO_DISCARD FORCEINLINE friend uint32 GetTypeHash(const FFlecsScriptEnumComponent& InScriptEnumComponent) 15 | { 16 | return GetTypeHash(InScriptEnumComponent.ScriptEnum); 17 | } 18 | 19 | NO_DISCARD FORCEINLINE friend bool operator==(const FFlecsScriptEnumComponent& Lhs, const FFlecsScriptEnumComponent& Rhs) 20 | { 21 | return Lhs.ScriptEnum == Rhs.ScriptEnum; 22 | } 23 | 24 | NO_DISCARD FORCEINLINE friend bool operator!=(const FFlecsScriptEnumComponent& Lhs, const FFlecsScriptEnumComponent& Rhs) 25 | { 26 | return !(Lhs == Rhs); 27 | } 28 | 29 | FORCEINLINE operator UEnum*() const { return ScriptEnum.Get(); } 30 | 31 | FORCEINLINE FFlecsScriptEnumComponent(UEnum* InScriptEnum = nullptr) 32 | : ScriptEnum(InScriptEnum) {} 33 | FORCEINLINE FFlecsScriptEnumComponent(const UEnum* InScriptEnum) 34 | : ScriptEnum(const_cast(InScriptEnum)) {} 35 | FORCEINLINE FFlecsScriptEnumComponent(const FFlecsScriptEnumComponent& InScriptEnumComponent) 36 | : ScriptEnum(InScriptEnumComponent.ScriptEnum) {} 37 | 38 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Flecs") 39 | TWeakObjectPtr ScriptEnum; 40 | 41 | }; // struct FFlecsScriptEnumComponent 42 | 43 | DEFINE_STD_HASH(FFlecsScriptEnumComponent) 44 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/Unreal/FlecsScriptStructComponent.h: -------------------------------------------------------------------------------- 1 | // Solstice Games © 2024. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Standard/Hashing.h" 7 | #include "FlecsScriptStructComponent.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct FLECSLIBRARY_API FFlecsScriptStructComponent 11 | { 12 | GENERATED_BODY() 13 | 14 | NO_DISCARD FORCEINLINE friend uint32 GetTypeHash(const FFlecsScriptStructComponent& InScriptStructComponent) 15 | { 16 | return GetTypeHash(InScriptStructComponent.ScriptStruct); 17 | } 18 | 19 | NO_DISCARD FORCEINLINE friend bool operator==(const FFlecsScriptStructComponent& Lhs, const FFlecsScriptStructComponent& Rhs) 20 | { 21 | return Lhs.ScriptStruct == Rhs.ScriptStruct; 22 | } 23 | 24 | NO_DISCARD FORCEINLINE friend bool operator!=(const FFlecsScriptStructComponent& Lhs, const FFlecsScriptStructComponent& Rhs) 25 | { 26 | return !(Lhs == Rhs); 27 | } 28 | 29 | FORCEINLINE operator UScriptStruct*() const { return ScriptStruct.Get(); } 30 | 31 | FORCEINLINE FFlecsScriptStructComponent(UScriptStruct* InScriptStruct = nullptr) 32 | : ScriptStruct(InScriptStruct) {} 33 | FORCEINLINE FFlecsScriptStructComponent(const UScriptStruct* InScriptStruct) 34 | : ScriptStruct(const_cast(InScriptStruct)) {} 35 | FORCEINLINE FFlecsScriptStructComponent(const FFlecsScriptStructComponent& InScriptStructComponent) 36 | : ScriptStruct(InScriptStructComponent.ScriptStruct) {} 37 | 38 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Flecs") 39 | TWeakObjectPtr ScriptStruct; 40 | 41 | }; // struct FFlecsScriptStructComponent 42 | 43 | DEFINE_STD_HASH(FFlecsScriptStructComponent) 44 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/Unreal/FlecsTypeMapComponent.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsScriptEnumComponent.h" 7 | #include "FlecsScriptStructComponent.h" 8 | #include "Standard/robin_hood.h" 9 | 10 | struct FFlecsTypeMapComponent final 11 | { 12 | mutable robin_hood::unordered_flat_map ScriptStructMap; 13 | mutable robin_hood::unordered_flat_map ScriptEnumMap; 14 | }; // struct FFlecsTypeMapComponent 15 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/alerts/builder.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/alerts/builder.hpp 3 | * @brief Alert builder. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "../../utils/builder.hpp" 9 | #include "builder_i.hpp" 10 | 11 | namespace flecs { 12 | namespace _ { 13 | template 14 | using alert_builder_base = builder< 15 | alert, ecs_alert_desc_t, alert_builder, 16 | alert_builder_i, Components ...>; 17 | } 18 | 19 | /** Alert builder. 20 | * 21 | * @ingroup cpp_addons_alerts 22 | */ 23 | template 24 | struct alert_builder final : _::alert_builder_base { 25 | alert_builder(flecs::world_t* world, const char *name = nullptr) 26 | : _::alert_builder_base(world) 27 | { 28 | _::sig(world).populate(this); 29 | if (name != nullptr) { 30 | ecs_entity_desc_t entity_desc = {}; 31 | entity_desc.name = name; 32 | entity_desc.sep = "::"; 33 | entity_desc.root_sep = "::"; 34 | this->desc_.entity = ecs_entity_init(world, &entity_desc); 35 | } 36 | } 37 | }; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/alerts/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/alerts/decl.hpp 3 | * @brief Alert declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_addons_alerts Alerts 12 | * @ingroup cpp_addons 13 | * Alert implementation. 14 | * 15 | * @{ 16 | */ 17 | 18 | /** Module */ 19 | struct alerts { 20 | using AlertsActive = EcsAlertsActive; 21 | using Instance = EcsAlertInstance; 22 | 23 | struct Alert { }; 24 | struct Info { }; 25 | struct Warning { }; 26 | struct Error { }; 27 | 28 | alerts(flecs::world& world); 29 | }; 30 | 31 | template 32 | struct alert; 33 | 34 | template 35 | struct alert_builder; 36 | 37 | /** @} */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/alerts/entity_view.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/alerts/entity_view.inl 3 | * @brief Alerts entity mixin. 4 | */ 5 | 6 | /** Return number of alerts for entity. 7 | * 8 | * @memberof flecs::entity_view 9 | * @ingroup cpp_addons_alerts 10 | */ 11 | int32_t alert_count(flecs::entity_t alert = 0) const { 12 | return ecs_get_alert_count(world_, id_, alert); 13 | } 14 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/alerts/impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/alerts/impl.hpp 3 | * @brief Alerts module implementation. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "builder.hpp" 9 | 10 | namespace flecs { 11 | 12 | template 13 | struct alert final : entity 14 | { 15 | using entity::entity; 16 | 17 | explicit alert() { 18 | id_ = 0; 19 | world_ = nullptr; 20 | } 21 | 22 | explicit alert(flecs::world_t *world, ecs_alert_desc_t *desc) { 23 | world_ = world; 24 | id_ = ecs_alert_init(world, desc); 25 | } 26 | }; 27 | 28 | inline alerts::alerts(flecs::world& world) { 29 | world.import(); 30 | 31 | /* Import C module */ 32 | FlecsAlertsImport(world); 33 | 34 | world.component(); 35 | world.component(); 36 | 37 | world.entity("::flecs::alerts::Alert"); 38 | world.entity("::flecs::alerts::Info"); 39 | world.entity("::flecs::alerts::Warning"); 40 | world.entity("::flecs::alerts::Error"); 41 | } 42 | 43 | template 44 | inline flecs::alert_builder world::alert(Args &&... args) const { 45 | return flecs::alert_builder(world_, FLECS_FWD(args)...); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/alerts/mixin.inl: -------------------------------------------------------------------------------- 1 | 2 | /** Create alert. 3 | * 4 | * @ingroup cpp_addons_alerts 5 | * @memberof flecs::world 6 | */ 7 | template 8 | flecs::alert_builder alert(Args &&... args) const; 9 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/app/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/app/decl.hpp 3 | * @brief App addon declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "builder.hpp" 9 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/app/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/app/mixin.inl 3 | * @brief App world addon mixin. 4 | */ 5 | 6 | /** 7 | * @ingroup cpp_addons_app 8 | * @memberof flecs::world 9 | * 10 | * @{ 11 | */ 12 | 13 | /** Return app builder. 14 | * The app builder is a convenience wrapper around a loop that runs 15 | * world::progress. An app allows for writing platform agnostic code, 16 | * as it provides hooks to modules for overtaking the main loop which is 17 | * required for frameworks like emscripten. 18 | */ 19 | flecs::app_builder app() { 20 | flecs::world_t *w = world_; 21 | world_ = nullptr; // Take ownership 22 | return flecs::app_builder(w); 23 | } 24 | 25 | /** @} */ 26 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/component/impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/component/impl.hpp 3 | * @brief Component mixin implementation 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | template 11 | inline flecs::component world::component(Args &&... args) const { 12 | return flecs::component(world_, FLECS_FWD(args)...); 13 | } 14 | 15 | template 16 | inline flecs::untyped_component world::component(Args &&... args) const { 17 | return flecs::untyped_component(world_, FLECS_FWD(args)...); 18 | } 19 | 20 | } // namespace flecs 21 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/component/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/component/mixin.inl 3 | * @brief Component mixin. 4 | */ 5 | 6 | /** Find or register component. 7 | * 8 | * @ingroup cpp_components 9 | * @memberof flecs::world 10 | */ 11 | template 12 | flecs::component component(Args &&... args) const; 13 | 14 | /** Find or register untyped component. 15 | * Method available on flecs::world class. 16 | * 17 | * @ingroup cpp_components 18 | * @memberof flecs::world 19 | */ 20 | template 21 | flecs::untyped_component component(Args &&... args) const; 22 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/doc/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/doc/decl.hpp 3 | * @brief Doc mixin declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | namespace doc { 10 | 11 | /** 12 | * @defgroup cpp_addons_doc Doc 13 | * @ingroup cpp_addons 14 | * Utilities for documenting entities, components and systems. 15 | * 16 | * @{ 17 | */ 18 | 19 | /** flecs.doc.Description component */ 20 | using Description = EcsDocDescription; 21 | 22 | /** flecs.doc.Uuid component */ 23 | static const flecs::entity_t Uuid = EcsDocUuid; 24 | 25 | /** flecs.doc.Brief component */ 26 | static const flecs::entity_t Brief = EcsDocBrief; 27 | 28 | /** flecs.doc.Detail component */ 29 | static const flecs::entity_t Detail = EcsDocDetail; 30 | 31 | /** flecs.doc.Link component */ 32 | static const flecs::entity_t Link = EcsDocLink; 33 | 34 | /** flecs.doc.Color component */ 35 | static const flecs::entity_t Color = EcsDocColor; 36 | 37 | /** @private */ 38 | namespace _ { 39 | /** @private */ 40 | void init(flecs::world& world); 41 | } 42 | 43 | /** @} */ 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/entity/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/entity/mixin.inl 3 | * @brief Entity world mixin. 4 | */ 5 | 6 | /** Create an entity. 7 | * 8 | * @memberof flecs::world 9 | * @ingroup cpp_entities 10 | */ 11 | template 12 | flecs::entity entity(Args &&... args) const; 13 | 14 | /** Convert enum constant to entity. 15 | * 16 | * @memberof flecs::world 17 | * @ingroup cpp_entities 18 | */ 19 | template ::value > = 0> 20 | flecs::id id(E value) const; 21 | 22 | /** Convert enum constant to entity. 23 | * 24 | * @memberof flecs::world 25 | * @ingroup cpp_entities 26 | */ 27 | template ::value > = 0> 28 | flecs::entity entity(E value) const; 29 | 30 | /** Create a prefab. 31 | * 32 | * @memberof flecs::world 33 | * @ingroup cpp_entities 34 | */ 35 | template 36 | flecs::entity prefab(Args &&... args) const; 37 | 38 | /** Create an entity that's associated with a type. 39 | * 40 | * @memberof flecs::world 41 | * @ingroup cpp_entities 42 | */ 43 | template 44 | flecs::entity entity(const char *name = nullptr) const; 45 | 46 | /** Create a prefab that's associated with a type. 47 | * 48 | * @memberof flecs::world 49 | * @ingroup cpp_entities 50 | */ 51 | template 52 | flecs::entity prefab(const char *name = nullptr) const; 53 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/enum/entity_view.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/enum/entity_view.inl 3 | * @brief Enum entity view mixin. 4 | */ 5 | 6 | /** Convert entity to enum constant. 7 | * 8 | * @memberof flecs::entity_view 9 | * @ingroup cpp_entities 10 | */ 11 | template 12 | E to_constant() const; 13 | 14 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/enum/impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/enum/impl.hpp 3 | * @brief Enum implementation. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | template 11 | inline E entity_view::to_constant() const { 12 | #ifdef FLECS_META 13 | using U = typename std::underlying_type::type; 14 | const E* ptr = static_cast(ecs_get_id(world_, id_, 15 | ecs_pair(flecs::Constant, _::type::id(world_)))); 16 | ecs_assert(ptr != NULL, ECS_INVALID_PARAMETER, "entity is not a constant"); 17 | return ptr[0]; 18 | #else 19 | ecs_assert(false, ECS_UNSUPPORTED, 20 | "operation not supported without FLECS_META addon"); 21 | return E(); 22 | #endif 23 | } 24 | 25 | template ::value >> 26 | inline flecs::entity world::to_entity(E constant) const { 27 | const auto& et = enum_type(world_); 28 | return flecs::entity(world_, et.entity(constant)); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/enum/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/enum/mixin.inl 3 | * @brief Enum world mixin. 4 | */ 5 | 6 | /** Convert enum constant to entity. 7 | * 8 | * @memberof flecs::world 9 | * @ingroup cpp_entities 10 | */ 11 | template ::value > = 0> 12 | flecs::entity to_entity(E constant) const; 13 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/event/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/event/decl.hpp 3 | * @brief Event declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "builder.hpp" 9 | 10 | namespace flecs { 11 | namespace _ { 12 | 13 | // Utility to derive event type from function 14 | template 15 | struct event_from_func; 16 | 17 | // Specialization for observer callbacks with a single argument 18 | template 19 | struct event_from_func::value == 1>> { 20 | using type = decay_t>; 21 | }; 22 | 23 | // Specialization for observer callbacks with an initial entity src argument 24 | template 25 | struct event_from_func::value == 2>> { 26 | using type = decay_t>; 27 | }; 28 | 29 | template 30 | using event_from_func_t = typename event_from_func::type; 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/event/entity_builder.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/event/entity_builder.inl 3 | * @brief Event entity mixin. 4 | */ 5 | 6 | /** Observe event on entity 7 | * 8 | * @memberof flecs::entity_builder 9 | * 10 | * @param evt The event id. 11 | * @param callback The observer callback. 12 | * @return Event builder. 13 | */ 14 | template 15 | const Self& observe(flecs::entity_t evt, Func&& callback) const; 16 | 17 | /** Observe event on entity 18 | * 19 | * @memberof flecs::entity_builder 20 | * 21 | * @tparam Evt The event type. 22 | * @param callback The observer callback. 23 | * @return Event builder. 24 | */ 25 | template 26 | const Self& observe(Func&& callback) const; 27 | 28 | /** Observe event on entity 29 | * 30 | * @memberof flecs::entity_builder 31 | * 32 | * @param callback The observer callback. 33 | * @return Event builder. 34 | */ 35 | template 36 | const Self& observe(Func&& callback) const; 37 | 38 | 39 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/event/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/event/mixin.inl 3 | * @brief Event world mixin. 4 | */ 5 | 6 | /** 7 | * @defgroup cpp_addons_event Events 8 | * @ingroup cpp_addons 9 | * API for emitting events. 10 | * 11 | * @{ 12 | */ 13 | 14 | /** Create a new event. 15 | * 16 | * @memberof flecs::world 17 | * 18 | * @param evt The event id. 19 | * @return Event builder. 20 | */ 21 | flecs::event_builder event(flecs::entity_t evt) const; 22 | 23 | /** Create a new event. 24 | * 25 | * @memberof flecs::world 26 | * 27 | * @tparam E The event type. 28 | * @return Event builder. 29 | */ 30 | template 31 | flecs::event_builder_typed event() const; 32 | 33 | /** @} */ 34 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/id/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/id/mixin.inl 3 | * @brief Id world mixin. 4 | */ 5 | 6 | /** Get id from a type. 7 | * 8 | * @memberof flecs::world 9 | */ 10 | template 11 | flecs::id id() const; 12 | 13 | /** Id factory. 14 | * 15 | * @memberof flecs::world 16 | */ 17 | template 18 | flecs::id id(Args&&... args) const; 19 | 20 | /** Get pair id from relationship, object. 21 | * 22 | * @memberof flecs::world 23 | */ 24 | template 25 | flecs::id pair() const; 26 | 27 | /** Get pair id from relationship, object. 28 | * 29 | * @memberof flecs::world 30 | */ 31 | template 32 | flecs::id pair(entity_t o) const; 33 | 34 | /** Get pair id from relationship, object. 35 | * 36 | * @memberof flecs::world 37 | */ 38 | flecs::id pair(entity_t r, entity_t o) const; 39 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/json/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/json/decl.hpp 3 | * @brief JSON addon declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_addons_json Json 12 | * @ingroup cpp_addons 13 | * Functions for serializing to/from JSON. 14 | * 15 | * @{ 16 | */ 17 | 18 | using from_json_desc_t = ecs_from_json_desc_t; 19 | using entity_to_json_desc_t = ecs_entity_to_json_desc_t; 20 | using iter_to_json_desc_t = ecs_iter_to_json_desc_t; 21 | 22 | /** @} */ 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/json/entity.inl: -------------------------------------------------------------------------------- 1 | 2 | /** Deserialize entity to JSON. 3 | * 4 | * @memberof flecs::entity 5 | * @ingroup cpp_addons_json 6 | */ 7 | const char* from_json(const char *json) { 8 | return ecs_entity_from_json(world_, id_, json, nullptr); 9 | } 10 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/json/entity_view.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/json/entity_view.inl 3 | * @brief JSON entity mixin. 4 | */ 5 | 6 | /** Serialize entity to JSON. 7 | * 8 | * @memberof flecs::entity_view 9 | * @ingroup cpp_addons_json 10 | */ 11 | flecs::string to_json(const flecs::entity_to_json_desc_t *desc = nullptr) const { 12 | char *json = ecs_entity_to_json(world_, id_, desc); 13 | return flecs::string(json); 14 | } 15 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/json/iterable.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/json/iterable.inl 3 | * @brief JSON iterable mixin. 4 | */ 5 | 6 | /** Serialize iterator result to JSON. 7 | * 8 | * @memberof flecs::iter 9 | * @ingroup cpp_addons_json 10 | */ 11 | flecs::string to_json(flecs::iter_to_json_desc_t *desc = nullptr) { 12 | char *json = ecs_iter_to_json(&it_, desc); 13 | return flecs::string(json); 14 | } 15 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/json/query.inl: -------------------------------------------------------------------------------- 1 | 2 | /** Serialize query to JSON. 3 | * 4 | * @memberof flecs::query_base 5 | * @ingroup cpp_addons_json 6 | */ 7 | flecs::string to_json(flecs::iter_to_json_desc_t *desc = nullptr) { 8 | ecs_iter_t it = ecs_query_iter(ecs_get_world(query_), query_); 9 | char *json = ecs_iter_to_json(&it, desc); 10 | return flecs::string(json); 11 | } -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/meta/component.inl: -------------------------------------------------------------------------------- 1 | 2 | /** Register opaque type interface */ 3 | template 4 | component& opaque(const Func& type_support) { 5 | flecs::world world(world_); 6 | auto ts = type_support(world); 7 | ts.desc.entity = _::type::id(world_); 8 | ecs_opaque_init(world_, &ts.desc); 9 | return *this; 10 | } 11 | 12 | flecs::opaque opaque(flecs::entity_t as_type) { 13 | return flecs::opaque(world_).as_type(as_type); 14 | } 15 | 16 | flecs::opaque opaque(flecs::entity as_type) { 17 | return this->opaque(as_type.id()); 18 | } 19 | 20 | flecs::opaque opaque(flecs::untyped_component as_type) { 21 | return this->opaque(as_type.id()); 22 | } 23 | 24 | /** Return opaque type builder for collection type */ 25 | template 26 | flecs::opaque opaque(flecs::id_t as_type) { 27 | return flecs::opaque(world_).as_type(as_type); 28 | } 29 | 30 | /** Add constant. */ 31 | component& constant(const char *name, T value) { 32 | using U = typename std::underlying_type::type; 33 | 34 | ecs_add_id(world_, id_, _::type::id(world_)); 35 | 36 | ecs_entity_desc_t desc = {}; 37 | desc.name = name; 38 | desc.parent = id_; 39 | ecs_entity_t eid = ecs_entity_init(world_, &desc); 40 | ecs_assert(eid != 0, ECS_INTERNAL_ERROR, NULL); 41 | 42 | flecs::id_t pair = ecs_pair(flecs::Constant, _::type::id(world_)); 43 | U *ptr = static_cast(ecs_ensure_id(world_, eid, pair)); 44 | *ptr = static_cast(value); 45 | ecs_modified_id(world_, eid, pair); 46 | 47 | return *this; 48 | } 49 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/meta/world.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/meta/world.inl 3 | * @brief Meta world mixin. 4 | */ 5 | 6 | /** 7 | * @memberof flecs::world 8 | * @ingroup cpp_addons_meta 9 | * 10 | * @{ 11 | */ 12 | 13 | /** Return meta cursor to value */ 14 | flecs::cursor cursor(flecs::entity_t tid, void *ptr) { 15 | return flecs::cursor(world_, tid, ptr); 16 | } 17 | 18 | /** Return meta cursor to value */ 19 | template 20 | flecs::cursor cursor(void *ptr) { 21 | flecs::entity_t tid = _::type::id(world_); 22 | return cursor(tid, ptr); 23 | } 24 | 25 | /** Create primitive type */ 26 | flecs::entity primitive(flecs::meta::primitive_kind_t kind); 27 | 28 | /** Create array type. */ 29 | flecs::entity array(flecs::entity_t elem_id, int32_t array_count); 30 | 31 | /** Create array type. */ 32 | template 33 | flecs::entity array(int32_t array_count); 34 | 35 | /** Create vector type. */ 36 | flecs::entity vector(flecs::entity_t elem_id); 37 | 38 | /** Create vector type. */ 39 | template 40 | flecs::entity vector(); 41 | 42 | /** @} */ 43 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/metrics/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/metrics/decl.hpp 3 | * @brief Metrics declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "builder.hpp" 9 | 10 | namespace flecs { 11 | 12 | /** 13 | * @defgroup cpp_addons_metrics Metrics 14 | * @ingroup cpp_addons 15 | * The metrics module extracts metrics from components and makes them available 16 | * through a unified component interface. 17 | * 18 | * @{ 19 | */ 20 | 21 | struct metrics { 22 | using Value = EcsMetricValue; 23 | using Source = EcsMetricSource; 24 | 25 | struct Instance { }; 26 | struct Metric { }; 27 | struct Counter { }; 28 | struct CounterIncrement { }; 29 | struct CounterId { }; 30 | struct Gauge { }; 31 | 32 | metrics(flecs::world& world); 33 | }; 34 | 35 | /** @} */ 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/metrics/mixin.inl: -------------------------------------------------------------------------------- 1 | 2 | /** Create metric. 3 | * 4 | * @ingroup cpp_addons_metrics 5 | * @memberof flecs::world 6 | */ 7 | template 8 | flecs::metric_builder metric(Args &&... args) const; 9 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/metrics/untyped_component.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/meta/untyped_component.inl 3 | * @brief Metrics component mixin. 4 | */ 5 | 6 | /** 7 | * @memberof flecs::component 8 | * @ingroup cpp_addons_metrics 9 | * 10 | * @{ 11 | */ 12 | 13 | /** Register member as metric. 14 | * When no explicit name is provided, this operation will derive the metric name 15 | * from the member name. When the member name is "value", the operation will use 16 | * the name of the component. 17 | * 18 | * When the brief parameter is provided, it is set on the metric as if 19 | * set_doc_brief is used. The brief description can be obtained with 20 | * get_doc_brief. 21 | * 22 | * @tparam Kind Metric kind (Counter, CounterIncrement or Gauge). 23 | * @param parent Parent entity of the metric (optional). 24 | * @param brief Description for metric (optional). 25 | * @param name Name of metric (optional). 26 | */ 27 | template 28 | untyped_component& metric( 29 | flecs::entity_t parent = 0, 30 | const char *brief = nullptr, 31 | const char *name = nullptr); 32 | 33 | /** @} */ 34 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/module/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/module/mixin.inl 3 | * @brief Module world mixin. 4 | */ 5 | 6 | /** 7 | * @memberof flecs::world 8 | * @ingroup cpp_addons_modules 9 | * 10 | * @{ 11 | */ 12 | 13 | /** Define a module. 14 | * This operation is not mandatory, but can be called inside the module ctor to 15 | * obtain the entity associated with the module, or override the module name. 16 | * 17 | * @tparam Module module class. 18 | * @return Module entity. 19 | */ 20 | template 21 | flecs::entity module(const char *name = nullptr) const; 22 | 23 | /** Import a module. 24 | * 25 | * @tparam Module module class. 26 | * @return Module entity. 27 | */ 28 | template 29 | flecs::entity import(); 30 | 31 | /** @} */ 32 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/observer/builder.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/observer/builder.hpp 3 | * @brief Observer builder. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "../../utils/node_builder.hpp" 9 | #include "builder_i.hpp" 10 | 11 | namespace flecs { 12 | namespace _ { 13 | template 14 | using observer_builder_base = node_builder< 15 | observer, ecs_observer_desc_t, observer_builder, 16 | observer_builder_i, Components ...>; 17 | } 18 | 19 | /** Observer builder. 20 | * 21 | * @ingroup cpp_observers 22 | */ 23 | template 24 | struct observer_builder final : _::observer_builder_base { 25 | observer_builder(flecs::world_t* world, const char *name = nullptr) 26 | : _::observer_builder_base(world, name) 27 | { 28 | _::sig(world).populate(this); 29 | } 30 | }; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/observer/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/observer/decl.hpp 3 | * @brief Observer declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_observers Observers 12 | * @ingroup cpp_core 13 | * Observers let applications register callbacks for ECS events. 14 | * 15 | * @{ 16 | */ 17 | 18 | struct observer; 19 | 20 | template 21 | struct observer_builder; 22 | 23 | /** @} */ 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/observer/impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/observer/impl.hpp 3 | * @brief Observer implementation. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "builder.hpp" 9 | 10 | namespace flecs 11 | { 12 | 13 | struct observer final : entity 14 | { 15 | using entity::entity; 16 | 17 | explicit observer() : entity() { } 18 | 19 | observer(flecs::world_t *world, ecs_observer_desc_t *desc) { 20 | world_ = world; 21 | id_ = ecs_observer_init(world, desc); 22 | } 23 | 24 | void ctx(void *ctx) { 25 | ecs_observer_desc_t desc = {}; 26 | desc.entity = id_; 27 | desc.ctx = ctx; 28 | ecs_observer_init(world_, &desc); 29 | } 30 | 31 | void* ctx() const { 32 | return ecs_observer_get(world_, id_)->ctx; 33 | } 34 | 35 | flecs::query<> query() const { 36 | return flecs::query<>(ecs_observer_get(world_, id_)->query); 37 | } 38 | }; 39 | 40 | // Mixin implementation 41 | inline observer world::observer(flecs::entity e) const { 42 | return flecs::observer(world_, e); 43 | } 44 | 45 | template 46 | inline observer_builder world::observer(Args &&... args) const { 47 | return flecs::observer_builder(world_, FLECS_FWD(args)...); 48 | } 49 | 50 | } // namespace flecs 51 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/observer/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/observer/mixin.inl 3 | * @brief Observer world mixin. 4 | */ 5 | 6 | /** Observer builder. 7 | * 8 | * @memberof flecs::world 9 | * @ingroup cpp_observers 10 | * 11 | * @{ 12 | */ 13 | 14 | /** Upcast entity to an observer. 15 | * The provided entity must be an observer. 16 | * 17 | * @param e The entity. 18 | * @return An observer object. 19 | */ 20 | flecs::observer observer(flecs::entity e) const; 21 | 22 | /** Create a new observer. 23 | * 24 | * @tparam Components The components to match on. 25 | * @tparam Args Arguments passed to the constructor of flecs::observer_builder. 26 | * @return Observer builder. 27 | */ 28 | template 29 | flecs::observer_builder observer(Args &&... args) const; 30 | 31 | /** @} */ 32 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/pipeline/builder.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/pipeline/builder.hpp 3 | * @brief Pipeline builder. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "../../utils/builder.hpp" 9 | #include "builder_i.hpp" 10 | 11 | namespace flecs { 12 | namespace _ { 13 | template 14 | using pipeline_builder_base = builder< 15 | pipeline, ecs_pipeline_desc_t, pipeline_builder, 16 | pipeline_builder_i, Components ...>; 17 | } 18 | 19 | /** Pipeline builder. 20 | * 21 | * @ingroup cpp_pipelines 22 | */ 23 | template 24 | struct pipeline_builder final : _::pipeline_builder_base { 25 | pipeline_builder(flecs::world_t* world, flecs::entity_t id = 0) 26 | : _::pipeline_builder_base(world) 27 | { 28 | _::sig(world).populate(this); 29 | this->desc_.entity = id; 30 | } 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/pipeline/builder_i.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/pipeline/builder_i.hpp 3 | * @brief Pipeline builder interface. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "../query/builder_i.hpp" 9 | 10 | namespace flecs { 11 | 12 | /** Pipeline builder interface. 13 | * 14 | * @ingroup cpp_pipelines 15 | */ 16 | template 17 | struct pipeline_builder_i : query_builder_i { 18 | pipeline_builder_i(ecs_pipeline_desc_t *desc, int32_t term_index = 0) 19 | : query_builder_i(&desc->query, term_index) 20 | , desc_(desc) { } 21 | 22 | private: 23 | ecs_pipeline_desc_t *desc_; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/pipeline/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/pipeline/decl.hpp 3 | * @brief Pipeline module declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_pipelines Pipelines 12 | * @ingroup cpp_addons 13 | * Pipelines order and schedule systems for execution. 14 | * 15 | * @{ 16 | */ 17 | 18 | template 19 | struct pipeline; 20 | 21 | template 22 | struct pipeline_builder; 23 | 24 | /* Builtin pipeline tags */ 25 | static const flecs::entity_t OnStart = EcsOnStart; 26 | static const flecs::entity_t PreFrame = EcsPreFrame; 27 | static const flecs::entity_t OnLoad = EcsOnLoad; 28 | static const flecs::entity_t PostLoad = EcsPostLoad; 29 | static const flecs::entity_t PreUpdate = EcsPreUpdate; 30 | static const flecs::entity_t OnUpdate = EcsOnUpdate; 31 | static const flecs::entity_t OnValidate = EcsOnValidate; 32 | static const flecs::entity_t PostUpdate = EcsPostUpdate; 33 | static const flecs::entity_t PreStore = EcsPreStore; 34 | static const flecs::entity_t OnStore = EcsOnStore; 35 | static const flecs::entity_t PostFrame = EcsPostFrame; 36 | 37 | /** @} */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/query/builder.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/query/builder.hpp 3 | * @brief Query builder. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "../../utils/builder.hpp" 9 | #include "builder_i.hpp" 10 | 11 | namespace flecs { 12 | namespace _ { 13 | template 14 | using query_builder_base = builder< 15 | query, ecs_query_desc_t, query_builder, 16 | query_builder_i, Components ...>; 17 | } 18 | 19 | /** Query builder. 20 | * 21 | * @ingroup cpp_core_queries 22 | */ 23 | template 24 | struct query_builder final : _::query_builder_base { 25 | query_builder(flecs::world_t* world, flecs::entity query_entity) 26 | : _::query_builder_base(world) 27 | { 28 | _::sig(world).populate(this); 29 | this->desc_.entity = query_entity.id(); 30 | } 31 | 32 | query_builder(flecs::world_t* world, const char *name = nullptr) 33 | : _::query_builder_base(world) 34 | { 35 | _::sig(world).populate(this); 36 | if (name != nullptr) { 37 | ecs_entity_desc_t entity_desc = {}; 38 | entity_desc.name = name; 39 | entity_desc.sep = "::"; 40 | entity_desc.root_sep = "::"; 41 | this->desc_.entity = ecs_entity_init(world, &entity_desc); 42 | } 43 | } 44 | 45 | template 46 | void each(Func&& func) { 47 | this->build().each(FLECS_FWD(func)); 48 | } 49 | }; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/query/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/query/decl.hpp 3 | * @brief Query declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_core_queries Queries 12 | * @ingroup cpp_core 13 | * 14 | * @{ 15 | */ 16 | 17 | struct query_base; 18 | 19 | template 20 | struct query; 21 | 22 | template 23 | struct query_builder; 24 | 25 | /** @} */ 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/query/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/query/mixin.inl 3 | * @brief Query world mixin. 4 | */ 5 | 6 | /** 7 | * @memberof flecs::world 8 | * @ingroup cpp_core_queries 9 | * 10 | * @{ 11 | */ 12 | 13 | /** Create a query. 14 | * 15 | * @see ecs_query_init 16 | */ 17 | template 18 | flecs::query query(Args &&... args) const; 19 | 20 | /** Create a query from entity. 21 | * 22 | * @see ecs_query_init 23 | */ 24 | flecs::query<> query(flecs::entity query_entity) const; 25 | 26 | /** Create a query builder. 27 | * 28 | * @see ecs_query_init 29 | */ 30 | template 31 | flecs::query_builder query_builder(Args &&... args) const; 32 | 33 | /** Iterate over all entities with components in argument list of function. 34 | * The function parameter must match the following signature: 35 | * 36 | * @code 37 | * void(*)(T&, U&, ...) 38 | * @endcode 39 | * 40 | * or: 41 | * 42 | * @code 43 | * void(*)(flecs::entity, T&, U&, ...) 44 | * @endcode 45 | * 46 | */ 47 | template 48 | void each(Func&& func) const; 49 | 50 | /** Iterate over all entities with provided component. 51 | * The function parameter must match the following signature: 52 | * 53 | * @code 54 | * void(*)(T&) 55 | * @endcode 56 | * 57 | * or: 58 | * 59 | * @code 60 | * void(*)(flecs::entity, T&) 61 | * @endcode 62 | * 63 | */ 64 | template 65 | void each(Func&& func) const; 66 | 67 | /** Iterate over all entities with provided (component) id. */ 68 | template 69 | void each(flecs::id_t term_id, Func&& func) const; 70 | 71 | /** @} */ 72 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/rest/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/rest/decl.hpp 3 | * @brief Rest module declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_addons_rest Rest 12 | * @ingroup cpp_addons 13 | * REST API for querying and mutating entities. 14 | * 15 | * @{ 16 | */ 17 | 18 | using Rest = EcsRest; 19 | 20 | namespace rest { 21 | 22 | namespace _ { 23 | 24 | void init(flecs::world& world); 25 | 26 | } 27 | } 28 | 29 | /** @} */ 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/rest/impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/rest/impl.hpp 3 | * @brief Rest module implementation. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | namespace rest { 10 | namespace _ { 11 | 12 | inline void init(flecs::world& world) { 13 | world.component("flecs::rest::Rest"); 14 | } 15 | 16 | } // namespace _ 17 | } // namespace rest 18 | } // namespace flecs 19 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/script/builder.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/script/builder.hpp 3 | * @brief Script builder. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @ingroup cpp_addons_script 12 | * @{ 13 | */ 14 | 15 | /** Script builder interface */ 16 | struct script_builder { 17 | script_builder(flecs::world_t *world, const char *name = nullptr) 18 | : world_(world) 19 | , desc_{} 20 | { 21 | if (name != nullptr) { 22 | ecs_entity_desc_t entity_desc = {}; 23 | entity_desc.name = name; 24 | entity_desc.sep = "::"; 25 | entity_desc.root_sep = "::"; 26 | this->desc_.entity = ecs_entity_init(world, &entity_desc); 27 | } 28 | } 29 | 30 | script_builder& code(const char *str) { 31 | desc_.code = str; 32 | return *this; 33 | } 34 | 35 | script_builder& filename(const char *str) { 36 | desc_.filename = str; 37 | return *this; 38 | } 39 | 40 | flecs::entity run() const; 41 | 42 | protected: 43 | flecs::world_t *world_; 44 | ecs_script_desc_t desc_; 45 | }; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/script/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/script/decl.hpp 3 | * @brief Script declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "builder.hpp" 9 | 10 | namespace flecs { 11 | 12 | /** 13 | * @defgroup cpp_addons_script Script 14 | * @ingroup cpp_addons 15 | * 16 | * @{ 17 | */ 18 | 19 | struct script_builder; 20 | 21 | /** @} */ 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/script/impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/script/impl.hpp 3 | * @brief Script implementation. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "builder.hpp" 9 | 10 | namespace flecs 11 | { 12 | 13 | inline flecs::entity script_builder::run() const { 14 | ecs_entity_t e = ecs_script_init(world_, &desc_); 15 | return flecs::entity(world_, e); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/script/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/script/mixin.inl 3 | * @brief Script world mixin. 4 | */ 5 | 6 | /** 7 | * @defgroup cpp_addons_script Script 8 | * @ingroup cpp_addons 9 | * Data definition format for loading entity data. 10 | * 11 | * @{ 12 | */ 13 | 14 | /** Run script. 15 | * @see ecs_script_run 16 | */ 17 | int script_run(const char *name, const char *str) const { 18 | return ecs_script_run(world_, name, str); 19 | } 20 | 21 | /** Run script from file. 22 | * @see ecs_script_run_file 23 | */ 24 | int script_run_file(const char *filename) const { 25 | return ecs_script_run_file(world_, filename); 26 | } 27 | 28 | /** Build script. 29 | * @see ecs_script_init 30 | */ 31 | script_builder script(const char *name = nullptr) const { 32 | return script_builder(world_, name); 33 | } 34 | 35 | /** Convert value to string */ 36 | flecs::string to_expr(flecs::entity_t tid, const void* value) { 37 | char *expr = ecs_ptr_to_expr(world_, tid, value); 38 | return flecs::string(expr); 39 | } 40 | 41 | /** Convert value to string */ 42 | template 43 | flecs::string to_expr(const T* value) { 44 | flecs::entity_t tid = _::type::id(world_); 45 | return to_expr(tid, value); 46 | } 47 | 48 | 49 | /** @} */ 50 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/stats/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/stats/decl.hpp 3 | * @brief Stats module declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_addons_stats Stats 12 | * @ingroup cpp_addons 13 | * The stats addon tracks statistics for the world and systems. 14 | * 15 | * @{ 16 | */ 17 | 18 | /** Component that stores world statistics */ 19 | using WorldStats = EcsWorldStats; 20 | 21 | /** Component that stores system/pipeline statistics */ 22 | using PipelineStats = EcsPipelineStats; 23 | 24 | /** Component with world summary stats */ 25 | using WorldSummary = EcsWorldSummary; 26 | 27 | struct stats { 28 | stats(flecs::world& world); 29 | }; 30 | 31 | /** @} */ 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/stats/impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/stats/impl.hpp 3 | * @brief Monitor module implementation. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | inline stats::stats(flecs::world& world) { 11 | #ifdef FLECS_UNITS 12 | world.import(); 13 | #endif 14 | 15 | /* Import C module */ 16 | FlecsStatsImport(world); 17 | 18 | world.component(); 19 | world.component(); 20 | world.component(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/system/builder.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/system/builder.hpp 3 | * @brief System builder. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "../../utils/node_builder.hpp" 9 | #include "builder_i.hpp" 10 | 11 | namespace flecs { 12 | namespace _ { 13 | template 14 | using system_builder_base = node_builder< 15 | system, ecs_system_desc_t, system_builder, 16 | system_builder_i, Components ...>; 17 | } 18 | 19 | /** System builder. 20 | * 21 | * @ingroup cpp_addons_systems 22 | */ 23 | template 24 | struct system_builder final : _::system_builder_base { 25 | system_builder(flecs::world_t* world, const char *name = nullptr) 26 | : _::system_builder_base(world, name) 27 | { 28 | _::sig(world).populate(this); 29 | 30 | #ifdef FLECS_PIPELINE 31 | ecs_add_id(world, this->desc_.entity, ecs_dependson(flecs::OnUpdate)); 32 | ecs_add_id(world, this->desc_.entity, flecs::OnUpdate); 33 | #endif 34 | } 35 | 36 | template 37 | system each(Func&& func); 38 | }; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/system/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/system/decl.hpp 3 | * @brief System module declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_addons_systems Systems 12 | * @ingroup cpp_addons 13 | * Systems are a query + function that can be ran manually or by a pipeline. 14 | * 15 | * @{ 16 | */ 17 | 18 | using TickSource = EcsTickSource; 19 | using SystemPriority = EcsSystemPriority; 20 | 21 | struct system; 22 | 23 | template 24 | struct system_builder; 25 | 26 | namespace _ { 27 | 28 | void system_init(flecs::world& world); 29 | 30 | /** @} */ 31 | 32 | } // namespace _ 33 | } // namespace flecs 34 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/system/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/system/mixin.inl 3 | * @brief System module world mixin. 4 | */ 5 | 6 | /** 7 | * @memberof flecs::world 8 | * @ingroup cpp_addons_systems 9 | * 10 | * @{ 11 | */ 12 | 13 | /** Upcast entity to a system. 14 | * The provided entity must be a system. 15 | * 16 | * @param e The entity. 17 | * @return A system object. 18 | */ 19 | flecs::system system(flecs::entity e) const; 20 | 21 | /** Create a new system. 22 | * 23 | * @tparam Components The components to match on. 24 | * @tparam Args Arguments passed to the constructor of flecs::system_builder. 25 | * @return System builder. 26 | */ 27 | template 28 | flecs::system_builder system(Args &&... args) const; 29 | 30 | /** @} */ 31 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/term/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/term/decl.hpp 3 | * @brief Term declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @ingroup cpp_core_queries 12 | * 13 | * @{ 14 | */ 15 | 16 | struct term; 17 | struct term_builder; 18 | 19 | /** @} */ 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/term/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/term/mixin.inl 3 | * @brief Term world mixin. 4 | */ 5 | 6 | /** 7 | * @memberof flecs::world 8 | * @ingroup cpp_core_queries 9 | * 10 | * @{ 11 | */ 12 | 13 | /** Create a term. 14 | * 15 | */ 16 | template 17 | flecs::term term(Args &&... args) const; 18 | 19 | /** Create a term for a (component) type. 20 | */ 21 | template 22 | flecs::term term() const; 23 | 24 | /** Create a term for a pair. 25 | */ 26 | template 27 | flecs::term term() const; 28 | 29 | /** @} */ 30 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/timer/decl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/timer/decl.hpp 3 | * @brief Timer module declarations. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace flecs { 9 | 10 | /** 11 | * @defgroup cpp_addons_timer Timer 12 | * @ingroup cpp_addons 13 | * Run systems at a time interval. 14 | * 15 | * @{ 16 | */ 17 | 18 | using Timer = EcsTimer; 19 | using RateFilter = EcsRateFilter; 20 | 21 | struct timer; 22 | 23 | /** @} */ 24 | 25 | namespace _ { 26 | 27 | void timer_init(flecs::world& world); 28 | 29 | } // namespace _ 30 | } // namespace flecs 31 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/timer/mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/timer/mixin.inl 3 | * @brief Timer module mixin. 4 | */ 5 | 6 | /** 7 | * @memberof flecs::world 8 | * @ingroup cpp_addons_timer 9 | */ 10 | 11 | /** Find or register a singleton timer. */ 12 | template 13 | flecs::timer timer() const; 14 | 15 | /** Find or register a timer. */ 16 | template 17 | flecs::timer timer(Args &&... args) const; 18 | 19 | /** Enable randomization of initial time values for timers. 20 | * @see ecs_randomize_timers 21 | */ 22 | void randomize_timers() const; 23 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/mixins/timer/system_mixin.inl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/mixins/timer/system_mixin.inl 3 | * @brief Timer module system mixin. 4 | */ 5 | 6 | /** 7 | * @memberof flecs::system 8 | * @ingroup cpp_addons_timer 9 | * 10 | * @{ 11 | */ 12 | 13 | /** Set interval. 14 | * @see ecs_set_interval 15 | */ 16 | void interval(ecs_ftime_t interval); 17 | 18 | /** Get interval. 19 | * @see ecs_get_interval. 20 | */ 21 | ecs_ftime_t interval(); 22 | 23 | /** Set timeout. 24 | * @see ecs_set_timeout 25 | */ 26 | void timeout(ecs_ftime_t timeout); 27 | 28 | /** Get timeout. 29 | * @see ecs_get_timeout 30 | */ 31 | ecs_ftime_t timeout(); 32 | 33 | /** Set system rate (system is its own tick source). 34 | * @see ecs_set_rate 35 | */ 36 | void rate(int32_t rate); 37 | 38 | /** Start timer. 39 | * @see ecs_start_timer 40 | */ 41 | void start(); 42 | 43 | /** Stop timer. 44 | * @see ecs_start_timer 45 | */ 46 | void stop(); 47 | 48 | /** Set external tick source. 49 | * @see ecs_set_tick_source 50 | */ 51 | template 52 | void set_tick_source(); 53 | 54 | /** Set external tick source. 55 | * @see ecs_set_tick_source 56 | */ 57 | void set_tick_source(flecs::entity e); 58 | 59 | /** @} */ 60 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/utils/builder.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/utils/builder.hpp 3 | * @brief Builder base class. 4 | * 5 | * Generic functionality for builder classes. 6 | */ 7 | 8 | #pragma once 9 | 10 | namespace flecs { 11 | namespace _ { 12 | 13 | // Macros for template types so we don't go cross-eyed 14 | #define FLECS_TBUILDER template class 15 | #define FLECS_IBUILDER template class 16 | 17 | template 18 | struct builder : IBuilder 19 | { 20 | using IBase = IBuilder; 21 | 22 | public: 23 | builder(flecs::world_t *world) 24 | : IBase(&desc_) 25 | , desc_{} 26 | , world_(world) { } 27 | 28 | builder(const builder& f) 29 | : IBase(&desc_, f.term_index_) 30 | { 31 | world_ = f.world_; 32 | desc_ = f.desc_; 33 | } 34 | 35 | builder(builder&& f) noexcept 36 | : builder(f) { } 37 | 38 | operator TDesc*() { 39 | return &desc_; 40 | } 41 | 42 | T build() { 43 | return T(world_, *static_cast(this)); 44 | } 45 | 46 | protected: 47 | flecs::world_t* world_v() override { return world_; } 48 | TDesc desc_; 49 | flecs::world_t *world_; 50 | }; 51 | 52 | #undef FLECS_TBUILDER 53 | #undef FLECS_IBUILDER 54 | 55 | } // namespace _ 56 | } // namespace flecs 57 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/cpp/utils/stringstream.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/cpp/utils/stringstream.hpp 3 | * @brief Wrapper around ecs_strbuf_t that provides a simple stringstream like API. 4 | */ 5 | 6 | namespace flecs { 7 | 8 | struct stringstream { 9 | explicit stringstream() 10 | : buf_({}) { } 11 | 12 | ~stringstream() { 13 | ecs_strbuf_reset(&buf_); 14 | } 15 | 16 | stringstream(stringstream&& str) noexcept { 17 | ecs_strbuf_reset(&buf_); 18 | buf_ = str.buf_; 19 | str.buf_ = {}; 20 | } 21 | 22 | stringstream& operator=(stringstream&& str) noexcept { 23 | ecs_strbuf_reset(&buf_); 24 | buf_ = str.buf_; 25 | str.buf_ = {}; 26 | return *this; 27 | } 28 | 29 | // Ban implicit copies/allocations 30 | stringstream& operator=(const stringstream& str) = delete; 31 | stringstream(const stringstream& str) = delete; 32 | 33 | stringstream& operator<<(const char* str) { 34 | ecs_strbuf_appendstr(&buf_, str); 35 | return *this; 36 | } 37 | 38 | flecs::string str() { 39 | return flecs::string(ecs_strbuf_get(&buf_)); 40 | } 41 | 42 | private: 43 | ecs_strbuf_t buf_; 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/deprecated.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/deprecated.h 3 | * @brief The deprecated addon contains deprecated operations. 4 | */ 5 | 6 | #ifdef FLECS_DEPRECATED 7 | 8 | #ifndef FLECS_DEPRECATED_H 9 | #define FLECS_DEPRECATED_H 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/addons/script_math.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file addons/script_math.h 3 | * @brief Math functions for flecs script. 4 | */ 5 | 6 | #ifdef FLECS_SCRIPT_MATH 7 | 8 | #ifndef FLECS_SCRIPT 9 | #define FLECS_SCRIPT 10 | #endif 11 | 12 | /** 13 | * @defgroup c_addons_script_math Script Math 14 | * @ingroup c_addons 15 | * Math functions for flecs script. 16 | * @{ 17 | */ 18 | 19 | #ifndef FLECS_SCRIPT_MATH_H 20 | #define FLECS_SCRIPT_MATH_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | FLECS_API 27 | extern ECS_COMPONENT_DECLARE(EcsScriptRng); 28 | 29 | /* Randon number generator */ 30 | typedef struct { 31 | uint64_t seed; 32 | void *impl; 33 | } EcsScriptRng; 34 | 35 | /** Script math import function. 36 | * Usage: 37 | * @code 38 | * ECS_IMPORT(world, FlecsScriptMath) 39 | * @endcode 40 | * 41 | * @param world The world. 42 | */ 43 | FLECS_API 44 | void FlecsScriptMathImport( 45 | ecs_world_t *world); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | 53 | /** @} */ 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/bake_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | ) 3 | (.) 4 | .|. 5 | | | 6 | _.--| |--._ 7 | .-'; ;`-'& ; `&. 8 | \ & ; & &_/ 9 | |"""---...---"""| 10 | \ | | | | | | | / 11 | `---.|.|.|.---' 12 | 13 | * This file is generated by bake.lang.c for your convenience. Headers of 14 | * dependencies will automatically show up in this file. Include bake_config.h 15 | * in your main project file. Do not edit! */ 16 | 17 | #ifndef FLECS_BAKE_CONFIG_H 18 | #define FLECS_BAKE_CONFIG_H 19 | 20 | /* Headers of public dependencies */ 21 | /* No dependencies */ 22 | 23 | /* Convenience macro for exporting symbols #1# */ 24 | #ifndef flecs_STATIC 25 | #if defined(flecs_EXPORTS) && (defined(_MSC_VER) || defined(__MINGW32__)) 26 | #define FLECS_API __declspec(dllexport) 27 | #elif defined(flecs_EXPORTS) 28 | #define FLECS_API __attribute__((__visibility__("default"))) 29 | #elif defined(_MSC_VER) 30 | #define FLECS_API __declspec(dllimport) 31 | #else 32 | #define FLECS_API 33 | #endif 34 | #else 35 | #define FLECS_API 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Public/flecs/datastructures/bitset.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file bitset.h 3 | * @brief Bitset data structure. 4 | */ 5 | 6 | #ifndef FLECS_BITSET_H 7 | #define FLECS_BITSET_H 8 | 9 | #include "../private/api_defines.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct ecs_bitset_t { 16 | uint64_t *data; 17 | int32_t count; 18 | ecs_size_t size; 19 | } ecs_bitset_t; 20 | 21 | /** Initialize bitset. */ 22 | FLECS_DBG_API 23 | void flecs_bitset_init( 24 | ecs_bitset_t *bs); 25 | 26 | /** Deinitialize bitset. */ 27 | FLECS_DBG_API 28 | void flecs_bitset_fini( 29 | ecs_bitset_t *bs); 30 | 31 | /** Add n elements to bitset. */ 32 | FLECS_DBG_API 33 | void flecs_bitset_addn( 34 | ecs_bitset_t *bs, 35 | int32_t count); 36 | 37 | /** Ensure element exists. */ 38 | FLECS_DBG_API 39 | void flecs_bitset_ensure( 40 | ecs_bitset_t *bs, 41 | int32_t count); 42 | 43 | /** Set element. */ 44 | FLECS_DBG_API 45 | void flecs_bitset_set( 46 | ecs_bitset_t *bs, 47 | int32_t elem, 48 | bool value); 49 | 50 | /** Get element. */ 51 | FLECS_DBG_API 52 | bool flecs_bitset_get( 53 | const ecs_bitset_t *bs, 54 | int32_t elem); 55 | 56 | /** Return number of elements. */ 57 | FLECS_DBG_API 58 | int32_t flecs_bitset_count( 59 | const ecs_bitset_t *bs); 60 | 61 | /** Remove from bitset. */ 62 | FLECS_DBG_API 63 | void flecs_bitset_remove( 64 | ecs_bitset_t *bs, 65 | int32_t elem); 66 | 67 | /** Swap values in bitset. */ 68 | FLECS_DBG_API 69 | void flecs_bitset_swap( 70 | ecs_bitset_t *bs, 71 | int32_t elem_a, 72 | int32_t elem_b); 73 | 74 | FLECS_DBG_API 75 | void flecs_bitset_set_range( 76 | ecs_bitset_t *bs, 77 | int32_t start, 78 | int32_t stop, 79 | bool value); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Source/FlecsLibrary/Tests/Bake/FlecsTestTypes.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reddy-dev/Unreal-Flecs/9c4c14a11d2a664558aab09fe57969156d41e359/Source/FlecsLibrary/Tests/Bake/FlecsTestTypes.cpp -------------------------------------------------------------------------------- /Source/UnrealFlecs/Collections/FlecsComponentCollectionObject.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsComponentCollectionObject.h" 4 | #include "Worlds/FlecsWorld.h" 5 | #include "Worlds/FlecsWorldSubsystem.h" 6 | 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsComponentCollectionObject) 8 | 9 | UFlecsComponentCollectionObject::UFlecsComponentCollectionObject() 10 | { 11 | } 12 | 13 | UFlecsComponentCollectionObject::UFlecsComponentCollectionObject(const FObjectInitializer& ObjectInitializer) 14 | : Super(ObjectInitializer) 15 | { 16 | } 17 | 18 | void UFlecsComponentCollectionObject::ApplyCollection_Internal(FFlecsEntityHandle Entity, UFlecsWorld* InFlecsWorld) 19 | { 20 | FlecsWorld = InFlecsWorld; 21 | 22 | ApplyCollectionToEntity(Entity); 23 | } 24 | 25 | UFlecsWorld* UFlecsComponentCollectionObject::GetFlecsWorld() const 26 | { 27 | return FlecsWorld.Get(); 28 | } 29 | 30 | void UFlecsComponentCollectionObject::ApplyCollectionToEntity_Implementation(FFlecsEntityHandle& Entity) 31 | { 32 | } 33 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Collections/FlecsComponentCollectionObject.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Entities/FlecsEntityHandle.h" 7 | #include "FlecsComponentCollectionObject.generated.h" 8 | 9 | class UFlecsWorld; 10 | 11 | UCLASS(Abstract, BlueprintType, Blueprintable, EditInlineNew) 12 | class UNREALFLECS_API UFlecsComponentCollectionObject : public UObject 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | UFlecsComponentCollectionObject(); 18 | UFlecsComponentCollectionObject(const FObjectInitializer& ObjectInitializer); 19 | 20 | /* Applies to the Prefab Entity */ 21 | UFUNCTION(BlueprintNativeEvent, Category = "Flecs Component Collection") 22 | void ApplyCollectionToEntity(FFlecsEntityHandle& Entity); 23 | 24 | void ApplyCollection_Internal(FFlecsEntityHandle Entity, UFlecsWorld* InFlecsWorld); 25 | 26 | UFUNCTION(BlueprintCallable, Category = "Flecs Component Collection") 27 | UFlecsWorld* GetFlecsWorld() const; 28 | 29 | protected: 30 | 31 | UPROPERTY() 32 | TWeakObjectPtr FlecsWorld; 33 | 34 | }; // class UFlecsComponentCollectionObject 35 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Components/ComponentDefaultEntities.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Components/FlecsModuleComponent.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "SolidMacros/Macros.h" 7 | #include "FlecsModuleComponent.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct UNREALFLECS_API FFlecsModuleComponent 11 | { 12 | GENERATED_BODY() 13 | 14 | FORCEINLINE FFlecsModuleComponent() = default; 15 | 16 | FORCEINLINE FFlecsModuleComponent(const TSubclassOf InModuleClass) 17 | : ModuleClass(InModuleClass) 18 | { 19 | } 20 | 21 | NO_DISCARD FORCEINLINE TSubclassOf GetModuleClass() const 22 | { 23 | return ModuleClass; 24 | } 25 | 26 | FORCEINLINE FFlecsModuleComponent& operator=(UClass* InModuleClass) 27 | { 28 | ModuleClass = InModuleClass; 29 | return *this; 30 | } 31 | 32 | FORCEINLINE FFlecsModuleComponent& operator=(const FFlecsModuleComponent& InComponent) 33 | { 34 | ModuleClass = InComponent.ModuleClass; 35 | return *this; 36 | } 37 | 38 | FORCEINLINE bool operator==(const FFlecsModuleComponent& InComponent) const 39 | { 40 | return ModuleClass == InComponent.ModuleClass; 41 | } 42 | 43 | FORCEINLINE bool operator!=(const FFlecsModuleComponent& InComponent) const 44 | { 45 | return !(*this == InComponent); 46 | } 47 | 48 | UPROPERTY() 49 | TSubclassOf ModuleClass; 50 | 51 | }; // struct FFlecsModuleComponent -------------------------------------------------------------------------------- /Source/UnrealFlecs/Components/FlecsPrimaryAssetComponent.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "SolidMacros/Macros.h" 7 | #include "Properties/FlecsComponentProperties.h" 8 | #include "FlecsPrimaryAssetComponent.generated.h" 9 | 10 | USTRUCT() 11 | struct UNREALFLECS_API FFlecsPrimaryAssetComponent 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | FORCEINLINE FFlecsPrimaryAssetComponent() = default; 17 | FORCEINLINE FFlecsPrimaryAssetComponent(const FSoftObjectPath& InObjectPath) 18 | : ObjectPath(InObjectPath) 19 | { 20 | } 21 | 22 | UPROPERTY() 23 | FSoftObjectPath ObjectPath; 24 | 25 | }; // struct FFlecsPrimaryAssetComponent 26 | 27 | REGISTER_FLECS_COMPONENT(FFlecsPrimaryAssetComponent, 28 | [](flecs::world InWorld, const FFlecsComponentHandle& InComponent) 29 | { 30 | InComponent.AddPair(flecs::OnInstantiate, flecs::DontInherit); 31 | }); 32 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Components/ObjectTypes/FFlecsActorComponentTag.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FFlecsUObjectTag.h" 7 | #include "Entities/FlecsComponentHandle.h" 8 | #include "Properties/FlecsComponentProperties.h" 9 | #include "FFlecsActorComponentTag.generated.h" 10 | 11 | USTRUCT(BlueprintType) 12 | struct UNREALFLECS_API FFlecsActorComponentTag : public FFlecsUObjectTag 13 | { 14 | GENERATED_BODY() 15 | }; // struct FFlecsActorComponentTag 16 | 17 | REGISTER_FLECS_COMPONENT(FFlecsActorComponentTag, 18 | [](flecs::world InWorld, const FFlecsComponentHandle& InComponent) 19 | { 20 | InComponent.Add(flecs::Target); 21 | }); 22 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Components/ObjectTypes/FFlecsModuleComponentTag.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Properties/FlecsComponentProperties.h" 7 | #include "FFlecsModuleComponentTag.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct UNREALFLECS_API FFlecsModuleComponentTag : public FFlecsUObjectTag 11 | { 12 | GENERATED_BODY() 13 | }; // struct FFlecsModuleComponentTag 14 | 15 | REGISTER_FLECS_COMPONENT(FFlecsModuleComponentTag, 16 | [](flecs::world InWorld, FFlecsComponentHandle& InComponent) 17 | { 18 | InComponent.Add(flecs::Target); 19 | }); 20 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Components/ObjectTypes/FFlecsSceneComponentTag.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Properties/FlecsComponentProperties.h" 7 | #include "FFlecsSceneComponentTag.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct UNREALFLECS_API FFlecsSceneComponentTag : public FFlecsActorComponentTag 11 | { 12 | GENERATED_BODY() 13 | }; // struct FFlecsSceneComponentTag 14 | 15 | REGISTER_FLECS_COMPONENT(FFlecsSceneComponentTag, 16 | [](flecs::world InWorld, FFlecsComponentHandle& InComponent) 17 | { 18 | InComponent.Add(flecs::Target); 19 | }); -------------------------------------------------------------------------------- /Source/UnrealFlecs/Components/ObjectTypes/FFlecsUObjectTag.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Properties/FlecsComponentProperties.h" 7 | #include "FFlecsUObjectTag.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct UNREALFLECS_API FFlecsUObjectTag 11 | { 12 | GENERATED_BODY() 13 | }; // struct FFlecsUObjectTag 14 | 15 | REGISTER_FLECS_COMPONENT(FFlecsUObjectTag, 16 | [](flecs::world InWorld, FFlecsComponentHandle& InComponent) 17 | { 18 | InComponent.Add(flecs::Target); 19 | }); 20 | 21 | 22 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Components/ObjectTypes/FlecsActorTag.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FFlecsUObjectTag.h" 7 | #include "Properties/FlecsComponentProperties.h" 8 | #include "FlecsActorTag.generated.h" 9 | 10 | USTRUCT(BlueprintType) 11 | struct UNREALFLECS_API FFlecsActorTag : public FFlecsUObjectTag 12 | { 13 | GENERATED_BODY() 14 | }; // struct FFlecsActorTag 15 | 16 | REGISTER_FLECS_COMPONENT(FFlecsActorTag, 17 | [](flecs::world World, const FFlecsComponentHandle& InComponent) 18 | { 19 | InComponent.Add(flecs::Target); 20 | }); -------------------------------------------------------------------------------- /Source/UnrealFlecs/Entities/FFlecsMemberHandle.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FFlecsMemberHandle.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FFlecsMemberHandle) 6 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Entities/FFlecsMemberHandle.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "FFlecsMemberHandle.generated.h" 9 | 10 | USTRUCT(BlueprintType) 11 | struct UNREALFLECS_API FFlecsMemberHandle 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | FORCEINLINE FFlecsMemberHandle() = default; 17 | 18 | FORCEINLINE FFlecsMemberHandle(const flecs::member_t* InMember) 19 | : Member(InMember) 20 | { 21 | } 22 | 23 | NO_DISCARD FORCEINLINE bool IsValid() const 24 | { 25 | return Member != nullptr; 26 | } 27 | 28 | FORCEINLINE operator bool() const 29 | { 30 | return IsValid(); 31 | } 32 | 33 | FORCEINLINE void SetMember(const flecs::member_t* InMember) 34 | { 35 | Member = InMember; 36 | } 37 | 38 | NO_DISCARD FORCEINLINE const flecs::member_t* GetFlecsMember() const 39 | { 40 | return Member; 41 | } 42 | 43 | FORCEINLINE operator const flecs::member_t*() const 44 | { 45 | return Member; 46 | } 47 | 48 | FORCEINLINE bool operator==(const FFlecsMemberHandle& Other) const 49 | { 50 | return Member == Other.Member; 51 | } 52 | 53 | FORCEINLINE bool operator!=(const FFlecsMemberHandle& Other) const 54 | { 55 | return !(*this == Other); 56 | } 57 | 58 | private: 59 | const flecs::member_t* Member = nullptr; 60 | }; // struct FFlecsMemberHandle -------------------------------------------------------------------------------- /Source/UnrealFlecs/Entities/FlecsComponentHandle.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsComponentHandle.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsComponentHandle) 6 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/GameFramework/FlecsGameFrameworkModule.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsGameFrameworkModule.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsGameFrameworkModule) 6 | 7 | void UFlecsGameFrameworkModule::InitializeModule( 8 | TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) 9 | { 10 | 11 | } 12 | 13 | void UFlecsGameFrameworkModule::DeinitializeModule(TSolidNotNull InWorld) 14 | { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/GameFramework/FlecsGameFrameworkModule.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/FlecsModuleObject.h" 7 | #include "FlecsGameFrameworkModule.generated.h" 8 | 9 | UCLASS(BlueprintType, DisplayName = "Flecs Game Framework Module") 10 | class UNREALFLECS_API UFlecsGameFrameworkModule final : public UFlecsModuleObject 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | virtual void InitializeModule(TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) override; 16 | virtual void DeinitializeModule(TSolidNotNull InWorld) override; 17 | 18 | FORCEINLINE virtual FString GetModuleName_Implementation() const override 19 | { 20 | return "Flecs Game Framework Module"; 21 | } 22 | 23 | 24 | }; // class UFlecsGameFrameworkModule 25 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/GameFramework/UObject/UnrealFlecsObject.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Interfaces/FlecsEntityInterface.h" 7 | #include "UObject/Object.h" 8 | #include "UnrealFlecsObject.generated.h" 9 | 10 | class UFlecsWorld; 11 | 12 | UCLASS(Abstract, BlueprintType) 13 | class UNREALFLECS_API UUnrealFlecsObject : public UObject, public IFlecsEntityInterface 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | UUnrealFlecsObject(); 19 | UUnrealFlecsObject(const FObjectInitializer& ObjectInitializer); 20 | 21 | void InitializeFlecsObject(TSolidNotNull InFlecsWorld); 22 | 23 | // Inheriting class can override this if they want to customize their Entity creation 24 | virtual FFlecsEntityHandle CreateObjectEntity(); 25 | 26 | virtual void BeginPlay(); 27 | 28 | UFUNCTION(BlueprintImplementableEvent, Category = "Flecs", meta = (DisplayName = "Begin Play")) 29 | void BP_BeginPlay(); 30 | 31 | FORCEINLINE virtual FFlecsEntityHandle GetEntityHandle() const override 32 | { 33 | return ObjectEntityHandle; 34 | } 35 | 36 | UFUNCTION(BlueprintCallable, Category = "Flecs") 37 | UFlecsWorld* GetFlecsWorld() const; 38 | 39 | virtual UWorld* GetWorld() const override; 40 | virtual void GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const override; 41 | 42 | protected: 43 | UPROPERTY(Replicated) 44 | FFlecsEntityHandle ObjectEntityHandle; 45 | 46 | UPROPERTY() 47 | TWeakObjectPtr FlecsWorld; 48 | 49 | }; // class UUnrealFlecsObject 50 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/General/FlecsDeveloperSettings.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsDeveloperSettings.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsDeveloperSettings) 6 | 7 | static bool bEnableFlecs = true; 8 | static FAutoConsoleVariableRef CVarEnableFlecs( 9 | TEXT("Flecs.UseFlecs"), 10 | bEnableFlecs, 11 | TEXT("Enable Unreal Flecs Plugin.") 12 | ); 13 | 14 | static bool bUseTaskThreads = true; 15 | static FAutoConsoleVariableRef CVarUseTaskThreads( 16 | TEXT("Flecs.UseTaskThreads"), 17 | bUseTaskThreads, 18 | TEXT("Enable task threads for Flecs.") 19 | ); 20 | 21 | static int32 TaskThreadCount = 4; 22 | static FAutoConsoleVariableRef CVarTaskThreadCount( 23 | TEXT("Flecs.TaskThreadCount"), 24 | TaskThreadCount, 25 | TEXT("Number of threads to use for Flecs task processing.") 26 | ); 27 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/General/FlecsDeveloperSettings.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Engine/DeveloperSettings.h" 7 | #include "FlecsDeveloperSettings.generated.h" 8 | 9 | UCLASS(BlueprintType, Config = Game, DefaultConfig, Category = "Flecs", meta = (DisplayName = "Flecs World Settings")) 10 | class UNREALFLECS_API UFlecsDeveloperSettings final : public UDeveloperSettings 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | UPROPERTY(EditAnywhere, Config, Category = "Flecs", meta = (ConsoleVariable = "Flecs.UseFlecs")) 16 | bool bEnableFlecs = true; 17 | 18 | UPROPERTY(EditAnywhere, Config, Category = "Flecs", meta = (ConsoleVariable = "Flecs.UseTaskThreads")) 19 | bool bUseTaskThreads = true; 20 | 21 | UPROPERTY(EditAnywhere, Config, Category = "Flecs", 22 | meta = (EditCondition = "bUseTaskThreads", ConsoleVariable = "Flecs.TaskThreadCount")) 23 | int32 TaskThreadCount = 4; 24 | 25 | }; // class UFlecsDeveloperSettings 26 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/General/FlecsPrimaryDataAsset.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsPrimaryDataAsset.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsPrimaryDataAsset) 6 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/General/FlecsPrimaryDataAsset.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Engine/DataAsset.h" 7 | #include "Entities/FlecsEntityHandle.h" 8 | #include "FlecsPrimaryDataAsset.generated.h" 9 | 10 | UCLASS(Abstract, BlueprintType) 11 | class UNREALFLECS_API UFlecsPrimaryDataAsset : public UPrimaryDataAsset 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | 17 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Flecs") 18 | bool bEnabledOnStartup = true; 19 | 20 | FORCEINLINE virtual FPrimaryAssetId GetPrimaryAssetId() const override final 21 | { 22 | return FPrimaryAssetId("FlecsPrimaryDataAsset", GetFName()); 23 | } 24 | 25 | virtual void OnEntityCreated(const FFlecsEntityHandle& InEntityHandle, UFlecsWorld* World) 26 | PURE_VIRTUAL(UFlecsPrimaryDataAsset::OnEntityCreated, ); 27 | virtual void OnEntityDestroyed(const FFlecsEntityHandle& InEntityHandle, UFlecsWorld* World) 28 | PURE_VIRTUAL(UFlecsPrimaryDataAsset::OnEntityDestroyed, ); 29 | 30 | NO_DISCARD FORCEINLINE bool ShouldSpawn() const 31 | { 32 | return bEnabledOnStartup && !GetClass()->HasAnyClassFlags(CLASS_Abstract); 33 | } 34 | 35 | }; // class UFlecsPrimaryDataAsset 36 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/General/FlecsStringConverters.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | namespace Unreal::Flecs 8 | { 9 | template 10 | NO_DISCARD FORCEINLINE const char* ToCString(const TCHAR* InString) 11 | { 12 | return StringCast(InString).Get(); 13 | } 14 | 15 | template 16 | NO_DISCARD FORCEINLINE const char* ToCString(const FString& InString) 17 | { 18 | return ToCString(*InString); 19 | } 20 | 21 | } // namespace Unreal::Flecs 22 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Interfaces/FlecsEntityInterface.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsEntityInterface.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsEntityInterface) 6 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Interfaces/FlecsEntityInterface.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Entities/FlecsEntityHandle.h" 7 | #include "UObject/Interface.h" 8 | #include "FlecsEntityInterface.generated.h" 9 | 10 | UINTERFACE(BlueprintType) 11 | class UNREALFLECS_API UFlecsEntityInterface : public UInterface 12 | { 13 | GENERATED_BODY() 14 | }; // class UFlecsEntityInterface 15 | 16 | class UNREALFLECS_API IFlecsEntityInterface 17 | { 18 | GENERATED_BODY() 19 | 20 | public: 21 | 22 | NO_DISCARD virtual FFlecsEntityHandle GetEntityHandle() const 23 | PURE_VIRTUAL(IFlecsEntityInterface::GetEntityHandle, return FFlecsEntityHandle();); 24 | 25 | }; // class IFlecsEntityInterface 26 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Libraries/DefaultEntitiesLibrary.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Entities/FlecsEntityHandle.h" 7 | #include "Kismet/BlueprintFunctionLibrary.h" 8 | #include "DefaultEntitiesLibrary.generated.h" 9 | 10 | UCLASS() 11 | class UNREALFLECS_API UDefaultEntitiesLibrary final : public UBlueprintFunctionLibrary 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | 17 | UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Flecs | Default Entities") 18 | static FORCEINLINE FFlecsEntityHandle GetNullEntity() 19 | { 20 | return FFlecsEntityHandle::GetNullHandle(); 21 | } 22 | 23 | }; // class UDefaultEntitiesLibrary 24 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Libraries/EntityFunctionLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "EntityFunctionLibrary.h" 4 | #include "Worlds/FlecsWorldSubsystem.h" 5 | 6 | #include UE_INLINE_GENERATED_CPP_BY_NAME(EntityFunctionLibrary) -------------------------------------------------------------------------------- /Source/UnrealFlecs/Logs/FlecsCategories.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Unlog/Unlog.h" 7 | 8 | UNLOG_CATEGORY(LogFlecsCore); 9 | UNLOG_CATEGORY(LogFlecsJournal); 10 | UNLOG_CATEGORY(LogFlecsWorld); 11 | UNLOG_CATEGORY(LogFlecsSystem); 12 | UNLOG_CATEGORY(LogFlecsComponent); 13 | UNLOG_CATEGORY(LogFlecsEntity); 14 | UNLOG_CATEGORY(LogFlecsNetworking); -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsAddons/FlecsRestModule.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | // ReSharper disable CppExpressionWithoutSideEffects 4 | #include "FlecsRestModule.h" 5 | #include "Worlds/FlecsWorld.h" 6 | 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsRestModule) 8 | 9 | void UFlecsRestModule::InitializeModule(TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) 10 | { 11 | #ifdef FLECS_REST 12 | 13 | uint16 ClientPieInstanceOffset = 0; 14 | 15 | const TSolidNotNull UnrealWorld = InWorld->GetWorld(); 16 | 17 | #if WITH_EDITOR 18 | 19 | if (UnrealWorld->GetNetMode() == NM_Client) 20 | { 21 | ClientPieInstanceOffset = static_cast(UE::GetPlayInEditorID()); 22 | } 23 | 24 | #endif // WITH_EDITOR 25 | 26 | const uint16 RestPort = ECS_REST_DEFAULT_PORT + ClientPieInstanceOffset; 27 | 28 | InWorld->SetSingleton(flecs::Rest{ .port = RestPort }); 29 | RestEntity = InWorld->ObtainSingletonEntity(); 30 | 31 | #ifdef FLECS_STATS 32 | 33 | if (bImportStats) 34 | { 35 | StatsEntity = InWorld->ImportFlecsModule(); 36 | } 37 | 38 | #endif // FLECS_STATS 39 | 40 | #endif // FLECS_REST 41 | } 42 | 43 | void UFlecsRestModule::DeinitializeModule(TSolidNotNull InWorld) 44 | { 45 | #ifdef FLECS_REST 46 | 47 | #ifdef FLECS_STATS 48 | 49 | if (StatsEntity.IsValid()) 50 | { 51 | StatsEntity.Disable(); 52 | } 53 | 54 | #endif // FLECS_STATS 55 | 56 | if UNLIKELY_IF(!RestEntity.IsValid()) 57 | { 58 | return; 59 | } 60 | 61 | RestEntity.Disable(); 62 | 63 | #endif // FLECS_REST 64 | } 65 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsAddons/FlecsRestModule.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/FlecsModuleInterface.h" 7 | #include "Modules/FlecsModuleObject.h" 8 | #include "UObject/Object.h" 9 | #include "FlecsRestModule.generated.h" 10 | 11 | UCLASS(BlueprintType, DisplayName = "Flecs Rest Module") 12 | class UNREALFLECS_API UFlecsRestModule final : public UFlecsModuleObject 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | virtual void InitializeModule(TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) override; 18 | virtual void DeinitializeModule(TSolidNotNull InWorld) override; 19 | 20 | FORCEINLINE virtual FString GetModuleName_Implementation() const override 21 | { 22 | return "Flecs Rest Module"; 23 | } 24 | 25 | UPROPERTY() 26 | FFlecsEntityHandle RestEntity; 27 | 28 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rest") 29 | bool bImportStats = true; 30 | 31 | UPROPERTY() 32 | FFlecsEntityHandle StatsEntity; 33 | 34 | }; // class UFlecsRestModule 35 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsDependenciesComponent.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "flecs.h" 8 | 9 | #include "CoreMinimal.h" 10 | #include "Properties/FlecsComponentProperties.h" 11 | #include "Entities/FlecsEntityHandle.h" 12 | #include "FlecsDependenciesComponent.generated.h" 13 | 14 | class UFlecsWorld; 15 | 16 | USTRUCT(BlueprintType) 17 | struct alignas(64) UNREALFLECS_API FFlecsDependenciesComponent 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | robin_hood::unordered_flat_map, 23 | TSolidNotNull, 24 | FFlecsEntityHandle)>> Dependencies; 25 | }; // struct FFlecsDependenciesComponent 26 | 27 | REGISTER_FLECS_COMPONENT(FFlecsDependenciesComponent, 28 | [](flecs::world InWorld, const FFlecsComponentHandle& InComponent) 29 | { 30 | InComponent.Add(flecs::Sparse); 31 | }); 32 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsModuleInitEvent.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsModuleInitEvent.generated.h" 7 | 8 | USTRUCT(BlueprintType) 9 | struct UNREALFLECS_API FFlecsModuleInitEvent 10 | { 11 | GENERATED_BODY() 12 | }; // struct FFlecsModuleInitEvent 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsModuleObject.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsModuleObject.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsModuleObject) 6 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsModuleObject.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsModuleInterface.h" 7 | #include "UObject/Object.h" 8 | #include "FlecsModuleObject.generated.h" 9 | 10 | UCLASS(Abstract, Blueprintable, BlueprintType, EditInlineNew, DefaultToInstanced, ClassGroup = (Flecs)) 11 | class UNREALFLECS_API UFlecsModuleObject : public UObject, public IFlecsModuleInterface 12 | { 13 | GENERATED_BODY() 14 | }; // class UFlecsModuleObject 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsModuleProgressInterface.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/Interface.h" 7 | #include "FlecsModuleProgressInterface.generated.h" 8 | 9 | // This class does not need to be modified. 10 | UINTERFACE(meta = (CannotImplementInterfaceInBlueprint)) 11 | class UNREALFLECS_API UFlecsModuleProgressInterface : public UInterface 12 | { 13 | GENERATED_BODY() 14 | }; // class UFlecsModuleProgressInterface 15 | 16 | /** 17 | * Use this interface to implement a module that needs to be updated every frame. 18 | * This is called before Progress is called on the flecs world. 19 | */ 20 | class UNREALFLECS_API IFlecsModuleProgressInterface 21 | { 22 | GENERATED_BODY() 23 | public: 24 | virtual void ProgressModule(double InDeltaTime) PURE_VIRTUAL(IFlecsModuleProgressInterface::ProgressModule, ); 25 | 26 | }; // class IFlecsModuleProgressInterface 27 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsModuleSetDataAsset.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsModuleSetDataAsset.h" 4 | #include "FlecsModuleInterface.h" 5 | #include "SolidMacros/Macros.h" 6 | #include "Worlds/FlecsWorld.h" 7 | 8 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsModuleSetDataAsset) 9 | 10 | void UFlecsModuleSetDataAsset::ImportModules(const TSolidNotNull InWorld) 11 | { 12 | for (UObject* Module : Modules) 13 | { 14 | if UNLIKELY_IF(!ensureAlways(IsValid(Module))) 15 | { 16 | continue; 17 | } 18 | 19 | solid_check(Module->GetClass()->ImplementsInterface(UFlecsModuleInterface::StaticClass())); 20 | 21 | InWorld->ImportModule(Module); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Modules/FlecsModuleSetDataAsset.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Engine/DataAsset.h" 7 | #include "Types/SolidNotNull.h" 8 | #include "FlecsModuleSetDataAsset.generated.h" 9 | 10 | class UFlecsWorld; 11 | 12 | UCLASS(BlueprintType) 13 | class UNREALFLECS_API UFlecsModuleSetDataAsset : public UDataAsset 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | UPROPERTY(EditAnywhere, Instanced, Category = "Flecs", 19 | meta = (MustImplement = "/Script/UnrealFlecs.FlecsModuleInterface")) 20 | TArray> Modules; 21 | 22 | void ImportModules(const TSolidNotNull InWorld); 23 | 24 | }; // class UFlecsModuleSetDataAsset 25 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Networking/FlecsNetworkMessage.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsNetworkMessage.generated.h" 7 | 8 | USTRUCT(BlueprintType) 9 | struct UNREALFLECS_API FFlecsNetworkMessage 10 | { 11 | GENERATED_BODY() 12 | }; // struct FFlecsNetworkMessage 13 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Networking/FlecsNetworkTrait.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsNetworkTrait.generated.h" 7 | 8 | USTRUCT(BlueprintType) 9 | struct UNREALFLECS_API FFlecsNetworkTrait 10 | { 11 | GENERATED_BODY() 12 | }; // struct FFlecsNetworkTrait 13 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Networking/FlecsNetworkingModule.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsNetworkingModule.h" 4 | #include "Worlds/FlecsWorld.h" 5 | 6 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsNetworkingModule) 7 | 8 | void UFlecsNetworkingModule::InitializeModule( 9 | TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) 10 | { 11 | } 12 | 13 | void UFlecsNetworkingModule::DeinitializeModule(TSolidNotNull InWorld) 14 | { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Networking/FlecsNetworkingModule.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/FlecsModuleObject.h" 7 | #include "FlecsNetworkingModule.generated.h" 8 | 9 | UCLASS(BlueprintType, EditInlineNew, DefaultToInstanced, meta = (DisplayName = "Flecs Networking Module")) 10 | class UNREALFLECS_API UFlecsNetworkingModule final : public UFlecsModuleObject 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | virtual void InitializeModule(TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) override; 17 | virtual void DeinitializeModule(TSolidNotNull InWorld) override; 18 | 19 | }; // class UFlecsNetworkingModule 20 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Networking/FlecsResimulatingComponent.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsResimulatingComponent.generated.h" 7 | 8 | USTRUCT(BlueprintType) 9 | struct UNREALFLECS_API FFlecsResimulatingComponent 10 | { 11 | GENERATED_BODY() 12 | }; // struct FFlecsResimulatingComponent 13 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Physics/FlecsPhysicsModule.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "TickerPhysicsHistoryComponent.h" 7 | #include "Modules/FlecsModuleObject.h" 8 | #include "Systems/FlecsSystem.h" 9 | #include "Ticker/FlecsTickerComponent.h" 10 | #include "UObject/Object.h" 11 | #include "FlecsPhysicsModule.generated.h" 12 | 13 | // @TODO: Not Fully Implemented 14 | UCLASS(BlueprintType, DefaultToInstanced, EditInlineNew, DisplayName = "Flecs Physics Module") 15 | class UNREALFLECS_API UFlecsPhysicsModule final : public UFlecsModuleObject 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | virtual void InitializeModule(TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) override; 21 | virtual void DeinitializeModule(TSolidNotNull InWorld) override; 22 | 23 | virtual void WorldBeginPlay(TSolidNotNull InWorld, TSolidNotNull InGameWorld) override; 24 | 25 | void ResimulationHandlers(); 26 | 27 | FORCEINLINE virtual FString GetModuleName_Implementation() const override 28 | { 29 | return "Flecs Physics Module"; 30 | } 31 | 32 | //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physics") 33 | bool bAllowResimulation = false; 34 | 35 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physics", meta = (EditCondition = "bAllowResimulation")) 36 | int32 MaxFrameHistory = 300; 37 | 38 | flecs::observer AddPhysicsComponentObserver; 39 | 40 | private: 41 | int32 PreResimValue = 0; 42 | 43 | FTickerPhysicsHistoryComponent* PhysicsHistoryComponentRef; 44 | FFlecsTickerComponent* TickerComponentRef; 45 | 46 | FPhysScene* Scene = nullptr; 47 | 48 | }; // class UFlecsPhysicsModule 49 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Physics/FlecsPhysicsSceneComponent.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Properties/FlecsComponentProperties.h" 7 | #include "FlecsPhysicsSceneComponent.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct UNREALFLECS_API FFlecsPhysicsSceneComponent 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | FPhysScene* PhysicsScene = nullptr; 16 | 17 | FORCEINLINE operator FPhysScene*() const { return PhysicsScene; } 18 | FORCEINLINE FPhysScene* operator->() const { return PhysicsScene; } 19 | FORCEINLINE FPhysScene& operator*() const { return *PhysicsScene; } 20 | 21 | FORCEINLINE bool operator==(const FFlecsPhysicsSceneComponent& InComponent) const 22 | { 23 | return PhysicsScene == InComponent.PhysicsScene; 24 | } 25 | 26 | FORCEINLINE bool operator!=(const FFlecsPhysicsSceneComponent& InComponent) const 27 | { 28 | return !(*this == InComponent); 29 | } 30 | 31 | }; // struct FFlecsPhysicsSceneComponent 32 | 33 | REGISTER_FLECS_COMPONENT(FFlecsPhysicsSceneComponent, 34 | [](flecs::world World, const FFlecsComponentHandle& Component) 35 | { 36 | Component.Add(flecs::Sparse); 37 | }); -------------------------------------------------------------------------------- /Source/UnrealFlecs/Physics/FlecsPhysicsSettingsTrait.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsPhysicsSettingsTrait.generated.h" -------------------------------------------------------------------------------- /Source/UnrealFlecs/Physics/TickerPhysicsHistoryComponent.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "Properties/FlecsComponentProperties.h" 9 | #include "TickerPhysicsHistoryComponent.generated.h" 10 | 11 | USTRUCT() 12 | struct UNREALFLECS_API FTickerPhysicsHistoryItem final 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | UPROPERTY() 18 | int32 TickId = 0; 19 | 20 | UPROPERTY() 21 | int32 PhysicsFrame = 0; 22 | }; // struct FTickerPhysicsHistoryItem 23 | 24 | REGISTER_FLECS_COMPONENT(FTickerPhysicsHistoryItem, 25 | [](flecs::world World, const FFlecsComponentHandle& Component) 26 | { 27 | }); 28 | 29 | USTRUCT(BlueprintType) 30 | struct UNREALFLECS_API FTickerPhysicsHistoryComponent final 31 | { 32 | GENERATED_BODY() 33 | 34 | public: 35 | UPROPERTY() 36 | TArray HistoryItems; 37 | }; // struct FTickerPhysicsHistoryComponent 38 | 39 | REGISTER_FLECS_COMPONENT(FTickerPhysicsHistoryComponent, 40 | [](flecs::world World, const FFlecsComponentHandle& Component) 41 | { 42 | Component.Add(flecs::Sparse); 43 | }); 44 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Pipelines/FlecsDefaultGameLoop.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsDefaultGameLoop.h" 4 | #include "Worlds/FlecsWorld.h" 5 | 6 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsDefaultGameLoop) 7 | 8 | void UFlecsDefaultGameLoop::InitializeGameLoop(TSolidNotNull InWorld) 9 | { 10 | } 11 | 12 | bool UFlecsDefaultGameLoop::Progress(const double DeltaTime, const TSolidNotNull InWorld) 13 | { 14 | return InWorld->Progress(DeltaTime); 15 | } 16 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Pipelines/FlecsDefaultGameLoop.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsGameLoopObject.h" 7 | #include "FlecsDefaultGameLoop.generated.h" 8 | 9 | UCLASS(BlueprintType) 10 | class UNREALFLECS_API UFlecsDefaultGameLoop final : public UFlecsGameLoopObject 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | virtual void InitializeGameLoop(TSolidNotNull InWorld) override; 16 | virtual bool Progress(double DeltaTime, TSolidNotNull InWorld) override; 17 | 18 | }; // class UFlecsDefaultGameLoop -------------------------------------------------------------------------------- /Source/UnrealFlecs/Pipelines/FlecsGameLoopInterface.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsGameLoopInterface.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsGameLoopInterface) 6 | 7 | // Add default functionality here for any IFlecsGameLoopInterface functions that are not pure virtual. 8 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Pipelines/FlecsGameLoopInterface.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Types/SolidNotNull.h" 7 | #include "UObject/Interface.h" 8 | #include "FlecsGameLoopInterface.generated.h" 9 | 10 | class UFlecsWorld; 11 | // This class does not need to be modified. 12 | UINTERFACE(meta=(CannotImplementInterfaceInBlueprint)) 13 | class UNREALFLECS_API UFlecsGameLoopInterface : public UInterface 14 | { 15 | GENERATED_BODY() 16 | }; // class UFlecsGameLoopInterface 17 | 18 | class UNREALFLECS_API IFlecsGameLoopInterface 19 | { 20 | GENERATED_BODY() 21 | 22 | // Add interface functions to this class. This is the class that will be inherited to implement this interface. 23 | public: 24 | virtual void InitializeGameLoop(TSolidNotNull InWorld) {} 25 | 26 | virtual bool Progress(double DeltaTime, TSolidNotNull InWorld) 27 | PURE_VIRTUAL(IFlecsGameLoopInterface::Progress, return false;); 28 | 29 | }; // class IFlecsGameLoopInterface 30 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Pipelines/FlecsGameLoopObject.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsGameLoopObject.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsGameLoopObject) 6 | 7 | UFlecsGameLoopObject::UFlecsGameLoopObject() 8 | { 9 | } 10 | 11 | UFlecsGameLoopObject::UFlecsGameLoopObject(const FObjectInitializer& ObjectInitializer) 12 | : Super(ObjectInitializer) 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Pipelines/FlecsGameLoopObject.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsGameLoopInterface.h" 7 | #include "UObject/Object.h" 8 | #include "FlecsGameLoopObject.generated.h" 9 | 10 | UCLASS(Abstract, EditInlineNew, BlueprintType, NotBlueprintable, Category="Flecs|GameLoop") 11 | class UNREALFLECS_API UFlecsGameLoopObject : public UObject, public IFlecsGameLoopInterface 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | UFlecsGameLoopObject(); 17 | UFlecsGameLoopObject(const FObjectInitializer& ObjectInitializer); 18 | }; // class UFlecsGameLoopObject 19 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Prefabs/FlecsPrefabAsset.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsPrefabAsset.h" 4 | #include "Worlds/FlecsWorld.h" 5 | 6 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsPrefabAsset) 7 | 8 | void UFlecsPrefabAsset::OnEntityCreated(const FFlecsEntityHandle& InEntityHandle, UFlecsWorld* World) 9 | { 10 | PrefabEntityHandle = World->CreatePrefabWithRecord(Prefab.Record, Prefab.Name); 11 | } 12 | 13 | void UFlecsPrefabAsset::OnEntityDestroyed(const FFlecsEntityHandle& InEntityHandle, UFlecsWorld* World) 14 | { 15 | World->DestroyPrefab(PrefabEntityHandle); 16 | } 17 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Prefabs/FlecsPrefabAsset.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | // ReSharper disable CppExpressionWithoutSideEffects 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | #include "Entities/FlecsEntityRecord.h" 8 | #include "General/FlecsPrimaryDataAsset.h" 9 | #include "FlecsPrefabAsset.generated.h" 10 | 11 | USTRUCT(BlueprintType) 12 | struct FFlecsPrefabSlotInfo 13 | { 14 | GENERATED_BODY() 15 | 16 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Prefab") 17 | FString Name; 18 | 19 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Prefab") 20 | FFlecsEntityRecord Record; 21 | 22 | // @TODO: Not Implemented 23 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Prefab") 24 | TArray> SubSlots; 25 | 26 | }; // struct FFlecsPrefabSlotInfo 27 | 28 | UCLASS(BlueprintType) 29 | class UNREALFLECS_API UFlecsPrefabAsset : public UFlecsPrimaryDataAsset 30 | { 31 | GENERATED_BODY() 32 | 33 | public: 34 | 35 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Prefab") 36 | FFlecsPrefabSlotInfo Prefab; 37 | 38 | // @TODO: Not Implemented 39 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Prefab") 40 | TArray Slots; 41 | 42 | UPROPERTY() 43 | FFlecsEntityHandle PrefabEntityHandle; 44 | 45 | virtual void OnEntityCreated(const FFlecsEntityHandle& InEntityHandle, UFlecsWorld* World) override final; 46 | virtual void OnEntityDestroyed(const FFlecsEntityHandle& InEntityHandle, UFlecsWorld* World) override final; 47 | 48 | 49 | }; // class UFlecsPrefabAsset 50 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Prefabs/FlecsPrefabObject.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsPrefabObject.h" 4 | #include "SolidMacros/Macros.h" 5 | #include "Worlds/FlecsWorld.h" 6 | 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsPrefabObject) 8 | 9 | void UFlecsPrefabObject::CreatePrefab(const TSolidNotNull InWorld) 10 | { 11 | FlecsWorld = InWorld; 12 | 13 | PrefabEntityHandle = InWorld->CreatePrefab(PrefabName); 14 | OnPrefabCreated(GetPrefabHandle()); 15 | BP_OnPrefabCreated(GetPrefabHandle()); 16 | } 17 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Prefabs/FlecsPrefabObject.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Entities/FlecsEntityHandle.h" 7 | #include "Interfaces/FlecsEntityInterface.h" 8 | #include "UObject/Object.h" 9 | #include "FlecsPrefabObject.generated.h" 10 | 11 | class UFlecsWorld; 12 | 13 | UCLASS(Abstract, Blueprintable, BlueprintType, EditInlineNew, ClassGroup = (Flecs)) 14 | class UNREALFLECS_API UFlecsPrefabObject : public UObject, public IFlecsEntityInterface 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | void CreatePrefab(TSolidNotNull InWorld); 20 | 21 | virtual void OnPrefabCreated(const FFlecsEntityHandle& InPrefab) {} 22 | 23 | UFUNCTION(BlueprintImplementableEvent, Category = "Flecs", meta = (DisplayName = "OnPrefabCreated")) 24 | void BP_OnPrefabCreated(const FFlecsEntityHandle& InPrefab); 25 | 26 | UPROPERTY(EditAnywhere, Category = "Flecs") 27 | FString PrefabName; 28 | 29 | FORCEINLINE virtual FFlecsEntityHandle GetEntityHandle() const override final 30 | { 31 | return PrefabEntityHandle; 32 | } 33 | 34 | UPROPERTY() 35 | FFlecsEntityHandle PrefabEntityHandle; 36 | 37 | UFUNCTION(BlueprintCallable, Category = "Flecs") 38 | FORCEINLINE FFlecsEntityHandle GetPrefabHandle() const 39 | { 40 | return PrefabEntityHandle; 41 | } 42 | 43 | UFUNCTION(BlueprintCallable, Category = "Flecs") 44 | FORCEINLINE UFlecsWorld* GetFlecsWorld() const 45 | { 46 | return FlecsWorld.Get(); 47 | } 48 | 49 | protected: 50 | UPROPERTY() 51 | TWeakObjectPtr FlecsWorld; 52 | 53 | }; // class UFlecsPrefabObject 54 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Properties/FlecsComponentProperties.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsComponentProperties.h" 4 | 5 | FFlecsComponentPropertiesRegistry FFlecsComponentPropertiesRegistry::Instance; -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Enums/FlecsQueryCache.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "FlecsQueryCache.generated.h" 9 | 10 | UENUM(BlueprintType) 11 | enum class EFlecsQueryCacheType : uint8 12 | { 13 | Default = flecs::QueryCacheDefault, /**< Behavior determined by query creation context */ 14 | Auto = flecs::QueryCacheAuto, /**< Cache query terms that are cacheable */ 15 | All = flecs::QueryCacheAll, /**< Require that all query terms can be cached */ 16 | None = flecs::QueryCacheNone /**< No caching */ 17 | }; // enum class EFlecsQueryCacheType 18 | 19 | NO_DISCARD FORCEINLINE constexpr flecs::query_cache_kind_t ToFlecsQueryCache(EFlecsQueryCacheType CacheType) NOEXCEPT 20 | { 21 | return static_cast(CacheType); 22 | } -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Enums/FlecsQueryInOut.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "FlecsQueryInOut.generated.h" 9 | 10 | UENUM(BlueprintType) 11 | enum class EFlecsQueryInOut : uint8 12 | { 13 | Default = flecs::InOutDefault, /**< InOut for regular terms, In for shared terms */ 14 | None = flecs::InOutNone, /**< Term is neither read nor written */ 15 | Read = flecs::In, /** Term is only read */ 16 | Write = flecs::Out, /**< Term is only written */ 17 | ReadWrite = flecs::InOut UMETA(DisplayName = "Read/Write"), /**< Term is both read and written */ 18 | Filter = flecs::InOutFilter /** Same as None + prevents term from triggering observers */ 19 | }; // enum class EFlecsQueryInOut 20 | 21 | NO_DISCARD FORCEINLINE constexpr flecs::inout_kind_t ToFlecsInOut(EFlecsQueryInOut InOut) NOEXCEPT 22 | { 23 | return static_cast(InOut); 24 | } -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Enums/FlecsQueryOperators.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "SolidMacros/Macros.h" 9 | #include "FlecsQueryOperators.generated.h" 10 | 11 | UENUM(BlueprintType) 12 | enum class EFlecsQueryOperator : uint8 13 | { 14 | And = flecs::And, 15 | Or = flecs::Or, 16 | Not = flecs::Not, 17 | Optional = flecs::Optional, 18 | AndFrom = flecs::AndFrom, 19 | OrFrom = flecs::OrFrom, 20 | NotFrom = flecs::NotFrom, 21 | Default = flecs::And 22 | }; // enum class EFlecsQueryOperator 23 | 24 | NO_DISCARD FORCEINLINE constexpr flecs::oper_kind_t ToFlecsOperator(EFlecsQueryOperator Operator) NOEXCEPT 25 | { 26 | return static_cast(Operator); 27 | } 28 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsExpressionInOut.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsExpressionInOut.h" 4 | 5 | #include "Types/SolidNotNull.h" 6 | 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsExpressionInOut) 8 | 9 | FFlecsExpressionInOut::FFlecsExpressionInOut() : Super(false /* bInAllowsChildExpressions */) 10 | { 11 | } 12 | 13 | void FFlecsExpressionInOut::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 14 | { 15 | if (bStage) 16 | { 17 | InQueryBuilder.inout_stage(static_cast(InOut)); 18 | } 19 | else 20 | { 21 | InQueryBuilder.inout(static_cast(InOut)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsExpressionInOut.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryExpression.h" 7 | #include "Queries/Enums/FlecsQueryInOut.h" 8 | #include "Types/SolidNotNull.h" 9 | #include "FlecsExpressionInOut.generated.h" 10 | 11 | USTRUCT(BlueprintType, meta = (DisplayName = "In/Out Expression")) 12 | struct UNREALFLECS_API FFlecsExpressionInOut final : public FFlecsQueryExpression 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | FFlecsExpressionInOut(); 18 | 19 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 20 | 21 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query") 22 | EFlecsQueryInOut InOut = EFlecsQueryInOut::Default; 23 | 24 | /** Set read/write access for stage. Use this when a system reads or writes 25 | * components other than the ones provided by the query. This information 26 | * can be used by schedulers to insert sync/merge points between systems 27 | * where deferred operations are flushed. 28 | * 29 | * Setting this is optional. If not set, the value of the accessed component 30 | * may be out of sync for at most one frame. 31 | */ 32 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", AdvancedDisplay) 33 | bool bStage = true; 34 | 35 | }; // struct FFlecsExpressionInOut 36 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsOperQueryExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsOperQueryExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsOperQueryExpression) 6 | 7 | FFlecsOperQueryExpression::FFlecsOperQueryExpression() : Super(false /* bInAllowsChildExpressions */) 8 | { 9 | } 10 | 11 | void FFlecsOperQueryExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 12 | { 13 | InQueryBuilder.oper(static_cast(Operator)); 14 | } 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsOperQueryExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "FlecsQueryExpression.h" 9 | #include "Queries/Enums/FlecsQueryOperators.h" 10 | #include "Types/SolidNotNull.h" 11 | #include "FlecsOperQueryExpression.generated.h" 12 | 13 | USTRUCT(BlueprintType, meta = (DisplayName = "Operator Expression")) 14 | struct UNREALFLECS_API FFlecsOperQueryExpression final : public FFlecsQueryExpression 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | FFlecsOperQueryExpression(); 20 | 21 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 22 | 23 | UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Query") 24 | EFlecsQueryOperator Operator = EFlecsQueryOperator::Default; 25 | 26 | }; // struct FFlecsOperQueryExpression -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQueryExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQueryExpression) 6 | 7 | void FFlecsQueryExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 8 | { 9 | for (const TInstancedStruct& Child : Children) 10 | { 11 | Child.GetPtr()->Apply(InWorld, InQueryBuilder); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "StructUtils/InstancedStruct.h" 9 | #include "Types/SolidNotNull.h" 10 | #include "FlecsQueryExpression.generated.h" 11 | 12 | class UFlecsWorld; 13 | 14 | USTRUCT(BlueprintInternalUseOnly) 15 | struct UNREALFLECS_API FFlecsQueryExpression 16 | { 17 | GENERATED_BODY() 18 | 19 | protected: 20 | FORCEINLINE explicit FFlecsQueryExpression(const bool bInAllowsChildExpressions) 21 | #if WITH_EDITORONLY_DATA 22 | : bAllowsChildExpressions(bInAllowsChildExpressions) 23 | #endif // WITH_EDITORONLY_DATA 24 | {} 25 | 26 | public: 27 | FFlecsQueryExpression() = default; 28 | virtual ~FFlecsQueryExpression() = default; 29 | 30 | // We should only call the Super when we have child expressions 31 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const; 32 | 33 | #if WITH_EDITORONLY_DATA 34 | 35 | //UPROPERTY(VisibleAnywhere, Category = "Flecs | Query") 36 | UPROPERTY() 37 | bool bAllowsChildExpressions = false; 38 | 39 | #endif // WITH_EDITORONLY_DATA 40 | 41 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", 42 | meta = (EditCondition = "bAllowsChildExpressions", EditConditionHides, ShowOnlyInnerProperties, ExcludeBaseStruct)) 43 | TArray> Children; 44 | 45 | }; // struct FFlecsQueryExpression 46 | 47 | template<> 48 | struct TStructOpsTypeTraits : public TStructOpsTypeTraitsBase2 49 | { 50 | enum 51 | { 52 | //WithPureVirtual = true 53 | }; 54 | }; // struct TStructOpsTypeTraits 55 | 56 | template 57 | concept TQueryExpressionConcept = std::is_base_of::value; 58 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryFilterExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQueryFilterExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQueryFilterExpression) 6 | 7 | FFlecsQueryFilterExpression::FFlecsQueryFilterExpression() : Super(false /* bInAllowsChildExpressions */) 8 | { 9 | } 10 | 11 | void FFlecsQueryFilterExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 12 | { 13 | InQueryBuilder.filter(); 14 | } 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryFilterExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryExpression.h" 7 | #include "FlecsQueryFilterExpression.generated.h" 8 | 9 | USTRUCT(BlueprintType, meta = (DisplayName = "Filter Expression")) 10 | struct UNREALFLECS_API FFlecsQueryFilterExpression : public FFlecsQueryExpression 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | FFlecsQueryFilterExpression(); 16 | 17 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 18 | }; 19 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryNameExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQueryNameExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQueryNameExpression) 6 | 7 | FFlecsQueryNameExpression::FFlecsQueryNameExpression() : Super(false /* bInAllowsChildExpressions */) 8 | { 9 | } 10 | 11 | void FFlecsQueryNameExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 12 | { 13 | solid_checkf(!Name.IsEmpty(), TEXT("Name is empty")); 14 | InQueryBuilder.name(StringCast(*Name).Get()); 15 | } 16 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryNameExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryExpression.h" 7 | #include "FlecsQueryNameExpression.generated.h" 8 | 9 | USTRUCT(BlueprintType, meta = (DisplayName = "Name Expression")) 10 | struct UNREALFLECS_API FFlecsQueryNameExpression : public FFlecsQueryExpression 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | FFlecsQueryNameExpression(); 16 | 17 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query") 18 | FString Name; 19 | 20 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 21 | 22 | }; // struct FFlecsQueryNameExpression -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryOptionalExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQueryOptionalExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQueryOptionalExpression) 6 | 7 | FFlecsQueryOptionalExpression::FFlecsQueryOptionalExpression() : Super(false /* bInAllowsChildExpressions */) 8 | { 9 | } 10 | 11 | void FFlecsQueryOptionalExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 12 | { 13 | InQueryBuilder.optional(); 14 | } 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryOptionalExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryExpression.h" 7 | #include "FlecsQueryOptionalExpression.generated.h" 8 | 9 | USTRUCT(BlueprintType, meta = (DisplayName = "Optional Expression")) 10 | struct UNREALFLECS_API FFlecsQueryOptionalExpression : public FFlecsQueryExpression 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | FFlecsQueryOptionalExpression(); 16 | 17 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 18 | 19 | }; // struct FFlecsQueryOptionalExpression -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryScriptExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQueryScriptExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQueryScriptExpression) 6 | 7 | FFlecsQueryScriptExpression::FFlecsQueryScriptExpression() : Super(true /* bInAllowsChildExpressions */) 8 | { 9 | } 10 | 11 | void FFlecsQueryScriptExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 12 | { 13 | InQueryBuilder.expr(StringCast(*ScriptExpr.Expr).Get()); 14 | 15 | Super::Apply(InWorld, InQueryBuilder); 16 | } 17 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryScriptExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryExpression.h" 7 | #include "Queries/FlecsQueryScriptExpr.h" 8 | #include "FlecsQueryScriptExpression.generated.h" 9 | 10 | USTRUCT(BlueprintType, DisplayName = "Script Expression") 11 | struct UNREALFLECS_API FFlecsQueryScriptExpression : public FFlecsQueryExpression 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | FFlecsQueryScriptExpression(); 17 | 18 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", meta = (ShowOnlyInnerProperties)) 19 | FFlecsQueryScriptExpr ScriptExpr; 20 | 21 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 22 | 23 | }; // struct FFlecsQueryScriptExpression 24 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQuerySingletonExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQuerySingletonExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQuerySingletonExpression) 6 | 7 | FFlecsQuerySingletonExpression::FFlecsQuerySingletonExpression() : Super(false /* bInAllowsChildExpressions */) 8 | { 9 | } 10 | 11 | void FFlecsQuerySingletonExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 12 | { 13 | InQueryBuilder.singleton(); 14 | } 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQuerySingletonExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryExpression.h" 7 | #include "FlecsQuerySingletonExpression.generated.h" 8 | 9 | USTRUCT(BlueprintType, meta = (DisplayName = "Singleton Expression")) 10 | struct UNREALFLECS_API FFlecsQuerySingletonExpression : public FFlecsQueryExpression 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | FFlecsQuerySingletonExpression(); 16 | 17 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 18 | 19 | }; // struct FFlecsQuerySingletonExpression 20 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQuerySrcExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQuerySrcExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQuerySrcExpression) 6 | 7 | FFlecsQuerySrcExpression::FFlecsQuerySrcExpression() : Super(false /* bInAllowsChildExpressions */) 8 | { 9 | } 10 | 11 | void FFlecsQuerySrcExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 12 | { 13 | switch (SrcType) 14 | { 15 | case EFlecsQuerySrcType::Entity: 16 | { 17 | InQueryBuilder.src(Entity); 18 | } 19 | break; 20 | case EFlecsQuerySrcType::String: 21 | { 22 | InQueryBuilder.src(StringCast(*Src).Get()); 23 | } 24 | break; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQuerySrcExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryExpression.h" 7 | #include "Entities/FlecsEntityHandle.h" 8 | #include "FlecsQuerySrcExpression.generated.h" 9 | 10 | UENUM(BlueprintType) 11 | enum class EFlecsQuerySrcType : uint8 12 | { 13 | Entity, 14 | String 15 | }; // enum class EFlecsQuerySrcType 16 | 17 | USTRUCT(BlueprintType, meta = (DisplayName = "Source Expression")) 18 | struct UNREALFLECS_API FFlecsQuerySrcExpression : public FFlecsQueryExpression 19 | { 20 | GENERATED_BODY() 21 | 22 | public: 23 | FFlecsQuerySrcExpression(); 24 | 25 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 26 | 27 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query") 28 | EFlecsQuerySrcType SrcType = EFlecsQuerySrcType::Entity; 29 | 30 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", 31 | meta = (EditCondition = "SrcType == EFlecsQuerySrcType::Entity", EditConditionHides)) 32 | FFlecsEntityHandle Entity; 33 | 34 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", 35 | meta = (EditCondition = "SrcType == EFlecsQuerySrcType::String", EditConditionHides)) 36 | FString Src; 37 | 38 | }; // struct FFlecsQuerySrcExpression 39 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryTermExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQueryTermExpression.h" 4 | #include "Worlds/FlecsWorld.h" 5 | 6 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQueryTermExpression) 7 | 8 | FFlecsQueryTermExpression::FFlecsQueryTermExpression() : Super(true /* bInAllowsChildExpressions */) 9 | { 10 | } 11 | 12 | void FFlecsQueryTermExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 13 | { 14 | switch (InputType.Type) 15 | { 16 | case EFlecsQueryInputType::ScriptStruct: 17 | { 18 | const UScriptStruct* Struct = InputType.ScriptStruct; 19 | solid_checkf(IsValid(Struct), 20 | TEXT("Invalid ScriptStruct provided for query term expression")); 21 | 22 | const FFlecsEntityHandle ScriptStructEntity = InWorld->ObtainComponentTypeStruct(Struct); 23 | solid_check(ScriptStructEntity.IsValid()); 24 | 25 | InQueryBuilder.with(ScriptStructEntity); 26 | } 27 | break; 28 | case EFlecsQueryInputType::Entity: 29 | { 30 | const FFlecsId Entity = InputType.Entity; 31 | InQueryBuilder.with(Entity); 32 | } 33 | break; 34 | case EFlecsQueryInputType::String: 35 | { 36 | const FString Expr = InputType.Expr.Expr; 37 | InQueryBuilder.with(StringCast(*Expr).Get()); 38 | } 39 | break; 40 | case EFlecsQueryInputType::GameplayTag: 41 | { 42 | const FGameplayTag Tag = InputType.Tag; 43 | solid_checkf(Tag.IsValid(), 44 | TEXT("Invalid GameplayTag provided for query term expression")); 45 | 46 | const FFlecsEntityHandle TagEntity = InWorld->GetTagEntity(Tag); 47 | solid_check(TagEntity.IsValid()); 48 | 49 | InQueryBuilder.with(TagEntity); 50 | } 51 | break; 52 | } 53 | 54 | if (bWithout) 55 | { 56 | InQueryBuilder.not_(); 57 | } 58 | 59 | Super::Apply(InWorld, InQueryBuilder); 60 | } -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryTermExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsOperQueryExpression.h" 7 | #include "FlecsQueryExpression.h" 8 | #include "Queries/FlecsQueryInputType.h" 9 | #include "FlecsQueryTermExpression.generated.h" 10 | 11 | USTRUCT(BlueprintType, meta = (DisplayName = "Term Query")) 12 | struct UNREALFLECS_API FFlecsQueryTermExpression : public FFlecsQueryExpression 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | FFlecsQueryTermExpression(); 18 | 19 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query") 20 | FFlecsQueryInput InputType; 21 | 22 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query") 23 | bool bWithout = false; 24 | 25 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 26 | 27 | }; // struct FFlecsQueryTermExpression 28 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryVarExpression.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQueryVarExpression.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQueryVarExpression) 6 | 7 | FFlecsQueryVarExpression::FFlecsQueryVarExpression() : Super(false /* bInAllowsChildExpressions */) 8 | { 9 | } 10 | 11 | void FFlecsQueryVarExpression::Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const 12 | { 13 | InQueryBuilder.var(StringCast(*VarName).Get()); 14 | } 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/Expressions/FlecsQueryVarExpression.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryExpression.h" 7 | #include "FlecsQueryVarExpression.generated.h" 8 | 9 | USTRUCT(BlueprintType, meta = (DisplayName="Var Expression")) 10 | struct UNREALFLECS_API FFlecsQueryVarExpression : public FFlecsQueryExpression 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | FFlecsQueryVarExpression(); 16 | 17 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query") 18 | FString VarName; 19 | 20 | virtual void Apply(TSolidNotNull InWorld, flecs::query_builder<>& InQueryBuilder) const override; 21 | 22 | }; // struct FFlecsQueryVarExpression -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/FlecsQuery.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQuery.h" 4 | #include "Components/FlecsWorldPtrComponent.h" 5 | 6 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQuery) 7 | 8 | FFlecsQuery::FFlecsQuery(const TSolidNotNull InFlecsWorld, 9 | const FString& InName, 10 | const FFlecsQueryDefinition& InDefinition) 11 | { 12 | flecs::query_builder<> QueryBuilder = InFlecsWorld->World.query_builder<>(StringCast(*InName).Get()); 13 | InDefinition.Apply(InFlecsWorld, QueryBuilder); 14 | Query = QueryBuilder.build(); 15 | } 16 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/FlecsQueryDefinition.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsQueryDefinition.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsQueryDefinition) -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/FlecsQueryFlags.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "FlecsQueryFlags.generated.h" 9 | 10 | UENUM(BlueprintType, meta = (Bitflags, UseEnumValuesAsMaskValuesInEditor = true)) 11 | enum class EFlecsQueryFlags : uint8 12 | { 13 | None = 0 UMETA(Hidden), 14 | /** 15 | * Query must match prefabs. 16 | * Can be combined with other query flags on the ecs_query_desc_t::flags field. 17 | * @ingroup queries 18 | */ 19 | MatchPrefabs = EcsQueryMatchPrefab, 20 | /** 21 | * Query must match disabled entities. 22 | * Can be combined with other query flags on the ecs_query_desc_t::flags field. 23 | * @ingroup queries 24 | */ 25 | MatchDisabled = EcsQueryMatchDisabled, 26 | /** 27 | * Query must match empty tables. 28 | * Can be combined with other query flags on the ecs_query_desc_t::flags field. 29 | * @ingroup queries 30 | */ 31 | MatchEmptyTables = EcsQueryMatchEmptyTables, 32 | /** 33 | * Query may have unresolved entity identifiers. 34 | * Can be combined with other query flags on the ecs_query_desc_t::flags field. 35 | * @ingroup queries 36 | */ 37 | AllowUnresolvedByName = EcsQueryAllowUnresolvedByName, 38 | /** 39 | * Query only returns whole tables (ignores toggle/member fields). 40 | * Can be combined with other query flags on the ecs_query_desc_t::flags field. 41 | * @ingroup queries 42 | */ 43 | TableOnly = EcsQueryTableOnly, 44 | }; // enum class EFlecsQueryFlags 45 | 46 | ENUM_CLASS_FLAGS(EFlecsQueryFlags) 47 | 48 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/FlecsQueryInputType.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryScriptExpr.h" 7 | #include "Entities/FlecsEntityHandle.h" 8 | #include "FlecsQueryInputType.generated.h" 9 | 10 | UENUM(BlueprintType) 11 | enum class EFlecsQueryInputType : uint8 12 | { 13 | ScriptStruct, 14 | Entity, 15 | String, 16 | GameplayTag, 17 | }; // enum class EFlecsQueryInputType 18 | 19 | USTRUCT(BlueprintType) 20 | struct UNREALFLECS_API FFlecsQueryInput 21 | { 22 | GENERATED_BODY() 23 | 24 | public: 25 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query") 26 | EFlecsQueryInputType Type = EFlecsQueryInputType::ScriptStruct; 27 | 28 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", 29 | meta = (EditCondition = "Type == EFlecsQueryInputType::ScriptStruct", EditConditionHides)) 30 | TObjectPtr ScriptStruct; 31 | 32 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", 33 | meta = (EditCondition = "Type == EFlecsQueryInputType::Entity", EditConditionHides)) 34 | FFlecsId Entity; 35 | 36 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", 37 | meta = (EditCondition = "Type == EFlecsQueryInputType::String", EditConditionHides)) 38 | FFlecsQueryScriptExpr Expr; 39 | 40 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Query", 41 | meta = (EditCondition = "Type == EFlecsQueryInputType::GameplayTag", EditConditionHides)) 42 | FGameplayTag Tag; 43 | 44 | }; // struct FFlecsQueryInput 45 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Queries/FlecsQueryScriptExpr.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsQueryScriptExpr.generated.h" 7 | 8 | /** 9 | * We need this type to have a custom PropertyEditor for the FlecsQueryScriptExpr type. 10 | */ 11 | USTRUCT(BlueprintType) 12 | struct UNREALFLECS_API FFlecsQueryScriptExpr 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | UPROPERTY(EditAnywhere, Category = "Query") 18 | FString Expr; 19 | }; // struct FFlecsQueryScriptExpr 20 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Rendering/FlecsRenderingModule.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsRenderingModule.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsRenderingModule) 6 | 7 | UFlecsRenderingModule::UFlecsRenderingModule(const FObjectInitializer& ObjectInitializer) 8 | : Super(ObjectInitializer) 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Rendering/FlecsRenderingModule.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/FlecsModuleObject.h" 7 | #include "FlecsRenderingModule.generated.h" 8 | 9 | // @TODO: Not Implemented 10 | UCLASS(BlueprintType, DefaultToInstanced, EditInlineNew) 11 | class UNREALFLECS_API UFlecsRenderingModule final : public UFlecsModuleObject 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | UFlecsRenderingModule(const FObjectInitializer& ObjectInitializer); 17 | 18 | }; // class UFlecsRenderingModule 19 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Systems/FlecsSystemActor.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsSystemActor.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsSystemActor) 6 | 7 | AFlecsSystemActor::AFlecsSystemActor() 8 | { 9 | } 10 | 11 | AFlecsSystemActor::AFlecsSystemActor(const FObjectInitializer& ObjectInitializer) 12 | : Super(ObjectInitializer) 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Systems/FlecsSystemActor.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsSystemInterface.h" 7 | #include "FlecsSystemSettingsInfo.h" 8 | #include "GameFramework/Actor.h" 9 | #include "FlecsSystemActor.generated.h" 10 | 11 | UCLASS(Abstract) 12 | class UNREALFLECS_API AFlecsSystemActor : public AActor, public IFlecsSystemInterface 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | AFlecsSystemActor(); 18 | AFlecsSystemActor(const FObjectInitializer& ObjectInitializer); 19 | 20 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Flecs", meta = (ExposeOnSpawn = true)) 21 | FFlecsSystemSettingsInfo SystemSettings; 22 | 23 | }; // class AFlecsSystemActor 24 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Systems/FlecsSystemInterface.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsSystemInterface.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsSystemInterface) 6 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Systems/FlecsSystemObject.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsSystemObject.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsSystemObject) 6 | 7 | UFlecsSystemObject::UFlecsSystemObject(const FObjectInitializer& ObjectInitializer) 8 | : Super(ObjectInitializer) 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Systems/FlecsSystemObject.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsSystemInterface.h" 7 | #include "FlecsSystemSettingsInfo.h" 8 | #include "UObject/Object.h" 9 | #include "FlecsSystemObject.generated.h" 10 | 11 | UCLASS(Abstract, BlueprintType, Blueprintable) 12 | class UNREALFLECS_API UFlecsSystemObject : public UObject, public IFlecsSystemInterface 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | UFlecsSystemObject(const FObjectInitializer& ObjectInitializer); 18 | 19 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Flecs", meta = (ExposeOnSpawn = true)) 20 | FFlecsSystemSettingsInfo SystemSettings; 21 | 22 | private: 23 | 24 | }; // class UFlecsSystemObject 25 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Systems/FlecsSystemSettingsInfo.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Entities/FlecsEntityRecord.h" 7 | #include "FlecsSystemSettingsInfo.generated.h" 8 | 9 | UENUM(BlueprintType) 10 | enum class EFlecsSystemTimerKind : uint8 11 | { 12 | None = 0, 13 | Interval = 1, 14 | Rate = 2, 15 | }; // enum class EFlecsSystemTimerKind 16 | 17 | USTRUCT(BlueprintType) 18 | struct UNREALFLECS_API FFlecsSystemSettingsInfo 19 | { 20 | GENERATED_BODY() 21 | 22 | public: 23 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System") 24 | FString Name; 25 | 26 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System") 27 | FFlecsEntityRecord SystemRecord; 28 | 29 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System") 30 | FFlecsEntityHandle Kind; 31 | 32 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System") 33 | EFlecsSystemTimerKind TimerKind = EFlecsSystemTimerKind::None; 34 | 35 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System", 36 | meta = (ClampMin = 0.0f, UIMin = 0.0f, EditCondition = "TimerKind == EFlecsSystemTimerKind::Interval")) 37 | double Interval = 0.0f; 38 | 39 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System", 40 | meta = (ClampMin = 0, UIMin = 0, EditCondition = "TimerKind == EFlecsSystemTimerKind::Rate")) 41 | int32 Rate = 0; 42 | 43 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System") 44 | FFlecsEntityHandle TickSource; 45 | 46 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System") 47 | bool bImmediate = false; 48 | 49 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System") 50 | bool bMultiThreaded = false; 51 | 52 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "System", AdvancedDisplay) 53 | int32 Priority = FLECS_DEFAULT_SYSTEM_PRIORITY; 54 | 55 | }; // struct FFlecsSystemSettingsInfo -------------------------------------------------------------------------------- /Source/UnrealFlecs/Ticker/FlecsTickerComponent.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Properties/FlecsComponentProperties.h" 7 | #include "FlecsTickerComponent.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct UNREALFLECS_API FFlecsTickerComponent final 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | FORCEINLINE FFlecsTickerComponent() = default; 16 | FORCEINLINE FFlecsTickerComponent(const int32 InTickId) : TickId(InTickId) {} 17 | 18 | UPROPERTY() 19 | int32 TickId = 0; 20 | 21 | }; // struct FFlecsTickerComponent 22 | 23 | REGISTER_FLECS_COMPONENT(FFlecsTickerComponent, 24 | [](flecs::world InWorld, const FFlecsComponentHandle& InComponent) 25 | { 26 | InComponent.Add(flecs::Sparse); 27 | }); 28 | 29 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Ticker/FlecsTickerDefaultEntities.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsTickerDefaultEntities.h" 4 | 5 | DEFINE_DEFAULT_ENTITY(FlecsFixedTick, 5001 + FLECS_HI_COMPONENT_ID, [](flecs::entity InEntity) 6 | { 7 | }); -------------------------------------------------------------------------------- /Source/UnrealFlecs/Ticker/FlecsTickerDefaultEntities.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Entities/FlecsDefaultEntityEngineSubsystem.h" 7 | 8 | UNREALFLECS_API DECLARE_DEFAULT_ENTITY(FlecsFixedTick); -------------------------------------------------------------------------------- /Source/UnrealFlecs/Ticker/FlecsTickerGameLoop.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsTickerComponent.h" 7 | #include "Entities/FlecsEntityHandle.h" 8 | #include "Pipelines/FlecsGameLoopObject.h" 9 | #include "Systems/FlecsSystem.h" 10 | #include "FlecsTickerGameLoop.generated.h" 11 | 12 | UCLASS(BlueprintType) 13 | class UNREALFLECS_API UFlecsTickerGameLoop : public UFlecsGameLoopObject 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | 19 | virtual void InitializeGameLoop(TSolidNotNull InWorld) override; 20 | virtual bool Progress(double DeltaTime, TSolidNotNull InWorld) override; 21 | 22 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ticker", 23 | meta = (Units = "Hz", ClampMin = "1", ClampMax = "240")) //EditCondition = "!bUsePhysicsTick")) 24 | int64 TickerRate = 60; 25 | 26 | UFUNCTION(BlueprintCallable, Category = "Flecs | Ticker") 27 | FORCEINLINE int64 GetTickerRate() const { return TickerRate; } 28 | 29 | UFUNCTION(BlueprintCallable, Category = "Flecs | Ticker") 30 | FORCEINLINE void SetTickerRate(const int64 InRate) { TickerRate = InRate; } 31 | 32 | UFUNCTION(BlueprintCallable, Category = "Flecs | Ticker") 33 | FORCEINLINE FFlecsSystem GetTickerSystem() const { return TickerSystem; } 34 | 35 | UFUNCTION(BlueprintCallable, Category = "Flecs | Ticker") 36 | FORCEINLINE FFlecsEntityHandle GetTickerSource() const { return TickerSystem.GetEntity(); } 37 | 38 | UPROPERTY() 39 | double TickerAccumulator = 0.0; 40 | 41 | double TickerInterval = 0.0; 42 | 43 | FFlecsTickerComponent* TickerComponentPtr = nullptr; 44 | 45 | UPROPERTY() 46 | FFlecsSystem TickerSystem; 47 | 48 | UPROPERTY() 49 | FFlecsEntityHandle MainPipeline; 50 | 51 | UPROPERTY() 52 | FFlecsEntityHandle TickerPipeline; 53 | 54 | }; // class UFlecsTickerGameLoop 55 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Transforms/FlecsTransformComponents.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsTransformComponents.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsTransformComponents) 6 | 7 | UFlecsTransform3dCollection::UFlecsTransform3dCollection(const FObjectInitializer& ObjectInitializer) 8 | : Super(ObjectInitializer) 9 | { 10 | Location = FFlecsLocationComponent(); 11 | Rotation = FFlecsRotationComponent(); 12 | Scale = FFlecsScaleComponent(); 13 | } 14 | 15 | void UFlecsTransform3dCollection::ApplyCollectionToEntity_Implementation(FFlecsEntityHandle& Entity) 16 | { 17 | Super::ApplyCollectionToEntity_Implementation(Entity); 18 | 19 | Entity.Set(Location); 20 | Entity.Set(Rotation); 21 | Entity.Set(Scale); 22 | } 23 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Transforms/FlecsTransformDefaultEntities.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsTransformDefaultEntities.h" 4 | 5 | DEFINE_DEFAULT_ENTITY(FlecsLocalTrait, 5002 + FLECS_HI_COMPONENT_ID, [](flecs::entity InEntity) 6 | { 7 | }); 8 | 9 | DEFINE_DEFAULT_ENTITY(FlecsGlobalTrait, 5003 + FLECS_HI_COMPONENT_ID, [](flecs::entity InEntity) 10 | { 11 | }); 12 | 13 | DEFINE_DEFAULT_ENTITY(FlecsRelativeTrait, 5004 + FLECS_HI_COMPONENT_ID, [](flecs::entity InEntity) 14 | { 15 | }); -------------------------------------------------------------------------------- /Source/UnrealFlecs/Transforms/FlecsTransformDefaultEntities.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "flecs.h" 6 | 7 | #include "CoreMinimal.h" 8 | #include "Entities/FlecsDefaultEntityEngineSubsystem.h" 9 | 10 | // Gets the closest Entity with FGlobalTransform 11 | UNREALFLECS_API DECLARE_DEFAULT_ENTITY(FlecsLocalTrait); 12 | UNREALFLECS_API DECLARE_DEFAULT_ENTITY(FlecsGlobalTrait); 13 | 14 | // Doesn't have own Transform, but is relative to another Entity 15 | UNREALFLECS_API DECLARE_DEFAULT_ENTITY(FlecsRelativeTrait); 16 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Transforms/FlecsTransformModule.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsTransformModule.h" 4 | #include "FlecsTransformComponents.h" 5 | #include "Worlds/FlecsWorld.h" 6 | 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsTransformModule) 8 | 9 | UFlecsTransformModule::UFlecsTransformModule() 10 | { 11 | } 12 | 13 | void UFlecsTransformModule::InitializeModule(TSolidNotNull InWorld, 14 | const FFlecsEntityHandle& InModuleEntity) 15 | { 16 | InWorld->RegisterComponentType(); 17 | InWorld->RegisterComponentType(); 18 | InWorld->RegisterComponentType(); 19 | } 20 | 21 | void UFlecsTransformModule::DeinitializeModule(TSolidNotNull InWorld) 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Transforms/FlecsTransformModule.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/FlecsModuleObject.h" 7 | #include "FlecsTransformModule.generated.h" 8 | 9 | // @TODO: Not Fully Implemented 10 | UCLASS(BlueprintType, DisplayName = "Flecs Transform Module") 11 | class UNREALFLECS_API UFlecsTransformModule final : public UFlecsModuleObject 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | UFlecsTransformModule(); 17 | 18 | FORCEINLINE virtual FString GetModuleName_Implementation() const override 19 | { 20 | return "Flecs Transform Module"; 21 | } 22 | 23 | virtual void InitializeModule(TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) override; 24 | virtual void DeinitializeModule(TSolidNotNull InWorld) override; 25 | 26 | 27 | }; // class UFlecsTransformModule 28 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Translators/FlecsTranslationModule.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsTranslationModule.h" 4 | #include "FlecsTranslationSettingTraits.h" 5 | #include "Worlds/FlecsWorld.h" 6 | 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsTranslationModule) 8 | 9 | void UFlecsTranslationModule::InitializeModule( 10 | TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) 11 | { 12 | InWorld->RegisterComponentType(); 13 | InWorld->RegisterComponentType(); 14 | InWorld->RegisterComponentType(); 15 | InWorld->RegisterComponentType(); 16 | } 17 | 18 | void UFlecsTranslationModule::DeinitializeModule(TSolidNotNull InWorld) 19 | { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Translators/FlecsTranslationModule.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/FlecsModuleObject.h" 7 | #include "FlecsTranslationModule.generated.h" 8 | 9 | // @TODO: Not Implemented 10 | UCLASS(BlueprintType, meta = (DisplayName = "Flecs Translation Module")) 11 | class UNREALFLECS_API UFlecsTranslationModule final : public UFlecsModuleObject 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | FORCEINLINE virtual FString GetModuleName_Implementation() const override 17 | { 18 | return "Flecs Translation Module"; 19 | } 20 | 21 | virtual void InitializeModule( 22 | TSolidNotNull InWorld, const FFlecsEntityHandle& InModuleEntity) override; 23 | virtual void DeinitializeModule(TSolidNotNull InWorld) override; 24 | 25 | private: 26 | 27 | }; // class UFlecsTranslationModule 28 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Translators/FlecsTranslationSettingTraits.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Properties/FlecsComponentProperties.h" 7 | #include "FlecsTranslationSettingTraits.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct UNREALFLECS_API FFlecsTranslationPropertyTrait 11 | { 12 | GENERATED_BODY() 13 | }; // struct FFlecsTranslationPropertyTrait 14 | 15 | REGISTER_FLECS_COMPONENT(FFlecsTranslationPropertyTrait, 16 | [](flecs::world InWorld, const FFlecsComponentHandle& InComponent) 17 | { 18 | InComponent.Add(flecs::PairIsTag); 19 | }) 20 | 21 | USTRUCT(BlueprintType) 22 | struct UNREALFLECS_API FFlecsToUnreal 23 | { 24 | GENERATED_BODY() 25 | }; // struct FFlecsToUnreal 26 | 27 | USTRUCT(BlueprintType) 28 | struct UNREALFLECS_API FUnrealToFlecs 29 | { 30 | GENERATED_BODY() 31 | }; // struct FUnrealToFlecs 32 | 33 | USTRUCT(BlueprintType) 34 | struct UNREALFLECS_API FFlecsToBoth 35 | { 36 | GENERATED_BODY() 37 | }; // struct FFlecsToBoth -------------------------------------------------------------------------------- /Source/UnrealFlecs/UnrealFlecs.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class UnrealFlecs : ModuleRules 6 | { 7 | public UnrealFlecs(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | CppStandard = CppStandardVersion.Latest; 12 | OptimizationLevel = OptimizationMode.Speed; 13 | IWYUSupport = IWYUSupport.Full; 14 | bEnableNonInlinedGenCppWarnings = true; 15 | 16 | PublicIncludePaths.AddRange( 17 | new string[] 18 | { 19 | ModuleDirectory 20 | } 21 | ); 22 | 23 | PublicDependencyModuleNames.AddRange( 24 | new string[] 25 | { 26 | "Core", 27 | "FlecsLibrary", 28 | "SolidMacros", 29 | "GameplayTags", 30 | "AssetRegistry", 31 | "StructUtils", 32 | "NetCore", 33 | "NetCommon", 34 | "PhysicsCore", 35 | "Chaos", 36 | "ChaosCore", 37 | "ChaosSolverEngine", 38 | "DeveloperSettings", 39 | } 40 | ); 41 | 42 | 43 | PrivateDependencyModuleNames.AddRange( 44 | new string[] 45 | { 46 | "CoreUObject", 47 | "Engine", 48 | "Slate", 49 | "SlateCore" 50 | } 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/UnrealFlecs.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "UnrealFlecs.h" 4 | 5 | #include "Entities/FlecsDefaultEntityEngineSubsystem.h" 6 | #include "Worlds/FlecsOSAPI.h" 7 | #include "Versioning/UnrealFlecsVersion.h" 8 | 9 | #if !defined(SOLID_MACROS_VERSION) || SOLID_MACROS_VERSION != EXPECTED_SOLID_MACROS_VERSION 10 | #error "The Solid Macros version is not as expected. Please update the Solid Macros to the latest version." 11 | #endif 12 | 13 | #define LOCTEXT_NAMESPACE "FUnrealFlecsModule" 14 | 15 | static FOSApiInitializer OSApiInitializer; 16 | 17 | void FUnrealFlecsModule::StartupModule() 18 | { 19 | FCoreDelegates::OnPostEngineInit.AddLambda([]() 20 | { 21 | FFlecsDefaultEntityEngine::Get().Initialize(); 22 | }); 23 | } 24 | 25 | void FUnrealFlecsModule::ShutdownModule() 26 | { 27 | } 28 | 29 | #undef LOCTEXT_NAMESPACE 30 | 31 | IMPLEMENT_MODULE(FUnrealFlecsModule, UnrealFlecs) -------------------------------------------------------------------------------- /Source/UnrealFlecs/UnrealFlecs.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class FUnrealFlecsModule : public IModuleInterface 9 | { 10 | public: 11 | 12 | /** IModuleInterface implementation */ 13 | virtual void StartupModule() override; 14 | virtual void ShutdownModule() override; 15 | }; // class FUnrealFlecsModule 16 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Versioning/UnrealFlecsVersion.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Versioning/SolidMacrosVersion.h" 6 | 7 | #define EXPECTED_SOLID_MACROS_MAJOR 0 8 | #define EXPECTED_SOLID_MACROS_MINOR 1 9 | #define EXPECTED_SOLID_MACROS_PATCH 3 10 | #define EXPECTED_SOLID_MACROS_BUILD 0 11 | 12 | #define EXPECTED_SOLID_MACROS_VERSION (EXPECTED_SOLID_MACROS_MAJOR * 1000000 + \ 13 | EXPECTED_SOLID_MACROS_MINOR * 10000 + \ 14 | EXPECTED_SOLID_MACROS_PATCH * 100 + \ 15 | EXPECTED_SOLID_MACROS_BUILD) 16 | 17 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Worlds/FlecsAbstractWorldSubsystem.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsAbstractWorldSubsystem.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsAbstractWorldSubsystem) 6 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Worlds/FlecsAbstractWorldSubsystem.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsWorld.h" 7 | #include "FlecsWorldSubsystem.h" 8 | #include "Subsystems/WorldSubsystem.h" 9 | #include "FlecsAbstractWorldSubsystem.generated.h" 10 | 11 | UCLASS(Abstract) 12 | class UNREALFLECS_API UFlecsAbstractWorldSubsystem : public UWorldSubsystem 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | FORCEINLINE virtual void Initialize(FSubsystemCollectionBase& Collection) override 18 | { 19 | Super::Initialize(Collection); 20 | 21 | Collection.InitializeDependency(); 22 | FlecsWorld = UFlecsWorldSubsystem::GetDefaultWorldStatic(this); 23 | } 24 | 25 | FORCEINLINE virtual bool DoesSupportWorldType(const EWorldType::Type WorldType) const override final 26 | { 27 | return WorldType == EWorldType::Game 28 | || WorldType == EWorldType::PIE 29 | || WorldType == EWorldType::GameRPC; 30 | } 31 | 32 | NO_DISCARD FORCEINLINE UFlecsWorld* GetFlecsWorld() const 33 | { 34 | return FlecsWorld.Get(); 35 | } 36 | 37 | UPROPERTY() 38 | TWeakObjectPtr FlecsWorld; 39 | 40 | }; // class UFlecsAbstractWorldSubsystem 41 | 42 | 43 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Worlds/FlecsWorld.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsWorld.h" 4 | #include "FlecsWorldSubsystem.h" 5 | 6 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsWorld) 7 | 8 | // static bool GFlecs_bRegisterMemberTypeStructs = false; 9 | // FAutoConsoleVariable CVarFlecsRegisterMemberTypeStructs( 10 | // TEXT("Flecs.RegisterMemberTypeStructs"), 11 | // GFlecs_bRegisterMemberTypeStructs, 12 | // TEXT("Register the member type structs as components if not previously registered."), 13 | // ECVF_Default); 14 | 15 | UFlecsWorldSubsystem* UFlecsWorld::GetContext() const 16 | { 17 | return static_cast(World.get_ctx()); 18 | } 19 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Worlds/FlecsWorldInfoSettings.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsWorldInfoSettings.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsWorldInfoSettings) -------------------------------------------------------------------------------- /Source/UnrealFlecs/Worlds/FlecsWorldSettings.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsWorldSettings.h" 4 | 5 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsWorldSettings) 6 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Worlds/FlecsWorldSettings.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/WorldSettings.h" 7 | #include "FlecsWorldSettings.generated.h" 8 | 9 | class UFlecsWorldSettingsAsset; 10 | 11 | UCLASS() 12 | class UNREALFLECS_API AFlecsWorldSettings : public AWorldSettings 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Flecs", meta = (ExposeOnSpawn = true)) 18 | TObjectPtr DefaultWorld; 19 | 20 | }; // class AFlecsWorldSettings 21 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Worlds/FlecsWorldSettingsAsset.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsWorldSettingsAsset.h" 4 | 5 | #include "Pipelines/FlecsDefaultGameLoop.h" 6 | 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(FlecsWorldSettingsAsset) 8 | 9 | #define LOCTEXT_NAMESPACE "FlecsWorldSettingsAsset" 10 | 11 | UFlecsWorldSettingsAsset::UFlecsWorldSettingsAsset() 12 | { 13 | WorldSettings.WorldName = "DefaultFlecsWorld"; 14 | 15 | //WorldSettings.GameLoop = NewObject(this); 16 | } 17 | 18 | #if WITH_EDITOR 19 | 20 | EDataValidationResult UFlecsWorldSettingsAsset::IsDataValid(FDataValidationContext& Context) const 21 | { 22 | if (!IsValid(WorldSettings.GameLoop)) 23 | { 24 | Context.AddError(FText::Format( 25 | LOCTEXT("InvalidGameLoop", 26 | "WorldSettings {0} does not have a valid GameLoop set."), 27 | FText::FromString(GetPathName()))); 28 | 29 | return EDataValidationResult::Invalid; 30 | } 31 | 32 | return Super::IsDataValid(Context); 33 | } 34 | 35 | #endif // WITH_EDITOR 36 | 37 | 38 | #undef LOCTEXT_NAMESPACE 39 | -------------------------------------------------------------------------------- /Source/UnrealFlecs/Worlds/FlecsWorldSettingsAsset.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FlecsWorldInfoSettings.h" 7 | #include "Engine/DataAsset.h" 8 | #include "Misc/DataValidation.h" 9 | #include "FlecsWorldSettingsAsset.generated.h" 10 | 11 | UCLASS(BlueprintType, Blueprintable) 12 | class UNREALFLECS_API UFlecsWorldSettingsAsset : public UDataAsset 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | UFlecsWorldSettingsAsset(); 18 | 19 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Flecs") 20 | FFlecsWorldSettingsInfo WorldSettings; 21 | 22 | #if WITH_EDITOR 23 | 24 | virtual EDataValidationResult IsDataValid(FDataValidationContext& Context) const override; 25 | 26 | #endif // WITH_EDITOR 27 | 28 | FORCEINLINE virtual FPrimaryAssetId GetPrimaryAssetId() const override final 29 | { 30 | return FPrimaryAssetId("FlecsWorld", GetFName()); 31 | } 32 | 33 | }; // class UFlecsWorldSettingsAsset 34 | -------------------------------------------------------------------------------- /Source/UnrealFlecsEditor/Logs/FlecsEditorCategory.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Unlog/Unlog.h" 7 | 8 | UNLOG_CATEGORY(LogFlecsEditor); 9 | 10 | using FFlecsEditorLog 11 | = TUnlog<>::WithCategory::WithTargets; 12 | -------------------------------------------------------------------------------- /Source/UnrealFlecsEditor/UnrealFlecsEditor.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class UnrealFlecsEditor : ModuleRules 4 | { 5 | public UnrealFlecsEditor(ReadOnlyTargetRules Target) : base(Target) 6 | { 7 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 8 | 9 | PublicDependencyModuleNames.AddRange( 10 | new string[] 11 | { 12 | "Core", 13 | } 14 | ); 15 | 16 | PrivateDependencyModuleNames.AddRange( 17 | new string[] 18 | { 19 | "CoreUObject", 20 | "Engine", 21 | "Slate", 22 | "SlateCore", 23 | "ToolMenus", 24 | "EditorStyle", 25 | "Projects", 26 | "PropertyEditor", 27 | "UnrealFlecs", 28 | "FlecsLibrary", 29 | "StructUtils", 30 | "InputCore", 31 | "UnrealEd", 32 | "GraphEditor", 33 | "BlueprintGraph", 34 | "StructUtilsEditor", 35 | "AssetRegistry", 36 | } 37 | ); 38 | } 39 | } -------------------------------------------------------------------------------- /Source/UnrealFlecsEditor/UnrealFlecsEditor.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class FFlecsIdPinFactory; 9 | 10 | class FUnrealFlecsEditorModule : public IModuleInterface 11 | { 12 | public: 13 | virtual void StartupModule() override; 14 | virtual void ShutdownModule() override; 15 | 16 | private: 17 | void RegisterExplorerMenuExtension(); 18 | void AddPrimaryAssetTypes(); 19 | 20 | TSharedPtr FlecsIdPinFactory; 21 | }; // class FUnrealFlecsEditorModule 22 | -------------------------------------------------------------------------------- /Source/UnrealFlecsEditor/UnrealFlecsEditorStyle.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Editor/EditorStyle/Public/EditorStyleSet.h" 7 | #include "Runtime/Projects/Public/Interfaces/IPluginManager.h" 8 | #include "Runtime/SlateCore/Public/Brushes/SlateImageBrush.h" 9 | #include "Runtime/SlateCore/Public/Styling/SlateStyle.h" 10 | #include "Runtime/SlateCore/Public/Styling/SlateStyleRegistry.h" 11 | 12 | class FUnrealFlecsEditorStyle : public FEditorStyle 13 | { 14 | public: 15 | static void Initialize() 16 | { 17 | FString PluginContentDir = IPluginManager::Get().FindPlugin(TEXT("UnrealFlecs"))->GetBaseDir(); 18 | const FString ContentDir = FPaths::Combine(PluginContentDir, TEXT("Resources")); 19 | 20 | FSlateStyleSet* StyleSet = new FSlateStyleSet("UnrealFlecsEditorStyle"); 21 | StyleSet->SetContentRoot(ContentDir); 22 | 23 | const FVector2D IconSize(128.0f, 128.0f); 24 | const FString IconPath = FPaths::Combine(ContentDir, TEXT("Icon128.png")); 25 | StyleSet->Set("UnrealFlecs.FlecsEditor.FlecsLogo", new FSlateImageBrush(IconPath, IconSize)); 26 | 27 | FSlateStyleRegistry::RegisterSlateStyle(*StyleSet); 28 | } 29 | 30 | static void Shutdown() 31 | { 32 | FSlateStyleRegistry::UnRegisterSlateStyle("UnrealFlecsEditorStyle"); 33 | } 34 | 35 | }; // struct FUnrealFlecsEditorStyle 36 | -------------------------------------------------------------------------------- /Source/UnrealFlecsEditor/Widgets/EntityHandle/FlecsIdCustomization.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | class UNREALFLECSEDITOR_API FFlecsIdCustomization : public IPropertyTypeCustomization 8 | { 9 | public: 10 | static TSharedRef MakeInstance(); 11 | 12 | virtual void CustomizeHeader(TSharedRef StructPropertyHandle, 13 | FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; 14 | virtual void CustomizeChildren(TSharedRef StructPropertyHandle, 15 | IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; 16 | 17 | protected: 18 | TSharedPtr GetSelectedItem() const; 19 | 20 | TSharedPtr PropertyHandle; 21 | 22 | }; // class FFlecsIdCustomization 23 | -------------------------------------------------------------------------------- /Source/UnrealFlecsEditor/Widgets/EntityHandle/FlecsIdPinFactory.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "FlecsIdPinFactory.h" 4 | #include "SGraphPinFlecsId.h" 5 | #include "Entities/FlecsEntityHandle.h" 6 | 7 | TSharedPtr FFlecsIdPinFactory::CreatePin(UEdGraphPin* InPin) const 8 | { 9 | if (InPin->PinType.PinCategory == UEdGraphSchema_K2::PC_Struct && 10 | InPin->PinType.PinSubCategoryObject == FFlecsId::StaticStruct()) 11 | { 12 | return SNew(SGraphPinFlecsId, InPin); 13 | } 14 | 15 | return nullptr; 16 | } 17 | -------------------------------------------------------------------------------- /Source/UnrealFlecsEditor/Widgets/EntityHandle/FlecsIdPinFactory.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "EdGraphUtilities.h" 7 | 8 | class FFlecsIdPinFactory : public FGraphPanelPinFactory 9 | { 10 | public: 11 | virtual TSharedPtr CreatePin(UEdGraphPin* InPin) const override; 12 | }; // class FFlecsIdPinFactory 13 | -------------------------------------------------------------------------------- /Source/UnrealFlecsEditor/Widgets/EntityHandle/SGraphPinFlecsId.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "SGraphPin.h" 7 | #include "Entities/FlecsId.h" 8 | 9 | class SGraphPinFlecsId : public SGraphPin 10 | { 11 | public: 12 | SLATE_BEGIN_ARGS(SGraphPinFlecsId) {} 13 | SLATE_END_ARGS() 14 | 15 | virtual void Construct(const FArguments& InArgs, UEdGraphPin* InGraphPinObj); 16 | 17 | protected: 18 | virtual TSharedRef GetDefaultValueWidget() override; 19 | TSharedPtr GetSelectedName() const; 20 | 21 | TArray> Options; 22 | TArray EntityOptions; 23 | }; // class SGraphPinFlecsId -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Benchmarks/Entities/EntityBenchmarks.spec.cpp: -------------------------------------------------------------------------------- 1 |  2 | #if WITH_AUTOMATION_TESTS 3 | 4 | #include "Misc/AutomationTest.h" 5 | #include "Fixtures/FlecsWorldFixture.h" 6 | 7 | BEGIN_DEFINE_SPEC(FEntityBenchmarksSpec, 8 | "Flecs.Benchmarks.Entity", 9 | EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter); 10 | 11 | FFlecsTestFixture Fixture; 12 | 13 | END_DEFINE_SPEC(FEntityBenchmarksSpec); 14 | 15 | void FEntityBenchmarksSpec::Define() 16 | { 17 | FLECS_FIXTURE_LIFECYCLE(Fixture); 18 | } 19 | 20 | #endif // WITH_AUTOMATION_TESTS 21 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Components/Collections/ComponentCollectionTest.spec.cpp: -------------------------------------------------------------------------------- 1 |  2 | #include "Transforms/FlecsTransformModule.h" 3 | #if WITH_AUTOMATION_TESTS 4 | 5 | #include "Misc/AutomationTest.h" 6 | #include "Fixtures/FlecsWorldFixture.h" 7 | #include "Transforms/FlecsTransformComponents.h" 8 | 9 | BEGIN_DEFINE_SPEC(FComponentCollectionTestSpec, 10 | "Flecs.Components.Collections", 11 | EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter); 12 | 13 | FFlecsTestFixture Fixture; 14 | 15 | END_DEFINE_SPEC(FComponentCollectionTestSpec); 16 | 17 | void FComponentCollectionTestSpec::Define() 18 | { 19 | BeforeEach([this]() 20 | { 21 | UFlecsTransformModule* Module = NewObject(); 22 | Fixture.SetUp( nullptr, { Module } ); 23 | }); 24 | 25 | AfterEach([this]() 26 | { 27 | Fixture.TearDown(); 28 | }); 29 | 30 | Describe("Component Collection Basic", [this]() 31 | { 32 | It("Should be able to add a Component Collection", [this]() 33 | { 34 | FFlecsEntityHandle TestEntity = Fixture.FlecsWorld->CreateEntity(); 35 | 36 | UFlecsTransform3dCollection* Collection = NewObject(); 37 | Collection->Location = FFlecsLocationComponent(FVector(1.f, 2.f, 3.f)); 38 | TestEntity.AddCollection(Collection); 39 | 40 | TestTrue("Entity has Location Component", TestEntity.Has()); 41 | TestTrue("Entity has Rotation Component", TestEntity.Has()); 42 | TestTrue("Entity has Scale Component", TestEntity.Has()); 43 | 44 | TestEqual("Entity Location Component is correct", 45 | TestEntity.Get().Location, FVector(1.f, 2.f, 3.f)); 46 | }); 47 | }); 48 | } 49 | 50 | #endif // WITH_AUTOMATION_TESTS 51 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Components/Enums/ComponentTestEnums.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ComponentTestEnums.generated.h" 7 | 8 | enum class ETestEnum : uint8 9 | { 10 | None, 11 | One, 12 | Two, 13 | Three 14 | }; // enum class ETestEnum 15 | 16 | UENUM() 17 | enum class ETestEnum_UENUM : uint8 18 | { 19 | None, 20 | One, 21 | Two, 22 | Three 23 | }; // enum class ETestEnum 24 | 25 | UENUM() 26 | enum class ETestEnum_SparseUENUM : uint8 27 | { 28 | None, 29 | One, 30 | Two, 31 | Three, 32 | Five = 5, 33 | Ten = 10, 34 | }; // enum class ETestEnum -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Components/Strings/StringComponentTests.spec.cpp: -------------------------------------------------------------------------------- 1 | #if WITH_AUTOMATION_TESTS 2 | 3 | #include "Misc/AutomationTest.h" 4 | #include "Fixtures/FlecsWorldFixture.h" 5 | 6 | 7 | BEGIN_DEFINE_SPEC(FStringComponentTestsSpec, 8 | "Flecs.Components.Strings", 9 | EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter); 10 | 11 | FFlecsTestFixture Fixture; 12 | 13 | END_DEFINE_SPEC(FStringComponentTestsSpec); 14 | 15 | void FStringComponentTestsSpec::Define() 16 | { 17 | FLECS_FIXTURE_LIFECYCLE(Fixture); 18 | 19 | Describe("String Component", [this] 20 | { 21 | It("Should be able to add a string component to an entity", [this] 22 | { 23 | FFlecsEntityHandle TestEntity = Fixture.FlecsWorld->CreateEntity(); 24 | TestEntity.Set(FString(TEXT("Hello, World!"))); 25 | 26 | FString TestSerialization = TestEntity.ToJson(); 27 | }); 28 | 29 | It("Should be able to add a FName component to an entity", [this] 30 | { 31 | FFlecsEntityHandle TestEntity = Fixture.FlecsWorld->CreateEntity(); 32 | TestEntity.Set(FName(TEXT("Hello, World!"))); 33 | 34 | FString TestSerialization = TestEntity.ToJson(); 35 | }); 36 | 37 | It("Should be able to add a FText component to an entity", [this] 38 | { 39 | FFlecsEntityHandle TestEntity = Fixture.FlecsWorld->CreateEntity(); 40 | TestEntity.Set(FText::FromString(TEXT("Hello, World!"))); 41 | 42 | FString TestSerialization = TestEntity.ToJson(); 43 | }); 44 | }); 45 | } 46 | 47 | #endif // WITH_AUTOMATION_TESTS 48 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Components/Structs/ComponentTestStructs.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ComponentTestStructs.generated.h" 7 | 8 | struct FTestComponent_RegisterComponentTest 9 | { 10 | int32 Value; 11 | }; // struct FTestComponent 12 | 13 | USTRUCT() 14 | struct FUStructTestComponent_RegisterComponentTest 15 | { 16 | GENERATED_BODY() 17 | 18 | UPROPERTY() 19 | int32 Value; 20 | }; // struct FUStructTestComponent 21 | 22 | USTRUCT() 23 | struct FUStructTestComponent_Inherited : public FUStructTestComponent_RegisterComponentTest 24 | { 25 | GENERATED_BODY() 26 | 27 | UPROPERTY() 28 | int32 Value2; 29 | }; // struct FUStructTestComponent_Inherited 30 | 31 | USTRUCT() 32 | struct FUStructTestComponent_TagUSTRUCT 33 | { 34 | GENERATED_BODY() 35 | }; // struct FUStructTestComponent_TagUSTRUCT 36 | 37 | USTRUCT() 38 | struct FUStructTestComponent_NonTagUSTRUCT 39 | { 40 | GENERATED_BODY() 41 | 42 | UPROPERTY() 43 | bool bTest = false; 44 | }; // struct FUStructTestComponent_NonTagUSTRUCT 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Components/UObjectComponent/FlecsUObjectComponentTestObject.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/Object.h" 7 | #include "FlecsUObjectComponentTestObject.generated.h" 8 | 9 | UCLASS() 10 | class UNREALFLECSTESTS_API UFlecsUObjectComponentTestObject : public UObject 11 | { 12 | GENERATED_BODY() 13 | }; // class UFlecsUObjectComponentTestObject 14 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Components/UObjectComponent/UObjectTests.spec.cpp: -------------------------------------------------------------------------------- 1 |  2 | #if WITH_AUTOMATION_TESTS 3 | 4 | #include "FlecsUObjectComponentTestObject.h" 5 | #include "Misc/AutomationTest.h" 6 | #include "Fixtures/FlecsWorldFixture.h" 7 | #include "Kismet/KismetSystemLibrary.h" 8 | 9 | BEGIN_DEFINE_SPEC(FUObjectTestsSpec, 10 | "Flecs.Components.UObjectComponent", 11 | EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter); 12 | 13 | FFlecsTestFixture Fixture; 14 | 15 | END_DEFINE_SPEC(FUObjectTestsSpec); 16 | 17 | void FUObjectTestsSpec::Define() 18 | { 19 | FLECS_FIXTURE_LIFECYCLE(Fixture); 20 | } 21 | 22 | #endif // WITH_AUTOMATION_TESTS 23 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Entities/DefaultEntities/DefaultEntityDefinitions.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "DefaultEntityDefinitions.h" 4 | 5 | DEFINE_DEFAULT_ENTITY(TestEntityOption, 6000 + FLECS_HI_COMPONENT_ID, [](flecs::entity InEntity) 6 | { 7 | }); 8 | 9 | DEFINE_DEFAULT_ENTITY(TestEntityOption2, 6001 + FLECS_HI_COMPONENT_ID, [](flecs::entity InEntity) 10 | { 11 | InEntity.add(flecs::Trait); 12 | }); 13 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Entities/DefaultEntities/DefaultEntityDefinitions.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Entities/FlecsDefaultEntityEngineSubsystem.h" 7 | 8 | DECLARE_DEFAULT_ENTITY(TestEntityOption); 9 | DECLARE_DEFAULT_ENTITY(TestEntityOption2); 10 | 11 | 12 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Entities/Prefabs/EntityRecordTestStructs.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "EntityRecordTestStructs.generated.h" 7 | 8 | USTRUCT() 9 | struct FTestStruct_EntityRecord 10 | { 11 | GENERATED_BODY() 12 | 13 | public: 14 | UPROPERTY() 15 | int32 IntegerValue; 16 | }; // struct FTestStruct_EntityRecord 17 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/OSAPI/OS_API_Tests.spec.cpp: -------------------------------------------------------------------------------- 1 |  2 | #if WITH_AUTOMATION_TESTS 3 | 4 | #include "flecs.h" 5 | 6 | #include "Misc/AutomationTest.h" 7 | #include "HAL/PlatformProcess.h" 8 | #include "Worlds/FlecsOSAPI.h" 9 | 10 | BEGIN_DEFINE_SPEC(FFlecsOSApiTestsSpec, 11 | "Flecs.API.OS-API.Tests", 12 | EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter); 13 | 14 | END_DEFINE_SPEC(FFlecsOSApiTestsSpec); 15 | 16 | void FFlecsOSApiTestsSpec::Define() 17 | { 18 | Describe("Memory", [this] 19 | { 20 | It("Should Allocate Memory", [this] 21 | { 22 | void* Memory = ecs_os_malloc(10); 23 | TestNotNull("Memory should not be null", Memory); 24 | ecs_os_free(Memory); 25 | Memory = nullptr; 26 | }); 27 | 28 | It("Should Reallocate Memory", [this] 29 | { 30 | void* Memory = ecs_os_malloc(10); 31 | TestNotNull("Memory should not be null", Memory); 32 | void* NewMemory = ecs_os_realloc(Memory, 20); 33 | TestNotNull("Memory should not be null", NewMemory); 34 | ecs_os_free(NewMemory); 35 | NewMemory = nullptr; 36 | }); 37 | }); 38 | 39 | Describe("Time", [this] 40 | { 41 | It("Should Get Time Now", [this] 42 | { 43 | const uint32_t Time = ecs_os_now(); 44 | TestTrue("Time should be greater than 0", Time > 0); 45 | }); 46 | 47 | It("Should Sleep 10000 nanosecs", [this] 48 | { 49 | ecs_time_t Time = {}; 50 | ecs_time_measure(&Time); 51 | ecs_os_sleep(0, 10000); 52 | const double Elapsed = ecs_time_measure(&Time); 53 | TestTrue("Elapsed time should be greater than 0", Elapsed > 0); 54 | }); 55 | }); 56 | } 57 | 58 | #endif // WITH_AUTOMATION_TESTS 59 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/Queries/Definitions/QueryDefinitionTestComponents.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "QueryDefinitionTestComponents.generated.h" 7 | 8 | USTRUCT() 9 | struct FTestStruct_QueryDefinitions 10 | { 11 | GENERATED_BODY() 12 | }; // struct FTestStruct_QueryDefinitions 13 | 14 | -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/Tests/World/FlecsWorldLifecycleTests.spec.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #if WITH_AUTOMATION_TESTS 4 | 5 | #include "Misc/AutomationTest.h" 6 | #include "Fixtures/FlecsWorldFixture.h" 7 | 8 | BEGIN_DEFINE_SPEC(FFlecsWorldLifecycleTestsSpec, "Flecs.World.LifecycleTests", 9 | EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter) 10 | 11 | FFlecsTestFixture Fixture; 12 | 13 | END_DEFINE_SPEC(FFlecsWorldLifecycleTestsSpec) 14 | 15 | void FFlecsWorldLifecycleTestsSpec::Define() 16 | { 17 | FLECS_FIXTURE_LIFECYCLE(Fixture); 18 | 19 | Describe("World Creation", [this]() 20 | { 21 | It("Should create a valid Flecs world", [this]() 22 | { 23 | TestTrue("Flecs world is valid", Fixture.FlecsWorld.IsValid()); 24 | }); 25 | }); 26 | 27 | Describe("World Ptr Tests", [this]() 28 | { 29 | It("Should be able to convert flecs::world to UFlecsWorld using ToFlecsWorld Function", 30 | [this]() 31 | { 32 | TestTrue("Flecs world is valid", Fixture.FlecsWorld.IsValid()); 33 | TestNotNull("Flecs world singleton is valid", 34 | Unreal::Flecs::ToFlecsWorld(Fixture.FlecsWorld->World)); 35 | }); 36 | }); 37 | } 38 | 39 | #endif // WITH_AUTOMATION_TESTS -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/UnrealFlecsTests.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class UnrealFlecsTests : ModuleRules 4 | { 5 | public UnrealFlecsTests(ReadOnlyTargetRules Target) : base(Target) 6 | { 7 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 8 | 9 | PrivateIncludePaths.AddRange( 10 | new string[] 11 | { 12 | ModuleDirectory 13 | } 14 | ); 15 | 16 | PublicDependencyModuleNames.AddRange( 17 | new string[] 18 | { 19 | "Core", 20 | "StructUtils", 21 | "SolidMacros", 22 | "FlecsLibrary", 23 | "UnrealFlecs", 24 | "UnrealEd", 25 | "AutomationUtils", 26 | "GameplayTags" 27 | } 28 | ); 29 | 30 | PrivateDependencyModuleNames.AddRange( 31 | new string[] 32 | { 33 | "CoreUObject", 34 | "Engine", 35 | "Slate", 36 | "SlateCore", 37 | } 38 | ); 39 | } 40 | } -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/UnrealFlecsTests.cpp: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #include "UnrealFlecsTests.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FUnrealFlecsTestsModule" 6 | 7 | void FUnrealFlecsTestsModule::StartupModule() 8 | { 9 | 10 | } 11 | 12 | void FUnrealFlecsTestsModule::ShutdownModule() 13 | { 14 | 15 | } 16 | 17 | #undef LOCTEXT_NAMESPACE 18 | 19 | IMPLEMENT_MODULE(FUnrealFlecsTestsModule, UnrealFlecsTests) -------------------------------------------------------------------------------- /Source/UnrealFlecsTests/UnrealFlecsTests.h: -------------------------------------------------------------------------------- 1 | // Elie Wiese-Namir © 2025. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class FUnrealFlecsTestsModule : public IModuleInterface 9 | { 10 | public: 11 | virtual void StartupModule() override; 12 | virtual void ShutdownModule() override; 13 | }; // class FUnrealFlecsTestsModule 14 | -------------------------------------------------------------------------------- /UnrealFlecs.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "0.1", 5 | "FriendlyName": "UnrealFlecs", 6 | "Description": "", 7 | "Category": "ECS", 8 | "CreatedBy": "Reddy-dev", 9 | "CreatedByURL": "", 10 | "Copyright": "Elie Wiese-Namir © 2025. All Rights Reserved.", 11 | "DocsURL": "https://www.flecs.dev/", 12 | "MarketplaceURL": "", 13 | "CanContainContent": true, 14 | "IsBetaVersion": true, 15 | "IsExperimentalVersion": true, 16 | "Installed": false, 17 | "Modules": [ 18 | { 19 | "Name": "FlecsLibrary", 20 | "Type": "Runtime", 21 | "LoadingPhase": "PreDefault" 22 | }, 23 | { 24 | "Name": "UnrealFlecs", 25 | "Type": "Runtime", 26 | "LoadingPhase": "Default" 27 | }, 28 | { 29 | "Name": "UnrealFlecsEditor", 30 | "Type": "Editor", 31 | "LoadingPhase": "Default" 32 | }, 33 | { 34 | "Name": "UnrealFlecsTests", 35 | "Type": "UncookedOnly", 36 | "LoadingPhase": "PostDefault" 37 | } 38 | ], 39 | "Plugins": [ 40 | { 41 | "Name": "SolidMacros", 42 | "Enabled": true 43 | }, 44 | { 45 | "Name": "StructUtils", 46 | "Enabled": true 47 | }, 48 | { 49 | "Name": "AutomationUtils", 50 | "Enabled": true 51 | }, 52 | { 53 | "Name": "FunctionalTestingEditor", 54 | "Enabled": true 55 | }, 56 | { 57 | "Name": "Gauntlet", 58 | "Enabled": true 59 | } 60 | ], 61 | "SupportURL": "", 62 | "SupportedTargetPlatforms": [ 63 | "Win64" 64 | ] 65 | } --------------------------------------------------------------------------------