115 lines
3.4 KiB
C++
115 lines
3.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/GameModeBase.h"
|
|
#include "lpx-enginewrapper.hpp"
|
|
#include "DebugPrint.h"
|
|
#include "StringDecoder.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, Category = "Luprex")
|
|
void ConsoleSetOutput(const FString& text);
|
|
|
|
// This is called by the GUI whenever the user hits enter.
|
|
UFUNCTION(BlueprintCallable, Category = "Luprex")
|
|
void ConsoleSendInput(const FString& text);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Luprex")
|
|
int64 GetPlayerId();
|
|
|
|
// Assemble a lua call. To call into lua:
|
|
//
|
|
// * Use LuaCallBegin
|
|
// * Get the lua call buffer.
|
|
// * Add a class name and a function name to the buffer.
|
|
// * Add parameters to the buffer.
|
|
// * Use LuaCallInvoke.
|
|
//
|
|
void LuaCallBegin() { LuaCallBuffer.clear(); }
|
|
FlxStreamBuffer &LuaCallGetBuffer() { return LuaCallBuffer; }
|
|
void LuaCallInvoke(bool background);
|
|
|
|
// Execute a debugging command, typed on the GUI.
|
|
void ExecuteDebuggingCommand(FlxLockedWrapper &w, const FString &fs);
|
|
|
|
// Transfer console output from the Luprex engine to unreal.
|
|
void UpdateConsoleOutput();
|
|
|
|
// Update the tangibles according to what Luprex tells us.
|
|
void UpdateTangibles();
|
|
|
|
// Pre-tick and post-tick functions.
|
|
void OnWorldPreActorTick(UWorld* InWorld, ELevelTick InLevelTick, float InDeltaSeconds);
|
|
void OnWorldPostActorTick(UWorld* InWorld, ELevelTick InLevelTick, float InDeltaSeconds);
|
|
|
|
// The run function is called by a background thread
|
|
// to update luprex sockets and update luprex itself.
|
|
virtual uint32 Run() override;
|
|
|
|
// Get the AIntegrationGameModeBase given any UObject
|
|
// If there is no AIntegrationGameModeBase in that world context, fatal error
|
|
static AIntegrationGameModeBase *GetFromWorld(UWorld *world);
|
|
static AIntegrationGameModeBase *GetFromContext(UObject *context);
|
|
|
|
UPROPERTY()
|
|
UlxTangibleManager *TangibleManager;
|
|
|
|
// This stores the entire text currently visible in the console.
|
|
FlxConsoleOutput ConsoleOutput;
|
|
|
|
// The Luprex EngineWrapper, with a Mutex to protect it.
|
|
// To access it, construct a FlxLockedWrapper.
|
|
FlxLockableWrapper LockableWrapper;
|
|
|
|
// The Lua Call assembly buffer.
|
|
FlxStreamBuffer LuaCallBuffer;
|
|
|
|
// 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<FlxSockets> Sockets;
|
|
|
|
// True if 'BeginPlay' has been successfully completed.
|
|
bool Playing;
|
|
|
|
// Current Player ID
|
|
int64 PlayerId;
|
|
|
|
// Amount of elapsed time since BeginPlay.
|
|
float EngineSeconds;
|
|
|
|
// When do we next rotate the cube.
|
|
float NextRotateCube;
|
|
|
|
// These allow us to pre-tick and post-tick.
|
|
FDelegateHandle OnWorldPreActorTickHandle;
|
|
FDelegateHandle OnWorldPostActorTickHandle;
|
|
};
|