2023-06-08 17:10:14 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "GameFramework/GameModeBase.h"
|
|
|
|
|
#include "enginewrapper.hpp"
|
|
|
|
|
#include "engineutil.hpp"
|
2023-09-02 01:33:11 -04:00
|
|
|
#include "TangibleManager.h"
|
2023-06-23 16:27:23 -04:00
|
|
|
#include "LuprexSockets.hpp"
|
2023-06-09 14:36:47 -04:00
|
|
|
#include "IntegrationGameModeBase.generated.h"
|
2023-06-08 17:10:14 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
UCLASS()
|
2023-06-22 15:17:49 -04:00
|
|
|
class INTEGRATION_API AIntegrationGameModeBase : public AGameModeBase, public FRunnable
|
2023-06-08 17:10:14 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
2023-06-09 14:36:47 -04:00
|
|
|
AIntegrationGameModeBase();
|
2023-06-22 15:17:49 -04:00
|
|
|
~AIntegrationGameModeBase();
|
2023-06-08 17:10:14 -04:00
|
|
|
virtual void BeginPlay() override;
|
|
|
|
|
virtual void Tick(float) override;
|
2023-06-09 16:47:46 -04:00
|
|
|
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason);
|
2023-06-08 17:10:14 -04:00
|
|
|
|
2023-06-23 16:27:23 -04:00
|
|
|
// Delete all the state created in BeginPlay. That
|
|
|
|
|
// includes: the Luprex engine, the thread, and the socket state.
|
|
|
|
|
void ResetToInitialState();
|
2023-06-22 15:17:49 -04:00
|
|
|
|
2023-06-23 12:45:23 -04:00
|
|
|
// Method of FRunnable, called by the Luprex thread.
|
2023-06-22 15:17:49 -04:00
|
|
|
virtual uint32 Run() override;
|
2023-06-08 17:10:14 -04:00
|
|
|
|
|
|
|
|
// Set the entire contents of the console output box.
|
|
|
|
|
UFUNCTION(BlueprintImplementableEvent)
|
|
|
|
|
void ConsoleSetOutput(const FString& text);
|
|
|
|
|
|
2023-06-22 15:17:49 -04:00
|
|
|
// This is called by the GUI whenever the user hits enter.
|
2023-06-08 17:10:14 -04:00
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
void ConsoleSendInput(const FString& text);
|
|
|
|
|
|
2023-08-29 19:36:37 -04:00
|
|
|
// The blueprint class TangibleActor
|
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = TangibleClasses)
|
|
|
|
|
TSubclassOf<AActor> ClassTangibleActor;
|
|
|
|
|
|
2023-06-23 12:45:23 -04:00
|
|
|
// Transfer console output from the Luprex engine to unreal.
|
|
|
|
|
void HandleLuprexConsoleOutput();
|
|
|
|
|
|
2023-09-02 01:39:35 -04:00
|
|
|
UPROPERTY()
|
|
|
|
|
FTangibleManager TangibleManager;
|
2023-08-29 20:05:10 -04:00
|
|
|
|
2023-06-23 12:45:23 -04:00
|
|
|
// This stores the entire text currently visible in the console.
|
|
|
|
|
engineutil::ConsoleOutput ConsoleOutput;
|
2023-06-08 17:10:14 -04:00
|
|
|
|
2023-06-23 12:45:23 -04:00
|
|
|
// The worker thread.
|
|
|
|
|
FRunnableThread *Thread;
|
2023-06-09 16:47:46 -04:00
|
|
|
|
2023-06-23 12:45:23 -04:00
|
|
|
// Used to tell the worker thread to stop.
|
2023-06-22 15:17:49 -04:00
|
|
|
bool ThreadStopRequested;
|
|
|
|
|
|
2023-06-23 12:45:23 -04:00
|
|
|
// 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;
|
|
|
|
|
|
2023-06-23 16:27:23 -04:00
|
|
|
// The Luprex wrapper and engine. MUST CLAIM LuprexMutex.
|
|
|
|
|
EngineWrapper Luprex;
|
|
|
|
|
|
|
|
|
|
// Luprex socket system. Aside from construction, only touched by Luprex thread.
|
|
|
|
|
TUniquePtr<FLpxSockets> Sockets;
|
|
|
|
|
|
|
|
|
|
// Amount of elapsed time.
|
2023-06-08 17:10:14 -04:00
|
|
|
float EngineSeconds;
|
2023-06-23 12:45:23 -04:00
|
|
|
|
|
|
|
|
// When do we next trigger the thread event (relative to EngineSeconds).
|
|
|
|
|
float NextThreadTrigger;
|
2023-06-08 17:10:14 -04:00
|
|
|
};
|