Files
integration/Source/Integration/IntegrationGameModeBase.h

69 lines
1.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "enginewrapper.hpp"
#include "engineutil.hpp"
#include "IntegrationGameModeBase.generated.h"
/**
*
*/
UCLASS()
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 shutdown and cleanup. Called by Blueprint thread.
void WaitForThread();
// Method of FRunnable, called by the Luprex thread.
virtual uint32 Run() override;
// Set the entire contents of the console output box.
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);
// Transfer console output from the Luprex engine to unreal.
void HandleLuprexConsoleOutput();
// This stores the entire text currently visible in the console.
engineutil::ConsoleOutput ConsoleOutput;
// The worker thread.
FRunnableThread *Thread;
// Used to tell the worker thread to stop.
bool ThreadStopRequested;
// This event is used to wake up the Luprex thread. Normally,
// this means we want the worker to do one processing step. But
// if ThreadStopRequested is true, it means we want the thread
// to exit.
FEvent* ThreadEvent;
// This critical section guards the use of the EngineWrapper.
FCriticalSection LuprexMutex;
// The Luprex wrapper and engine. You must claim the LuprexMutex
// before touching any of these variables.
static EngineWrapper Luprex;
float EngineSeconds;
// When do we next trigger the thread event (relative to EngineSeconds).
float NextThreadTrigger;
};