Files
integration/Source/Integration/IntegrationGameModeBase.h
2023-09-04 03:21:23 -04:00

81 lines
2.3 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 "TangibleManager.h"
#include "LuprexSockets.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);
// Delete all the state created in BeginPlay. That
// includes: the Luprex engine, the thread, and the socket state.
void ResetToInitialState();
// 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);
// The blueprint class TangibleActor
UPROPERTY(EditDefaultsOnly, Category = TangibleClasses)
TSubclassOf<AActor> ClassTangibleActor;
// Transfer console output from the Luprex engine to unreal.
void HandleLuprexConsoleOutput(FLockedWrapper &w);
UPROPERTY()
FTangibleManager TangibleManager;
// This stores the entire text currently visible in the console.
FConsoleOutput 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;
// The Luprex EngineWrapper, with a Mutex to protect it.
// To access it, construct a FLockedWrapper.
FLockableWrapper LockableWrapper;
// Luprex socket system. Aside from construction, only touched by Luprex thread.
TUniquePtr<FLpxSockets> Sockets;
// Amount of elapsed time.
float EngineSeconds;
// When do we next trigger the thread event (relative to EngineSeconds).
float NextThreadTrigger;
};