Files
integration/Source/Integration/IntegrationGameModeBase.h

85 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 "DebugPrint.h"
#include "TangibleManager.h"
#include "LuprexSockets.h"
#include "TriggeredTask.h"
#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();
// 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 UpdateConsoleOutput();
// Update the tangibles according to what Luprex tells us.
void UpdateTangibles();
// Trigger the update task, if enough time has passed.
void MaybeTriggerUpdateTask(float deltaseconds);
// The run function is called by a background thread
// to update luprex sockets and update luprex itself.
virtual uint32 Run() override;
UPROPERTY()
FTangibleManager TangibleManager;
// This stores the entire text currently visible in the console.
FConsoleOutput ConsoleOutput;
// The Luprex EngineWrapper, with a Mutex to protect it.
// To access it, construct a FLockedWrapper.
FLockableWrapper LockableWrapper;
// This utility runs the luprex update and socket update in a thread.
FTriggeredTask LuprexUpdateTask;
// Luprex socket system. Aside from construction, only touched by Luprex thread.
TUniquePtr<FLpxSockets> Sockets;
// True if 'BeginPlay' has been successfully completed.
//
bool Playing;
// Amount of elapsed time.
float EngineSeconds;
// When do we next trigger the thread event (relative to EngineSeconds).
float NextThreadTrigger;
};