Files
integration/Source/Integration/IntegrationGameModeBase.h

136 lines
4.1 KiB
C
Raw Normal View History

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 "lpx-enginewrapper.hpp"
#include "DebugPrint.h"
2024-08-31 16:42:07 -04:00
#include "StringDecoder.h"
2023-09-02 01:33:11 -04:00
#include "TangibleManager.h"
#include "LuprexSockets.h"
#include "TriggeredTask.h"
2023-06-09 14:36:47 -04:00
#include "IntegrationGameModeBase.generated.h"
2023-06-08 17:10:14 -04:00
2024-09-17 17:22:47 -04:00
class LookAtDetector;
2023-06-08 17:10:14 -04:00
/**
*
*/
UCLASS()
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();
~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-08 17:10:14 -04:00
// Set the entire contents of the console output box.
2023-09-20 01:52:25 -04:00
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex")
2023-06-08 17:10:14 -04:00
void ConsoleSetOutput(const FString& text);
// This is called by the GUI whenever the user hits enter.
2023-09-20 01:52:25 -04:00
UFUNCTION(BlueprintCallable, Category = "Luprex")
2023-06-08 17:10:14 -04:00
void ConsoleSendInput(const FString& text);
UFUNCTION(BlueprintCallable, Category = "Luprex")
int64 GetPlayerId();
2024-09-17 17:22:47 -04:00
UFUNCTION(BlueprintCallable, Category = "Luprex")
void SetLookAtDetector(UlxLookAtActorBase *det);
2024-08-31 16:42:07 -04:00
// Assemble a lua call. To call into lua:
//
// * Use LuaCallBegin
2024-09-04 23:15:13 -04:00
// * 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
2024-08-31 16:42:07 -04:00
//
2024-09-04 23:15:13 -04:00
FlxStreamBuffer &LuaCallBegin() { LuaCallBuffer.clear(); return LuaCallBuffer; }
2024-08-31 16:42:07 -04:00
FlxStreamBuffer &LuaCallGetBuffer() { return LuaCallBuffer; }
2024-09-04 23:15:13 -04:00
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);
2023-06-23 12:45:23 -04:00
// 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();
// Pre-tick and post-tick functions.
void OnWorldPreActorTick(UWorld* InWorld, ELevelTick InLevelTick, float InDeltaSeconds);
void OnWorldPostActorTick(UWorld* InWorld, ELevelTick InLevelTick, float InDeltaSeconds);
2023-06-23 12:45:23 -04:00
// The run function is called by a background thread
// to update luprex sockets and update luprex itself.
virtual uint32 Run() override;
2024-08-31 16:42:07 -04:00
// 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;
2023-08-29 20:05:10 -04:00
2024-09-17 17:22:47 -04:00
UPROPERTY()
UlxLookAtActorBase *LookAtDetector;
2023-06-23 12:45:23 -04:00
// This stores the entire text currently visible in the console.
2023-09-15 13:28:18 -04:00
FlxConsoleOutput 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.
2023-09-15 13:28:18 -04:00
// To access it, construct a FlxLockedWrapper.
FlxLockableWrapper LockableWrapper;
2023-06-23 16:27:23 -04:00
2024-08-31 16:42:07 -04:00
// The Lua Call assembly buffer.
FlxStreamBuffer LuaCallBuffer;
2024-09-04 23:15:13 -04:00
FlxStreamBuffer LuaCallResult;
2024-08-31 16:42:07 -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.
2023-09-15 13:28:18 -04:00
TUniquePtr<FlxSockets> Sockets;
2023-06-23 16:27:23 -04:00
// True if 'BeginPlay' has been successfully completed.
bool Playing;
// Current Player ID
int64 PlayerId;
// Amount of elapsed time since BeginPlay.
2023-06-08 17:10:14 -04:00
float EngineSeconds;
2023-06-23 12:45:23 -04:00
// When do we next rotate the cube.
float NextRotateCube;
// These allow us to pre-tick and post-tick.
FDelegateHandle OnWorldPreActorTickHandle;
FDelegateHandle OnWorldPostActorTickHandle;
2023-06-08 17:10:14 -04:00
};