From cc4441cb314adf9d76ba8302d8c1d6deb4abc59a Mon Sep 17 00:00:00 2001 From: jyelon Date: Mon, 17 Mar 2025 18:04:55 -0400 Subject: [PATCH] Rename IntegrationGameModeBase to LuprexGameModeBase, and other small refactors --- Config/DefaultEngine.ini | 1 - Content/Luprex/lxGameMode.uasset | 4 +- .../Luprex/lxUtilityFunctionsLibrary.uasset | 4 +- Content/Luprex/lxUtilityMacroLibrary.uasset | 4 +- Content/Tangibles/TangibleStaticMesh.uasset | 4 +- Content/Tangibles/tangiblecharacter.uasset | 4 +- Source/Integration/LuaCall.cpp | 40 +++++++------- Source/Integration/LuaCall.h | 2 +- ...ameModeBase.cpp => LuprexGameModeBase.cpp} | 52 +++++++++---------- ...ionGameModeBase.h => LuprexGameModeBase.h} | 25 ++++----- Source/Integration/Tangible.cpp | 4 +- Source/Integration/TangibleManager.cpp | 4 +- Source/Integration/TangibleManager.h | 8 +-- 13 files changed, 78 insertions(+), 78 deletions(-) rename Source/Integration/{IntegrationGameModeBase.cpp => LuprexGameModeBase.cpp} (84%) rename Source/Integration/{IntegrationGameModeBase.h => LuprexGameModeBase.h} (88%) diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 00238b9b..18fa7dce 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -1,5 +1,4 @@ - [/Script/EngineSettings.GameMapsSettings] GameDefaultMap=/Game/LpxLevel.LpxLevel GlobalDefaultGameMode=/Game/Luprex/lxGameMode.lxGameMode_C diff --git a/Content/Luprex/lxGameMode.uasset b/Content/Luprex/lxGameMode.uasset index 979a1014..582902c4 100644 --- a/Content/Luprex/lxGameMode.uasset +++ b/Content/Luprex/lxGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:df608f4a88a1490a5ab407def1f8ceb4b3cf0cd630642c2fde945ce9e18465e6 -size 116280 +oid sha256:21c2e559335c290b92b4e837b4d383686faf6ec4706d872f35113dc3265461ec +size 121336 diff --git a/Content/Luprex/lxUtilityFunctionsLibrary.uasset b/Content/Luprex/lxUtilityFunctionsLibrary.uasset index 3fb22fda..b4e6eddb 100644 --- a/Content/Luprex/lxUtilityFunctionsLibrary.uasset +++ b/Content/Luprex/lxUtilityFunctionsLibrary.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1afb3a566a2b64730bc10b3de4a8c3177a452f4d75088063de35899d5e2a2a2 -size 50214 +oid sha256:2eb1dedd09ea301c86c3c341a21670d80db46d61908d5912478c598e9c3da307 +size 63985 diff --git a/Content/Luprex/lxUtilityMacroLibrary.uasset b/Content/Luprex/lxUtilityMacroLibrary.uasset index 32d991d5..dae0839d 100644 --- a/Content/Luprex/lxUtilityMacroLibrary.uasset +++ b/Content/Luprex/lxUtilityMacroLibrary.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ac178219b6e91d02f78602e70da47ba8f361f86e41b15888fac6453952ca6829 -size 19388 +oid sha256:9a61a047c3119d201dbd2343ea8b700ef67bb4af807cb6003911f0e0e70a9e3f +size 19281 diff --git a/Content/Tangibles/TangibleStaticMesh.uasset b/Content/Tangibles/TangibleStaticMesh.uasset index 83118783..5ba9a5fc 100644 --- a/Content/Tangibles/TangibleStaticMesh.uasset +++ b/Content/Tangibles/TangibleStaticMesh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1037fccb759217bafeb88ede1dcd0915cc7018163d0e739c40dd1b70547e6f1e -size 219598 +oid sha256:a5b8ed1fcef22cb88a3f4a6034d389ba88c71645cef20ba032e411da2a423f7f +size 219262 diff --git a/Content/Tangibles/tangiblecharacter.uasset b/Content/Tangibles/tangiblecharacter.uasset index 776ef78e..0447b4e3 100644 --- a/Content/Tangibles/tangiblecharacter.uasset +++ b/Content/Tangibles/tangiblecharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e1504e7d8d446acad328fd7c178e86bf8c874eb71d53b975837988ef7992f2ee -size 334577 +oid sha256:9a90624c1a500217f240a4b5dba083d7d000faf3560af2a0a6c7d15d2ca45e79 +size 335694 diff --git a/Source/Integration/LuaCall.cpp b/Source/Integration/LuaCall.cpp index 6f51fcc9..1a8e5876 100644 --- a/Source/Integration/LuaCall.cpp +++ b/Source/Integration/LuaCall.cpp @@ -1,6 +1,6 @@ #include "LuaCall.h" -#include "IntegrationGameModeBase.h" +#include "LuprexGameModeBase.h" #include "EdGraphSchema_K2.h" static void FatalBlueprintError(const TCHAR *message) { @@ -204,7 +204,7 @@ FString UlxLuaCallLibrary::AllFunctionsWithPrefix(const TCHAR *Prefix) ///////////////////////////////////////////////////////////////// void UlxLuaCallLibrary::LuaCallBegin(UObject *context, const FString &cname, const FString &fname) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); mode->LuaCallBegin(); sb.write_string(cname); @@ -213,7 +213,7 @@ void UlxLuaCallLibrary::LuaCallBegin(UObject *context, const FString &cname, con void UlxLuaCallLibrary::LuaCallInvoke(UObject *context, AActor *place) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); mode->LuaCallEnd(InvocationKind::LUA_INVOKE, place); @@ -221,7 +221,7 @@ void UlxLuaCallLibrary::LuaCallInvoke(UObject *context, AActor *place) { void UlxLuaCallLibrary::LuaCallProbe(UObject *context, AActor *place) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); mode->LuaCallEnd(InvocationKind::LUA_PROBE, place); @@ -229,7 +229,7 @@ void UlxLuaCallLibrary::LuaCallProbe(UObject *context, AActor *place) { void UlxLuaCallLibrary::InvokeEngioMove(UObject *context, const FString &action, const FVector &xyz, double facing) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallBegin(); sb.write_string("engio"); sb.write_string("move"); @@ -244,7 +244,7 @@ void UlxLuaCallLibrary::InvokeEngioMove(UObject *context, const FString &action, ELpxSimpleDynamicTag UlxLuaCallLibrary::LuaCallNextResultType(UObject *context) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetResult(); if (sb.empty()) return ELpxSimpleDynamicTag::None; int64_t total_reads = sb.total_reads(); @@ -267,7 +267,7 @@ ELpxSimpleDynamicTag UlxLuaCallLibrary::LuaCallNextResultType(UObject *context) ///////////////////////////////////////////////////////////////// void UlxLuaCallLibrary::LuaCallArgument_string(UObject *context, const FString &pstring) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); sb.write_simple_dynamic_tag(SimpleDynamicTag::STRING); @@ -281,7 +281,7 @@ void UlxLuaCallLibrary::LuaCallArgument_name(UObject *context, const FName &pnam if ((tokvalue == 0) && !namestr.empty()) { FatalBlueprintError(TEXT("Names passed to lua must be short, and must contain only lowercase and digits")); } - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); sb.write_simple_dynamic_tag(SimpleDynamicTag::TOKEN); @@ -289,7 +289,7 @@ void UlxLuaCallLibrary::LuaCallArgument_name(UObject *context, const FName &pnam } void UlxLuaCallLibrary::LuaCallArgument_float(UObject *context, double pfloat) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER); @@ -297,7 +297,7 @@ void UlxLuaCallLibrary::LuaCallArgument_float(UObject *context, double pfloat) { } void UlxLuaCallLibrary::LuaCallArgument_int(UObject *context, int value) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER); @@ -305,7 +305,7 @@ void UlxLuaCallLibrary::LuaCallArgument_int(UObject *context, int value) { } void UlxLuaCallLibrary::LuaCallArgument_vector(UObject *context, const FVector &pvector) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR); @@ -313,7 +313,7 @@ void UlxLuaCallLibrary::LuaCallArgument_vector(UObject *context, const FVector & } void UlxLuaCallLibrary::LuaCallArgument_vector2d(UObject *context, const FVector2D &pvector) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR); @@ -323,7 +323,7 @@ void UlxLuaCallLibrary::LuaCallArgument_vector2d(UObject *context, const FVector } void UlxLuaCallLibrary::LuaCallArgument_boolean(UObject *context, bool pbool) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetBuffer(); CheckNotEmpty(sb); sb.write_simple_dynamic_tag(SimpleDynamicTag::BOOLEAN); @@ -339,7 +339,7 @@ void UlxLuaCallLibrary::LuaCallArgument_boolean(UObject *context, bool pbool) { FString UlxLuaCallLibrary::LuaCallReturnValue_string(UObject *context) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetResult(); SimpleDynamicTag tag = sb.read_simple_dynamic_tag(); if (tag != SimpleDynamicTag::STRING) FatalBlueprintError(TEXT("expected lua to return a string")); @@ -347,7 +347,7 @@ FString UlxLuaCallLibrary::LuaCallReturnValue_string(UObject *context) { } FName UlxLuaCallLibrary::LuaCallReturnValue_name(UObject *context) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetResult(); SimpleDynamicTag tag = sb.read_simple_dynamic_tag(); if (tag != SimpleDynamicTag::TOKEN) FatalBlueprintError(TEXT("expected lua to return a name")); @@ -355,7 +355,7 @@ FName UlxLuaCallLibrary::LuaCallReturnValue_name(UObject *context) { } double UlxLuaCallLibrary::LuaCallReturnValue_float(UObject *context) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetResult(); SimpleDynamicTag tag = sb.read_simple_dynamic_tag(); if (tag != SimpleDynamicTag::NUMBER) FatalBlueprintError(TEXT("expected lua to return a float")); @@ -363,7 +363,7 @@ double UlxLuaCallLibrary::LuaCallReturnValue_float(UObject *context) { } int UlxLuaCallLibrary::LuaCallReturnValue_int(UObject *context) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetResult(); SimpleDynamicTag tag = sb.read_simple_dynamic_tag(); if (tag != SimpleDynamicTag::NUMBER) FatalBlueprintError(TEXT("expected lua to return a number")); @@ -371,7 +371,7 @@ int UlxLuaCallLibrary::LuaCallReturnValue_int(UObject *context) { } FVector UlxLuaCallLibrary::LuaCallReturnValue_vector(UObject *context) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetResult(); SimpleDynamicTag tag = sb.read_simple_dynamic_tag(); if (tag != SimpleDynamicTag::VECTOR) FatalBlueprintError(TEXT("expected lua to return a vector")); @@ -379,7 +379,7 @@ FVector UlxLuaCallLibrary::LuaCallReturnValue_vector(UObject *context) { } FVector2D UlxLuaCallLibrary::LuaCallReturnValue_vector2d(UObject *context) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetResult(); SimpleDynamicTag tag = sb.read_simple_dynamic_tag(); if (tag != SimpleDynamicTag::VECTOR) FatalBlueprintError(TEXT("expected lua to return a vector")); @@ -388,7 +388,7 @@ FVector2D UlxLuaCallLibrary::LuaCallReturnValue_vector2d(UObject *context) { } bool UlxLuaCallLibrary::LuaCallReturnValue_boolean(UObject *context) { - AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context); + ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context); FlxStreamBuffer &sb = mode->LuaCallGetResult(); SimpleDynamicTag tag = sb.read_simple_dynamic_tag(); if (tag != SimpleDynamicTag::BOOLEAN) FatalBlueprintError(TEXT("expected lua to return a boolean")); diff --git a/Source/Integration/LuaCall.h b/Source/Integration/LuaCall.h index da82627a..764ce8fd 100644 --- a/Source/Integration/LuaCall.h +++ b/Source/Integration/LuaCall.h @@ -100,7 +100,7 @@ public: // * Use LuaCallReturnValueXXX to fetch return values from the return buffer. // // The two buffers are basically global variables, they are part of the -// IntegrationGameModeBase. This is okay because blueprint is single-threaded. +// LuprexGameModeBase. This is okay because blueprint is single-threaded. // // The following three libraries contain all the low-level functions. // diff --git a/Source/Integration/IntegrationGameModeBase.cpp b/Source/Integration/LuprexGameModeBase.cpp similarity index 84% rename from Source/Integration/IntegrationGameModeBase.cpp rename to Source/Integration/LuprexGameModeBase.cpp index 25f77384..b383ee9b 100644 --- a/Source/Integration/IntegrationGameModeBase.cpp +++ b/Source/Integration/LuprexGameModeBase.cpp @@ -1,6 +1,6 @@ // Copyright Epic Games, Inc. All Rights Reserved. -#include "IntegrationGameModeBase.h" +#include "LuprexGameModeBase.h" #include "lpx-drvutil.hpp" #include "lpx-paths.hpp" #include "DebugPrint.h" @@ -14,7 +14,7 @@ using namespace DebugPrint; using namespace CommonTypes; -AIntegrationGameModeBase::AIntegrationGameModeBase() +ALuprexGameModeBase::ALuprexGameModeBase() { TangibleManager = NewObject(); PlayerId = 0; @@ -26,11 +26,11 @@ AIntegrationGameModeBase::AIntegrationGameModeBase() SetActorTickInterval(0.0f); DebugPrintControl::EnableCollection(); ResetToInitialState(); - OnWorldPreActorTickHandle = FWorldDelegates::OnWorldPreActorTick.AddUObject(this, &AIntegrationGameModeBase::OnWorldPreActorTick); - OnWorldPostActorTickHandle = FWorldDelegates::OnWorldPostActorTick.AddUObject(this, &AIntegrationGameModeBase::OnWorldPostActorTick); + OnWorldPreActorTickHandle = FWorldDelegates::OnWorldPreActorTick.AddUObject(this, &ALuprexGameModeBase::OnWorldPreActorTick); + OnWorldPostActorTickHandle = FWorldDelegates::OnWorldPostActorTick.AddUObject(this, &ALuprexGameModeBase::OnWorldPostActorTick); } -AIntegrationGameModeBase::~AIntegrationGameModeBase() +ALuprexGameModeBase::~ALuprexGameModeBase() { ResetToInitialState(); FWorldDelegates::OnWorldPreActorTick.Remove(OnWorldPreActorTickHandle); @@ -40,7 +40,7 @@ AIntegrationGameModeBase::~AIntegrationGameModeBase() // This method runs in the background thread, // at the moment we trigger it. // -uint32 AIntegrationGameModeBase::Run() { +uint32 ALuprexGameModeBase::Run() { FlxLockedWrapper lockedwrap(LockableWrapper); Sockets->Update(lockedwrap); lockedwrap->play_update(lockedwrap.Get(), EngineSeconds); @@ -48,7 +48,7 @@ uint32 AIntegrationGameModeBase::Run() { return 0; } -void AIntegrationGameModeBase::ResetToInitialState() +void ALuprexGameModeBase::ResetToInitialState() { Playing = false; @@ -96,7 +96,7 @@ void AIntegrationGameModeBase::ResetToInitialState() } -void AIntegrationGameModeBase::UpdateConsoleOutput() { +void ALuprexGameModeBase::UpdateConsoleOutput() { // Copy Luprex Stdout into the console. FlxLockedWrapper lockedwrap(LockableWrapper); if (Playing) { @@ -117,7 +117,7 @@ void AIntegrationGameModeBase::UpdateConsoleOutput() { } #pragma optimize("", off) -void AIntegrationGameModeBase::UpdateTangibles() { +void ALuprexGameModeBase::UpdateTangibles() { double radius = 1000.0; // Hardwired for now. using TanArray = UlxTangibleManager::TanArray; if (!Playing) return; @@ -145,7 +145,7 @@ void AIntegrationGameModeBase::UpdateTangibles() { TangibleManager->DeleteFarawayTangibles(); } -void AIntegrationGameModeBase::UpdatePossessedTangible() { +void ALuprexGameModeBase::UpdatePossessedTangible() { UlxTangible *ptan = TangibleManager->GetPossessedTangible(); UlxTangible *tan = TangibleManager->GetTangible(PlayerId); APlayerController *ctrl = GetWorld()->GetFirstPlayerController(); @@ -164,7 +164,7 @@ void AIntegrationGameModeBase::UpdatePossessedTangible() { } } -void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind, int64 place_id) { +void ALuprexGameModeBase::LuaCallEnd(InvocationKind kind, int64 place_id) { std::string_view datapk = LuaCallBuffer.view(); FlxLockedWrapper w(LockableWrapper); if (place_id == 0) place_id = w.GetActor(); @@ -174,11 +174,11 @@ void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind, int64 place_id) { LuaCallResult.open(std::string_view(retpk, retpklen)); } -void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind) { +void ALuprexGameModeBase::LuaCallEnd(InvocationKind kind) { LuaCallEnd(kind, int64(0)); } -void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind, AActor *place) { +void ALuprexGameModeBase::LuaCallEnd(InvocationKind kind, AActor *place) { if (place == nullptr) { LuaCallEnd(kind, int64(0)); } else { @@ -191,7 +191,7 @@ void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind, AActor *place) { } } -void AIntegrationGameModeBase::ExecuteDebuggingCommand(FlxLockedWrapper &w, const FString &fs) { +void ALuprexGameModeBase::ExecuteDebuggingCommand(FlxLockedWrapper &w, const FString &fs) { if (fs == "\\invokeplayer") { DPrint(TEXT("Trying to invoke 'myfunction' in lua")); FlxStreamBuffer &sb = LuaCallBegin(); @@ -209,7 +209,7 @@ void AIntegrationGameModeBase::ExecuteDebuggingCommand(FlxLockedWrapper &w, cons } } -void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs) +void ALuprexGameModeBase::ConsoleSendInput(const FString& fs) { if (fs.IsEmpty()) { return; @@ -233,7 +233,7 @@ void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs) } } -void AIntegrationGameModeBase::OnWorldPreActorTick(UWorld* InWorld, ELevelTick InLevelTick, float deltaseconds) +void ALuprexGameModeBase::OnWorldPreActorTick(UWorld* InWorld, ELevelTick InLevelTick, float deltaseconds) { if(Playing && (GetWorld() == InWorld) && (InLevelTick == LEVELTICK_All)) { @@ -246,7 +246,7 @@ void AIntegrationGameModeBase::OnWorldPreActorTick(UWorld* InWorld, ELevelTick I } } -void AIntegrationGameModeBase::OnWorldPostActorTick(UWorld* InWorld, ELevelTick InLevelTick, float deltaseconds) +void ALuprexGameModeBase::OnWorldPostActorTick(UWorld* InWorld, ELevelTick InLevelTick, float deltaseconds) { if(Playing && (GetWorld() == InWorld) && (InLevelTick == LEVELTICK_All)) { @@ -255,12 +255,12 @@ void AIntegrationGameModeBase::OnWorldPostActorTick(UWorld* InWorld, ELevelTick } -void AIntegrationGameModeBase::Tick(float deltaseconds) +void ALuprexGameModeBase::Tick(float deltaseconds) { Super::Tick(deltaseconds); } -void AIntegrationGameModeBase::BeginPlay() +void ALuprexGameModeBase::BeginPlay() { Super::BeginPlay(); @@ -330,29 +330,29 @@ void AIntegrationGameModeBase::BeginPlay() new FlxDebugBlueprintErrorsOutputDevice(BreakToDebuggerLogVerbosity)); } -void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) +void ALuprexGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) { ResetToInitialState(); } -int64 AIntegrationGameModeBase::GetPlayerId() { +int64 ALuprexGameModeBase::GetPlayerId() { return PlayerId; } -AIntegrationGameModeBase *AIntegrationGameModeBase::GetLuprexGameMode(UObject *context) { - AIntegrationGameModeBase *result = context->GetWorld()->GetAuthGameMode(); +ALuprexGameModeBase *ALuprexGameModeBase::FromContext(UObject *context) { + ALuprexGameModeBase *result = context->GetWorld()->GetAuthGameMode(); if (result == nullptr) { UE_LOG(LogBlueprint, Fatal, TEXT("Not currently using a Luprex Game Mode.")); } return result; } -bool AIntegrationGameModeBase::IsLookAtChanged(UObject *context) { - AIntegrationGameModeBase *mode = GetLuprexGameMode(context); +bool ALuprexGameModeBase::IsLookAtChanged(UObject *context) { + ALuprexGameModeBase *mode = FromContext(context); return mode->CurrentLookAt.HitObjectHandle != mode->PreviousLookAt.HitObjectHandle; } -void AIntegrationGameModeBase::UpdateLookAt() { +void ALuprexGameModeBase::UpdateLookAt() { // Rotate the variables. PreviousLookAt = CurrentLookAt; CurrentLookAt.Init(); diff --git a/Source/Integration/IntegrationGameModeBase.h b/Source/Integration/LuprexGameModeBase.h similarity index 88% rename from Source/Integration/IntegrationGameModeBase.h rename to Source/Integration/LuprexGameModeBase.h index 42032f31..6885b9ee 100644 --- a/Source/Integration/IntegrationGameModeBase.h +++ b/Source/Integration/LuprexGameModeBase.h @@ -11,7 +11,7 @@ #include "LuprexSockets.h" #include "TriggeredTask.h" #include "BlueprintErrors.h" -#include "IntegrationGameModeBase.generated.h" +#include "LuprexGameModeBase.generated.h" class LookAtDetector; @@ -20,13 +20,13 @@ class LookAtDetector; * */ UCLASS() -class INTEGRATION_API AIntegrationGameModeBase : public AGameModeBase, public FRunnable +class INTEGRATION_API ALuprexGameModeBase : public AGameModeBase, public FRunnable { GENERATED_BODY() public: - AIntegrationGameModeBase(); - ~AIntegrationGameModeBase(); + ALuprexGameModeBase(); + ~ALuprexGameModeBase(); virtual void BeginPlay() override; virtual void Tick(float) override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason); @@ -46,23 +46,20 @@ public: UFUNCTION(BlueprintCallable, Category = "Luprex|Miscellaneous") int64 GetPlayerId(); - UFUNCTION(BlueprintPure, meta = (CompactNodeTitle="LxGameMode", WorldContext = "context"), Category = "Luprex|Miscellaneous") - static AIntegrationGameModeBase *GetLuprexGameMode(UObject *context); - UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection") - static void SetLookAt(UObject *context, const FHitResult &hit) { GetLuprexGameMode(context)->CurrentLookAt = hit; } + 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 GetLuprexGameMode(context)->CurrentLookAt; } + 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 GetLuprexGameMode(context)->CurrentLookAt.GetActor(); } + 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 GetLuprexGameMode(context)->PreviousLookAt; } + 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 GetLuprexGameMode(context)->PreviousLookAt.GetActor(); } + 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); @@ -118,6 +115,10 @@ public: // 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; diff --git a/Source/Integration/Tangible.cpp b/Source/Integration/Tangible.cpp index 335d4cbc..2d5e5a3c 100644 --- a/Source/Integration/Tangible.cpp +++ b/Source/Integration/Tangible.cpp @@ -3,7 +3,7 @@ #include "Tangible.h" #include "TangibleManager.h" -#include "IntegrationGameModeBase.h" +#include "LuprexGameModeBase.h" #define DEFAULT_BLUEPRINT (TEXT("TangibleStaticMesh")) #define LOCTEXT_NAMESPACE "Luprex Tangible" @@ -193,7 +193,7 @@ void UlxTangible::SetTangiblePlane(AActor* target, const FString& plane) { bool UlxTangible::IsCurrentPlayer(AActor* target) { UlxTangible *tan = GetActorTangibleQuiet(target); if (tan == nullptr) return false; - AIntegrationGameModeBase *gamemode = tan->Manager->GetGameMode(); + ALuprexGameModeBase *gamemode = tan->Manager->GetGameMode(); return (tan->TangibleId == gamemode->PlayerId); } diff --git a/Source/Integration/TangibleManager.cpp b/Source/Integration/TangibleManager.cpp index 4bb41966..d65a3d90 100644 --- a/Source/Integration/TangibleManager.cpp +++ b/Source/Integration/TangibleManager.cpp @@ -4,7 +4,7 @@ #include "TangibleManager.h" #include "Tangible.h" #include "DebugPrint.h" -#include "IntegrationGameModeBase.h" +#include "LuprexGameModeBase.h" using namespace DebugPrint; using TanArray = UlxTangibleManager::TanArray; @@ -53,7 +53,7 @@ UlxTangibleManager::UlxTangibleManager() { PossessedTangible = nullptr; } -void UlxTangibleManager::Init(UWorld* world, AIntegrationGameModeBase *gamemode) { +void UlxTangibleManager::Init(UWorld* world, ALuprexGameModeBase *gamemode) { World = world; GameMode = gamemode; } diff --git a/Source/Integration/TangibleManager.h b/Source/Integration/TangibleManager.h index 8f59d089..4e3d3a93 100644 --- a/Source/Integration/TangibleManager.h +++ b/Source/Integration/TangibleManager.h @@ -8,7 +8,7 @@ #include "Tangible.h" #include "TangibleManager.generated.h" -class AIntegrationGameModeBase; +class ALuprexGameModeBase; UCLASS() class INTEGRATION_API UlxTangibleManager : public UObject @@ -27,7 +27,7 @@ public: // A pointer to our game mode. UPROPERTY() - TWeakObjectPtr GameMode; + TWeakObjectPtr GameMode; // Given a tangible ID, look up the TangibleComponent of that actor. UPROPERTY() @@ -41,14 +41,14 @@ public: // Initialize the tangible manager. // - void Init(UWorld *world, AIntegrationGameModeBase *gamemode); + void Init(UWorld *world, ALuprexGameModeBase *gamemode); // Get a pointer to our world. // UWorld* GetWorld() const override { return World.Get(); } // Get a pointer to our game mode. - AIntegrationGameModeBase *GetGameMode() { return GameMode.Get(); } + ALuprexGameModeBase *GetGameMode() { return GameMode.Get(); } // Get the tangible if it exists, otherwise return NULL //