Refactor so GameModeBase is the runnable

This commit is contained in:
2023-06-22 15:17:49 -04:00
parent c6558ac0b4
commit 9a85092afb
7 changed files with 83 additions and 91 deletions

View File

@@ -6,23 +6,33 @@
#include "GameFramework/GameModeBase.h"
#include "enginewrapper.hpp"
#include "engineutil.hpp"
#include "WorkerRunnable.hpp"
#include "IntegrationGameModeBase.generated.h"
/**
*
*/
UCLASS()
class INTEGRATION_API AIntegrationGameModeBase : public AGameModeBase
class INTEGRATION_API AIntegrationGameModeBase : public AGameModeBase, public FRunnable
{
GENERATED_BODY()
public:
AIntegrationGameModeBase();
~AIntegrationGameModeBase();
virtual void BeginPlay() override;
virtual void Tick(float) override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason);
// Thread start and shutdown.
void LaunchThread();
void WaitForThread();
// Methods of FRunnable, for the thread to use.
virtual bool Init() override;
virtual uint32 Run() override;
virtual void Stop() override;
// Return true if luprex was successfully initialized.
inline bool luprex_initialized() {
return Luprex.play_initialize != nullptr;
}
@@ -31,16 +41,17 @@ public:
UFUNCTION(BlueprintImplementableEvent)
void ConsoleSetOutput(const FString& text);
// This is called by the GUI whenever the user hits enter.
UFUNCTION(BlueprintCallable)
void ConsoleSendInput(const FString& text);
void HandleConsoleOutput();
void WaitForWorkerThread();
// Refresh the console output.
FWorkerRunnable* Worker;
// The worker thread is responsible for networking and event_update
FRunnableThread* Thread;
bool ThreadStopRequested;
engineutil::ConsoleOutput ConsoleOutput;
static EngineWrapper Luprex;
float EngineSeconds;