2023-06-08 17:10:14 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "GameFramework/GameModeBase.h"
|
2023-09-07 03:57:29 -04:00
|
|
|
#include "lpx-enginewrapper.hpp"
|
2023-09-04 03:27:31 -04:00
|
|
|
#include "DebugPrint.h"
|
2023-09-02 01:33:11 -04:00
|
|
|
#include "TangibleManager.h"
|
2023-09-04 03:27:31 -04:00
|
|
|
#include "LuprexSockets.h"
|
2023-09-04 23:19:10 -04:00
|
|
|
#include "TriggeredTask.h"
|
2023-06-09 14:36:47 -04:00
|
|
|
#include "IntegrationGameModeBase.generated.h"
|
2023-06-08 17:10:14 -04:00
|
|
|
|
2023-09-04 23:19:10 -04:00
|
|
|
|
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-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.
|
2023-09-05 03:20:11 -04:00
|
|
|
void UpdateConsoleOutput();
|
|
|
|
|
|
2023-09-06 23:25:37 -04:00
|
|
|
// Update the tangibles according to what Luprex tells us.
|
|
|
|
|
void UpdateTangibles();
|
|
|
|
|
|
2023-09-05 03:20:11 -04:00
|
|
|
// Trigger the update task, if enough time has passed.
|
|
|
|
|
void MaybeTriggerUpdateTask(float deltaseconds);
|
2023-06-23 12:45:23 -04:00
|
|
|
|
2023-09-04 23:19:10 -04:00
|
|
|
// The run function is called by a background thread
|
|
|
|
|
// to update luprex sockets and update luprex itself.
|
|
|
|
|
virtual uint32 Run() override;
|
|
|
|
|
|
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.
|
2023-09-04 03:21:23 -04:00
|
|
|
FConsoleOutput ConsoleOutput;
|
2023-06-08 17:10:14 -04:00
|
|
|
|
2023-09-03 02:01:32 -04:00
|
|
|
// The Luprex EngineWrapper, with a Mutex to protect it.
|
|
|
|
|
// To access it, construct a FLockedWrapper.
|
|
|
|
|
FLockableWrapper LockableWrapper;
|
2023-06-23 16:27:23 -04:00
|
|
|
|
2023-09-04 23:19:10 -04:00
|
|
|
// This utility runs the luprex update and socket update in a thread.
|
|
|
|
|
FTriggeredTask LuprexUpdateTask;
|
|
|
|
|
|
2023-06-23 16:27:23 -04:00
|
|
|
// Luprex socket system. Aside from construction, only touched by Luprex thread.
|
|
|
|
|
TUniquePtr<FLpxSockets> Sockets;
|
|
|
|
|
|
2023-09-06 23:25:37 -04:00
|
|
|
// True if 'BeginPlay' has been successfully completed.
|
|
|
|
|
//
|
|
|
|
|
bool Playing;
|
|
|
|
|
|
2023-09-12 15:11:47 -04:00
|
|
|
// Amount of elapsed time since BeginPlay.
|
2023-06-08 17:10:14 -04:00
|
|
|
float EngineSeconds;
|
2023-06-23 12:45:23 -04:00
|
|
|
|
2023-09-12 15:11:47 -04:00
|
|
|
// When do we next trigger the thread event.
|
2023-06-23 12:45:23 -04:00
|
|
|
float NextThreadTrigger;
|
2023-09-12 15:11:47 -04:00
|
|
|
|
|
|
|
|
// When do we next rotate the cube.
|
|
|
|
|
float NextRotateCube;
|
2023-06-08 17:10:14 -04:00
|
|
|
};
|