Skip to content

Commit

Permalink
feat: more async connect disconnect fns
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Oct 9, 2024
1 parent 2135353 commit c43f73a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
12 changes: 12 additions & 0 deletions Source/Ecsact/Public/EcsactUnreal/EcsactRunner.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "EcsactUnreal/EcsactRunner.h"
#include "EcsactUnreal/EcsactAsyncRunnerEvents.h"
#include "EcsactUnreal/EcsactUnrealExecutionOptions.h"
#include "UObject/ObjectMacros.h"
#include "UObject/UObjectIterator.h"
Expand Down Expand Up @@ -45,6 +46,10 @@ auto UEcsactRunner::IsStopped() const -> bool {
return bIsStopped;
}

auto UEcsactRunner::HasAsyncEvents() const -> bool {
return Cast<IEcsactAsyncRunnerEvents>(this) != nullptr;
}

auto UEcsactRunner::Tick(float DeltaTime) -> void {
}

Expand Down Expand Up @@ -177,6 +182,13 @@ auto UEcsactRunner::OnEntityCreatedRaw(
) -> void {
auto self = static_cast<ThisClass*>(callback_user_data);

UE_LOG(
LogTemp,
Warning,
TEXT("Received entity created callback for %i"),
static_cast<int>(entity_id)
);

auto create_callback =
self->CreateEntityCallbacks.Find(placeholder_entity_id);
if(create_callback) {
Expand Down
3 changes: 3 additions & 0 deletions Source/Ecsact/Public/EcsactUnreal/EcsactRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class ECSACT_API UEcsactRunner : public UObject, public FTickableGameObject {
virtual auto Stop() -> void;
virtual auto IsStopped() const -> bool;

UFUNCTION(BlueprintPure)
bool HasAsyncEvents() const;

auto Tick(float DeltaTime) -> void override;
auto GetStatId() const -> TStatId override;
auto IsTickable() const -> bool override;
Expand Down
13 changes: 11 additions & 2 deletions Source/Ecsact/Public/EcsactUnreal/EcsactRunnerSubsystem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "EcsactRunnerSubsystem.h"
#include "EcsactRunner.h"

auto UEcsactRunnerSubsystem::InitComponentRaw(
ecsact_entity_id EntityId,
Expand Down Expand Up @@ -29,10 +30,18 @@ auto UEcsactRunnerSubsystem::GetRunner() const -> const class UEcsactRunner* {
return OwningRunner;
}

auto UEcsactRunnerSubsystem::AsyncConnect_Implementation() -> void {
auto UEcsactRunnerSubsystem::GetWorld() const -> class UWorld* {
if(OwningRunner != nullptr) {
return OwningRunner->GetWorld();
} else {
return nullptr;
}
}

auto UEcsactRunnerSubsystem::AsyncDisconnect_Implementation() -> void {
auto UEcsactRunnerSubsystem::AsyncConnected_Implementation() -> void {
}

auto UEcsactRunnerSubsystem::AsyncDisconnected_Implementation() -> void {
}

auto UEcsactRunnerSubsystem::RunnerStart_Implementation(
Expand Down
10 changes: 6 additions & 4 deletions Source/Ecsact/Public/EcsactUnreal/EcsactRunnerSubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ECSACT_API UEcsactRunnerSubsystem : public UObject {
auto GetRunner() const -> const class UEcsactRunner*;

public:
auto GetWorld() const -> class UWorld* override;

UFUNCTION(BlueprintNativeEvent, Category = "Ecsact Runner")
void RunnerStart(class UEcsactRunner* Runner);

Expand All @@ -50,19 +52,19 @@ class ECSACT_API UEcsactRunnerSubsystem : public UObject {
* NOTE: For 'async' runners only
*/
UFUNCTION(BlueprintNativeEvent, Category = "Ecsact Runner")
void AsyncConnect();
void AsyncConnected();

virtual auto AsyncConnect_Implementation() -> void;
virtual auto AsyncConnected_Implementation() -> void;

/**
* Called when an ecsact_async_disconnect is called or if an error that
* triggers a disconnect occurs.
* NOTE: For 'async' runners only
*/
UFUNCTION(BlueprintNativeEvent, Category = "Ecsact Runner")
void AsyncDisconnect();
void AsyncDisconnected();

virtual auto AsyncDisconnect_Implementation() -> void;
virtual auto AsyncDisconnected_Implementation() -> void;

UFUNCTION(BlueprintNativeEvent, Category = "Ecsact Runner")
void EntityCreated(int32 Entity);
Expand Down

0 comments on commit c43f73a

Please sign in to comment.