Skip to content

Commit 039dbfb

Browse files
committed
finish context_add, beginning work on dynamic library calls
1 parent b683013 commit 039dbfb

File tree

8 files changed

+233
-33
lines changed

8 files changed

+233
-33
lines changed

WORKSPACE.bazel

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ http_archive(
2525

2626
http_file(
2727
name = "ecsact_cli_windows",
28-
url = "https://github.com/ecsact-dev/ecsact_cli/releases/download/0.1.1/ecsact_0.1.1_windows_x64.exe",
29-
executable = True,
3028
downloaded_file_path = "ecsact.exe",
29+
executable = True,
30+
sha256 = "b61adc4d12d571d16996db6e5c5ad5ee7b150fb203012c535d899b03e28244aa",
31+
url = "https://github.com/ecsact-dev/ecsact_cli/releases/download/0.1.1/ecsact_0.1.1_windows_x64.exe",
3132
)
3233

3334
http_file(
3435
name = "ecsact_cli_linux",
35-
url = "https://github.com/ecsact-dev/ecsact_cli/releases/download/0.1.1/ecsact_0.1.1_linux_x64",
36-
executable = True,
3736
downloaded_file_path = "ecsact",
37+
executable = True,
38+
sha256 = "b87b1e2169dfebe9777b89736d5ddac7a9ab84bc10aec9c28231eb52567a4626",
39+
url = "https://github.com/ecsact-dev/ecsact_cli/releases/download/0.1.1/ecsact_0.1.1_linux_x64",
3840
)
3941

4042
http_archive(

ecsact/entt/detail/system_execution_context.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ constexpr auto underlying_assoc_index(assoc_index n) -> unsigned {
3030
} // namespace ecsact::entt
3131

3232
struct ecsact_system_execution_context {
33-
ecsact_system_like_id id;
34-
33+
ecsact_system_like_id id;
3534
ecsact::entt::entity_id entity;
35+
::entt::registry* registry = nullptr;
3636

3737
virtual ~ecsact_system_execution_context() = default;
3838

ecsact/entt/wrapper/dynamic.hh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#pragma once
2+
3+
#include <cassert>
4+
#include <type_traits>
5+
#include "entt/entity/registry.hpp"
6+
#include "ecsact/entt/registry_util.hh"
7+
#include "ecsact/entt/error_check.hh"
8+
#include "ecsact/entt/detail/internal_markers.hh"
9+
#include "ecsact/entt/event_markers.hh"
10+
#include "ecsact/entt/detail/system_execution_context.hh"
11+
12+
namespace ecsact::entt::wrapper::dynamic {
13+
14+
template<typename C>
15+
auto context_add(
16+
ecsact_system_execution_context* context,
17+
[[maybe_unused]] ecsact_component_like_id component_id,
18+
const void* component_data
19+
) -> void {
20+
using ecsact::entt::component_added;
21+
using ecsact::entt::component_removed;
22+
using ecsact::entt::detail::pending_add;
23+
24+
assert(ecsact_id_cast<ecsact_component_like_id>(C::id) == component_id);
25+
26+
auto entity = context->entity;
27+
auto& registry = *context->registry;
28+
29+
const C* component = static_cast<const C*>(component_data);
30+
31+
if constexpr(std::is_empty_v<C>) {
32+
registry.template emplace<pending_add<C>>(entity);
33+
} else {
34+
registry.template emplace<pending_add<C>>(entity, *component);
35+
}
36+
37+
if constexpr(!C::transient) {
38+
if(registry.template all_of<component_removed<C>>(entity)) {
39+
registry.template remove<component_removed<C>>(entity);
40+
} else {
41+
registry.template emplace<component_added<C>>(entity);
42+
}
43+
}
44+
}
45+
46+
} // namespace ecsact::entt::wrapper::dynamic

rt_entt_codegen/core/BUILD.bazel

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
33

44
cc_library(
55
name = "core_internal",
6-
visibility = ["//rt_entt_codegen:__pkg__"],
7-
copts = copts,
86
hdrs = ["core.hh"],
7+
copts = copts,
8+
visibility = ["//rt_entt_codegen:__pkg__"],
99
deps = ["//rt_entt_codegen/shared:ecsact_entt_details"],
1010
)
1111

1212
# keep sorted
1313
_CORE_CODEGEN_METHODS = {
1414
"execute_systems": [],
1515
"create_registry": [],
16-
"execute_system_like_template_specializations": [],
16+
"execute_system_like_template_specializations": [
17+
"@com_github_skypjack_entt//:entt",
18+
"@ecsact_rt_entt//:lib",
19+
],
1720
"check_error_template_specializations": [],
1821
}
1922

@@ -34,7 +37,7 @@ _CORE_CODEGEN_METHODS = {
3437

3538
cc_library(
3639
name = "core",
37-
visibility = ["//rt_entt_codegen:__pkg__"],
3840
copts = copts,
41+
visibility = ["//rt_entt_codegen:__pkg__"],
3942
deps = [":core_internal"] + [":{}".format(method) for method in _CORE_CODEGEN_METHODS],
4043
)

0 commit comments

Comments
 (0)