11#include " EcsactUnreal/EcsactUnrealExecutionOptions.h"
2+ #include " EcsactUnreal/Ecsact.h"
23#include " ecsact/runtime/common.h"
34
45using CreateEntityBuilder = UEcsactUnrealExecutionOptions::CreateEntityBuilder;
@@ -41,6 +42,54 @@ auto UEcsactUnrealExecutionOptions::Clear() -> void {
4142 ExecOpts = {};
4243}
4344
45+ #ifdef WITH_EDITORONLY_DATA
46+ auto UEcsactUnrealExecutionOptions::DebugLog () const -> void {
47+ if (!IsNotEmpty ()) {
48+ UE_LOG (Ecsact, Warning, TEXT (" (Empty Ecsact Execution Options)" ));
49+ return ;
50+ }
51+
52+ UE_LOG (Ecsact, Log, TEXT (" == Ecsact Execution Options ==" ));
53+ UE_LOG (Ecsact, Log, TEXT (" \t Actions Length: %i" ), ExecOpts.actions_length );
54+ for (auto i = 0 ; ExecOpts.actions_length > i; ++i) {
55+ UE_LOG (
56+ Ecsact,
57+ Log,
58+ TEXT (" \t\t ActionId: %i" ),
59+ ExecOpts.actions [i].action_id
60+ );
61+ }
62+ UE_LOG (
63+ Ecsact,
64+ Log,
65+ TEXT (" \t Create Entities Length: %i" ),
66+ ExecOpts.create_entities_length
67+ );
68+ for (auto i = 0 ; ExecOpts.create_entities_length > i; ++i) {
69+ UE_LOG (
70+ Ecsact,
71+ Log,
72+ TEXT (" \t\t PlaceholderId: %i" ),
73+ ExecOpts.create_entities [i]
74+ );
75+ for (auto ci = 0 ; ExecOpts.create_entities_components_length [i] > ci; ++ci) {
76+ auto comp_count = ExecOpts.create_entities_components_length [i];
77+ auto comps = ExecOpts.create_entities_components [ci];
78+ UE_LOG (
79+ Ecsact,
80+ Log,
81+ TEXT (" \t\t Create Entity Component Count: %i" ),
82+ comp_count
83+ );
84+ for (auto cci = 0 ; cci > comp_count; ++cci) {
85+ auto comp = comps[cci];
86+ UE_LOG (Ecsact, Log, TEXT (" \t\t\t ComponentId: %i" ), comp.component_id );
87+ }
88+ }
89+ }
90+ }
91+ #endif
92+
4493auto UEcsactUnrealExecutionOptions::CreateEntity (
4594 ecsact_placeholder_entity_id PlaceholderId
4695) -> CreateEntityBuilder {
@@ -49,29 +98,50 @@ auto UEcsactUnrealExecutionOptions::CreateEntity(
4998
5099CreateEntityBuilder::CreateEntityBuilder (
51100 UEcsactUnrealExecutionOptions* Owner,
52- ecsact_placeholder_entity_id PlacerholderId
101+ ecsact_placeholder_entity_id PlaceholderId
53102)
54103 : bValid(true ), Owner(Owner), PlaceholderId(PlaceholderId) {
55104}
56105
57106CreateEntityBuilder::CreateEntityBuilder (CreateEntityBuilder&& Other) {
58107 bValid = Other.bValid ;
59108 Owner = Other.Owner ;
109+ PlaceholderId = Other.PlaceholderId ;
60110 ComponentList = std::move (Other.ComponentList );
61111
62112 Other.bValid = false ;
63113 Other.Owner = nullptr ;
114+ Other.PlaceholderId = {};
64115 Other.ComponentList = {};
65116}
66117
118+ auto CreateEntityBuilder::operator =(CreateEntityBuilder&& Other
119+ ) -> CreateEntityBuilder& {
120+ bValid = Other.bValid ;
121+ Owner = Other.Owner ;
122+ PlaceholderId = Other.PlaceholderId ;
123+ ComponentList = std::move (Other.ComponentList );
124+
125+ Other.bValid = false ;
126+ Other.Owner = nullptr ;
127+ Other.PlaceholderId = {};
128+ Other.ComponentList = {};
129+ return *this ;
130+ }
131+
67132CreateEntityBuilder::~CreateEntityBuilder () {
68- if (bValid && Owner ) {
133+ if (bValid) {
69134 Finish ();
70135 }
71136}
72137
73138auto CreateEntityBuilder::Finish () -> void {
74- if (!bValid || !Owner) {
139+ if (!bValid) {
140+ return ;
141+ }
142+
143+ if (!Owner) {
144+ UE_LOG (Ecsact, Error, TEXT (" Cannot create entity - Runner not valid" ));
75145 return ;
76146 }
77147
0 commit comments