Rename IntegrationGameModeBase to LuprexGameModeBase, and other small refactors
This commit is contained in:
172
Source/Integration/LuprexGameModeBase.h
Normal file
172
Source/Integration/LuprexGameModeBase.h
Normal file
@@ -0,0 +1,172 @@
|
||||
// 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 "BlueprintErrors.h"
|
||||
#include "LuprexGameModeBase.generated.h"
|
||||
|
||||
|
||||
class LookAtDetector;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class INTEGRATION_API ALuprexGameModeBase : public AGameModeBase, public FRunnable
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
ALuprexGameModeBase();
|
||||
~ALuprexGameModeBase();
|
||||
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|Miscellaneous")
|
||||
void ConsoleSetOutput(const FString& text);
|
||||
|
||||
// This is called by the GUI whenever the user hits enter.
|
||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Miscellaneous")
|
||||
void ConsoleSendInput(const FString& text);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Miscellaneous")
|
||||
int64 GetPlayerId();
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||
static void SetLookAt(UObject *context, const FHitResult &hit) { FromContext(context)->CurrentLookAt = hit; }
|
||||
|
||||
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||
static const FHitResult &GetLookAt(UObject *context) { return FromContext(context)->CurrentLookAt; }
|
||||
|
||||
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||
static const AActor *GetLookAtActor(UObject *context) { return FromContext(context)->CurrentLookAt.GetActor(); }
|
||||
|
||||
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||
static const FHitResult &GetPreviousLookAt(UObject *context) { return FromContext(context)->PreviousLookAt; }
|
||||
|
||||
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||
static const AActor *GetPreviousLookAtActor(UObject *context) { return FromContext(context)->PreviousLookAt.GetActor(); }
|
||||
|
||||
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||
static bool IsLookAtChanged(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
||||
void CalculateLookAt(APlayerController *PlayerController);
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
||||
void LookAtChanged();
|
||||
|
||||
// Assemble a lua call. To call into lua:
|
||||
//
|
||||
// * Use LuaCallBegin
|
||||
// * Get the lua call buffer:
|
||||
// - add a class name
|
||||
// - add a function name
|
||||
// - add function parameters
|
||||
// * Use LuaCallEnd.
|
||||
// * Get the lua call result.
|
||||
// - parse out any return values
|
||||
//
|
||||
FlxStreamBuffer &LuaCallBegin() { LuaCallBuffer.clear(); return LuaCallBuffer; }
|
||||
FlxStreamBuffer &LuaCallGetBuffer() { return LuaCallBuffer; }
|
||||
void LuaCallEnd(InvocationKind kind);
|
||||
void LuaCallEnd(InvocationKind kind, int64 place_id);
|
||||
void LuaCallEnd(InvocationKind kind, AActor *place);
|
||||
FlxStreamBuffer &LuaCallGetResult() { return LuaCallResult; }
|
||||
void LuaCallClear() { LuaCallBuffer.clear(); LuaCallResult.clear(); }
|
||||
|
||||
// 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.
|
||||
// This also includes calling 'AnimationQueueChanged' on all
|
||||
// tangibles that have been changed.
|
||||
void UpdateTangibles();
|
||||
|
||||
// Maybe call 'BecomePossessed' on the player tangible.
|
||||
void UpdatePossessedTangible();
|
||||
|
||||
// Call 'CalculateLookAt', but only if everything is valid.
|
||||
// It is up to the blueprint code to actually determine what we're looking at.
|
||||
void UpdateLookAt();
|
||||
|
||||
// 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 current Luprex Game Mode Base, given a context object.
|
||||
static ALuprexGameModeBase *FromContext(UObject *context);
|
||||
|
||||
|
||||
UPROPERTY()
|
||||
UlxTangibleManager *TangibleManager;
|
||||
|
||||
// The actor that the player was looking at, previous frame.
|
||||
UPROPERTY()
|
||||
FHitResult PreviousLookAt;
|
||||
|
||||
// The actor that the player is looking at, current frame.
|
||||
UPROPERTY()
|
||||
FHitResult CurrentLookAt;
|
||||
|
||||
// The sensitivity level at which a log message triggers a debugger breakpoint.
|
||||
UPROPERTY(EditAnywhere, Category="Debugging Tools")
|
||||
ElxLogVerbosity BreakToDebuggerLogVerbosity;
|
||||
|
||||
// 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;
|
||||
FlxStreamBuffer LuaCallResult;
|
||||
|
||||
// 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;
|
||||
|
||||
// The device that implements BreakToDebuggerLogVerbosity, above.
|
||||
TUniquePtr<FlxDebugBlueprintErrorsOutputDevice> BreakToDebuggerLogVerbosityDevice;
|
||||
};
|
||||
Reference in New Issue
Block a user