Skip to content

Commit 216845b

Browse files
committed
feat: refactor to use new ecsact si wasm header api
1 parent c5e73be commit 216845b

File tree

6 files changed

+35
-25
lines changed

6 files changed

+35
-25
lines changed

Source/Ecsact/Ecsact.Build.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Ecsact(ReadOnlyTargetRules Target) : base(Target) {
6565
"ECSACT_META_API_LOAD_AT_RUNTIME",
6666
"ECSACT_SERIALIZE_API_LOAD_AT_RUNTIME",
6767
"ECSACT_STATIC_API_LOAD_AT_RUNTIME",
68-
"ECSACTSI_WASM_API_LOAD_AT_RUNTIME",
68+
"ECSACT_SI_WASM_API_LOAD_AT_RUNTIME",
6969
});
7070
PrivateDefinitions.AddRange(new string[] {
7171
"ECSACT_CORE_API_EXPORT",
@@ -74,7 +74,7 @@ public Ecsact(ReadOnlyTargetRules Target) : base(Target) {
7474
"ECSACT_META_API_EXPORT",
7575
"ECSACT_SERIALIZE_API_EXPORT",
7676
"ECSACT_STATIC_API_EXPORT",
77-
"ECSACTSI_WASM_API_EXPORT",
77+
"ECSACT_SI_WASM_API_EXPORT",
7878
});
7979

8080
var EcsactSources = GetEcsactSources();

Source/Ecsact/Public/EcsactUnreal/Ecsact.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "Misc/Paths.h"
88
#include "EcsactUnreal/EcsactAsyncRunner.h"
99
#include "ecsact/runtime.h"
10-
#include "ecsact/wasm.h"
10+
#include "ecsact/si/wasm.h"
1111
#include "Engine/World.h"
1212

1313
#define LOCTEXT_NAMESPACE "FEcsactModule"
@@ -16,7 +16,7 @@ DEFINE_LOG_CATEGORY(Ecsact);
1616

1717
#define INIT_ECSACT_API_FN(fn, UNUSED_PARAM) decltype(fn) fn = nullptr
1818
FOR_EACH_ECSACT_API_FN(INIT_ECSACT_API_FN, UNUSED_PARAM);
19-
FOR_EACH_ECSACTSI_WASM_API_FN(INIT_ECSACT_API_FN, UNUSED_PARAM);
19+
FOR_EACH_ECSACT_SI_WASM_API_FN(INIT_ECSACT_API_FN, UNUSED_PARAM);
2020
#undef INIT_ECSACT_API_FN
2121

2222
FEcsactModule* FEcsactModule::Self = nullptr;

Source/Ecsact/Public/EcsactUnreal/EcsactRunner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ auto UEcsactRunner::OnEntityCreatedRaw(
183183
) -> void {
184184
auto self = static_cast<ThisClass*>(callback_user_data);
185185

186+
UE_LOG(Ecsact, Error, TEXT("OnEntityCreatedRaw"));
187+
186188
auto create_callback =
187189
self->CreateEntityCallbacks.Find(placeholder_entity_id);
188190
if(create_callback) {

Source/Ecsact/Public/EcsactUnreal/EcsactSyncRunner.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
#include "EcsactUnreal/EcsactUnrealExecutionOptions.h"
44
#include "EcsactUnreal/EcsactExecution.h"
55
#include "ecsact/runtime/core.h"
6-
#include "ecsact/wasm.h"
6+
#include "ecsact/si/wasm.h"
7+
8+
UEcsactSyncRunner::UEcsactSyncRunner() : Super() {
9+
}
710

811
auto UEcsactSyncRunner::StreamImpl(
912
ecsact_entity_id Entity,
@@ -45,18 +48,21 @@ auto UEcsactSyncRunner::Tick(float DeltaTime) -> void {
4548
}
4649

4750
if(registry_id != ECSACT_INVALID_ID(registry)) {
48-
ecsact_execution_options* exec_opts = nullptr;
49-
if(ExecutionOptions != nullptr && ExecutionOptions->IsNotEmpty()) {
50-
exec_opts = ExecutionOptions->GetCPtr();
51-
}
52-
5351
if(ecsact_execute_systems) {
54-
auto err =
55-
ecsact_execute_systems(registry_id, 1, exec_opts, GetEventsCollector());
52+
ecsact_execution_options* exec_opts = nullptr;
53+
if(ExecutionOptions != nullptr && ExecutionOptions->IsNotEmpty()) {
54+
exec_opts = ExecutionOptions->GetCPtr();
55+
}
56+
auto err = ecsact_execute_systems( //
57+
registry_id,
58+
1,
59+
exec_opts,
60+
GetEventsCollector()
61+
);
5662
if(err != ECSACT_EXEC_SYS_OK) {
5763
UE_LOG(Ecsact, Error, TEXT("Ecsact execution failed"));
5864
}
59-
if(ExecutionOptions) {
65+
if(ExecutionOptions != nullptr) {
6066
ExecutionOptions->Clear();
6167
}
6268
} else {
@@ -68,23 +74,23 @@ auto UEcsactSyncRunner::Tick(float DeltaTime) -> void {
6874
}
6975
}
7076

71-
if(ecsactsi_wasm_consume_logs != nullptr) {
72-
ecsactsi_wasm_consume_logs(
77+
if(ecsact_si_wasm_consume_logs != nullptr) {
78+
ecsact_si_wasm_consume_logs(
7379
[](
74-
ecsactsi_wasm_log_level log_level,
75-
const char* message,
76-
int32_t message_length,
77-
void* user_data
80+
ecsact_si_wasm_log_level log_level,
81+
const char* message,
82+
int32_t message_length,
83+
void* user_data
7884
) {
7985
switch(log_level) {
8086
default:
81-
case ECSACTSI_WASM_LOG_LEVEL_INFO:
87+
case ECSACT_SI_WASM_LOG_LEVEL_INFO:
8288
UE_LOG(Ecsact, Log, TEXT("%.*hs"), message_length, message);
8389
break;
84-
case ECSACTSI_WASM_LOG_LEVEL_WARNING:
90+
case ECSACT_SI_WASM_LOG_LEVEL_WARNING:
8591
UE_LOG(Ecsact, Warning, TEXT("%.*hs"), message_length, message);
8692
break;
87-
case ECSACTSI_WASM_LOG_LEVEL_ERROR:
93+
case ECSACT_SI_WASM_LOG_LEVEL_ERROR:
8894
UE_LOG(Ecsact, Error, TEXT("%.*hs"), message_length, message);
8995
break;
9096
}

Source/Ecsact/Public/EcsactUnreal/EcsactSyncRunner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class ECSACT_API UEcsactSyncRunner : public UEcsactRunner {
2525
// TODO: Put this somewhere good.
2626
ecsact_registry_id registry_id = ECSACT_INVALID_ID(registry);
2727

28+
UEcsactSyncRunner();
29+
2830
auto Tick(float DeltaTime) -> void override;
2931
auto GetStatId() const -> TStatId override;
3032
};

Source/Ecsact/Public/EcsactUnreal/RuntimeLoad.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "EcsactUnreal/Ecsact.h"
44
#include "EcsactUnreal/RuntimeHandle.h"
55
#include "ecsact/runtime.h"
6-
#include "ecsact/wasm.h"
6+
#include "ecsact/si/wasm.h"
77

88
/** @internal - DO NOT USE */
99
#define ECSACT_API_FN_INIT_(fn, UNUSED_PARAM) decltype(fn) fn = nullptr
@@ -65,7 +65,7 @@
6565
return {}; \
6666
} \
6767
FOR_EACH_ECSACT_API_FN(ECSACTAPI_FN_FN_LOAD_); \
68-
FOR_EACH_ECSACTSI_WASM_API_FN(ECSACTAPI_FN_FN_LOAD_); \
68+
FOR_EACH_ECSACT_SI_WASM_API_FN(ECSACTAPI_FN_FN_LOAD_); \
6969
return result; \
7070
})()
7171

@@ -80,7 +80,7 @@
8080
} \
8181
EcsactUnreal::Detail::UnloadPostDisconnect(module, Handle_); \
8282
FOR_EACH_ECSACT_API_FN(ECSACT_API_FN_RESET_); \
83-
FOR_EACH_ECSACTSI_WASM_API_FN(ECSACT_API_FN_RESET_); \
83+
FOR_EACH_ECSACT_SI_WASM_API_FN(ECSACT_API_FN_RESET_); \
8484
EcsactUnreal::Detail::UnloadPostReset(module, Handle_); \
8585
})(Handle)
8686

0 commit comments

Comments
 (0)