From a295ff5e534baa95af6681fdbda5ddef3cfd9367 Mon Sep 17 00:00:00 2001 From: jyelon Date: Tue, 24 Sep 2024 22:13:56 -0400 Subject: [PATCH] A Bunch of miscellaneous refactoring --- Config/DefaultEngine.ini | 2 +- Content/Luprex/lxDefaultPawn.uasset | 3 +++ Content/Luprex/lxGameMode.uasset | 4 ++-- .../Luprex/lxUtilityFunctionsLibrary.uasset | 4 ++-- Content/Tangibles/TangibleCharacter.uasset | 3 --- Content/Tangibles/tangiblecharacter.uasset | 3 +++ .../Blueprints/BP_DefaultPawn.uasset | 3 --- .../Integration/IntegrationGameModeBase.cpp | 19 ++++++++++++++----- Source/Integration/Tangible.h | 5 ++--- Source/Integration/TangibleManager.cpp | 10 ---------- Source/Integration/TangibleManager.h | 6 +----- Source/Integration/UtilityLibrary.cpp | 5 ++++- Source/Integration/UtilityLibrary.h | 2 +- 13 files changed, 33 insertions(+), 36 deletions(-) create mode 100644 Content/Luprex/lxDefaultPawn.uasset delete mode 100644 Content/Tangibles/TangibleCharacter.uasset create mode 100644 Content/Tangibles/tangiblecharacter.uasset delete mode 100644 Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index d63a1041..fd1b9368 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -2,7 +2,7 @@ [/Script/EngineSettings.GameMapsSettings] GameDefaultMap=/Game/LpxLevel.LpxLevel -GlobalDefaultGameMode=/Game/IntegrationGameModeBaseBP.IntegrationGameModeBaseBP_C +GlobalDefaultGameMode=/Game/Luprex/lxGameMode.lxGameMode_C GameInstanceClass=/Script/IntegrationV7.GameInstanceV7 GlobalDefaultServerGameMode=/Game/IntegrationGameModeBaseBP.IntegrationGameModeBaseBP_C EditorStartupMap=/Game/LpxLevel.LpxLevel diff --git a/Content/Luprex/lxDefaultPawn.uasset b/Content/Luprex/lxDefaultPawn.uasset new file mode 100644 index 00000000..1e022579 --- /dev/null +++ b/Content/Luprex/lxDefaultPawn.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1088ff20ffe4d431cf03c492816f499a3fda7252a3189689020673b420f91038 +size 67049 diff --git a/Content/Luprex/lxGameMode.uasset b/Content/Luprex/lxGameMode.uasset index addf74aa..450ff511 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:53edabed12e415f9e9502194a05eae638fa83cde50b9078c532e8a475e21f365 -size 92330 +oid sha256:cf4f68433f29210d4890c6e20df08debb94ac1827dfd975d68903dcfda2ddc2b +size 92035 diff --git a/Content/Luprex/lxUtilityFunctionsLibrary.uasset b/Content/Luprex/lxUtilityFunctionsLibrary.uasset index a985c4cd..5dacf2e3 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:8386ed92aea1cfc4da7cac923e1f8f4a60c8fd8813d4b3f100d3c5878a017b32 -size 27353 +oid sha256:91469decab760473c36712e55bb4427cda0cd7fbf68929deb921f0592bd1ec84 +size 90818 diff --git a/Content/Tangibles/TangibleCharacter.uasset b/Content/Tangibles/TangibleCharacter.uasset deleted file mode 100644 index 0189c725..00000000 --- a/Content/Tangibles/TangibleCharacter.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e6c82599641f056288f87232e73a7f267a5002999216fa030c6319f7a151cbf2 -size 474888 diff --git a/Content/Tangibles/tangiblecharacter.uasset b/Content/Tangibles/tangiblecharacter.uasset new file mode 100644 index 00000000..7a22844a --- /dev/null +++ b/Content/Tangibles/tangiblecharacter.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a6086b0657e5c5de22e49eba805ea82d2f9170f68dd3ec8fe731effebb43426d +size 395326 diff --git a/Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset b/Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset deleted file mode 100644 index 557070ad..00000000 --- a/Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d68823c08d284a4a810a5a4c1a274c3a4ca4d9bdd846d174030c8d0a3ca41525 -size 66883 diff --git a/Source/Integration/IntegrationGameModeBase.cpp b/Source/Integration/IntegrationGameModeBase.cpp index d32555d6..ce254d82 100644 --- a/Source/Integration/IntegrationGameModeBase.cpp +++ b/Source/Integration/IntegrationGameModeBase.cpp @@ -143,13 +143,22 @@ void AIntegrationGameModeBase::UpdateTangibles() { } void AIntegrationGameModeBase::UpdatePossessedTangible() { - bool updated = TangibleManager->SetPossessedTangible(PlayerId); - if (updated) { - UlxTangible *ptan = TangibleManager->GetPossessedTangible(); + UlxTangible *ptan = TangibleManager->GetPossessedTangible(); + UlxTangible *tan = TangibleManager->GetTangible(PlayerId); + APlayerController *ctrl = GetWorld()->GetFirstPlayerController(); + APawn *pawn = nullptr; + if (tan != nullptr) pawn = Cast(tan->GetActor()); + if (pawn == nullptr) { if (ptan != nullptr) { - IlxTangibleInterface::Execute_BecomePossessed(ptan->GetActor()); + TangibleManager->SetPossessedTangible(nullptr); + ctrl->Possess(nullptr); } - } + } else { + if (ptan != tan) { + TangibleManager->SetPossessedTangible(tan); + ctrl->Possess(pawn); + } + } } void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind, int64 place_id) { diff --git a/Source/Integration/Tangible.h b/Source/Integration/Tangible.h index d9699d05..a4e5c3b2 100644 --- a/Source/Integration/Tangible.h +++ b/Source/Integration/Tangible.h @@ -32,11 +32,10 @@ class INTEGRATION_API IlxTangibleInterface // Add interface functions to this class. This is the class that will be inherited to implement this interface. public: + // Whenever the animation queue of a tangible changes in any way, this function + // gets called automatically. UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Animation Queue") bool AnimationQueueChanged(); - - UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Tangible") - void BecomePossessed(); }; diff --git a/Source/Integration/TangibleManager.cpp b/Source/Integration/TangibleManager.cpp index de71a21d..45dac241 100644 --- a/Source/Integration/TangibleManager.cpp +++ b/Source/Integration/TangibleManager.cpp @@ -77,16 +77,6 @@ TanArray UlxTangibleManager::GetAllTangibles() const { return result; } -bool UlxTangibleManager::SetPossessedTangible(int64 id) { - UlxTangible *t = GetTangible(id); - if ((t == nullptr) || (t->GetActor() == nullptr)) { - t = nullptr; - } - bool changed = (t != PossessedTangible); - PossessedTangible = t; - return changed; -} - #pragma optimize("", off) void UlxTangibleManager::UpdateNearAccordingToLuprex(IdView near) { // Clear all the 'NearAccordingToLuprex' flags. diff --git a/Source/Integration/TangibleManager.h b/Source/Integration/TangibleManager.h index fc299cf5..8bcae11d 100644 --- a/Source/Integration/TangibleManager.h +++ b/Source/Integration/TangibleManager.h @@ -74,11 +74,7 @@ public: // Set the currently-possessed tangible. // - // You can also pass 0 for "no possessed tangible." - // - // Returns true if something changed. - // - bool SetPossessedTangible(int64 playerid); + void SetPossessedTangible(UlxTangible *tan) { PossessedTangible = tan; } // Update the 'NearAccordingToLuprex' flags. // diff --git a/Source/Integration/UtilityLibrary.cpp b/Source/Integration/UtilityLibrary.cpp index 1374b6c5..6a1b28ea 100644 --- a/Source/Integration/UtilityLibrary.cpp +++ b/Source/Integration/UtilityLibrary.cpp @@ -12,7 +12,7 @@ void UlxUtilityLibrary::Assert(bool condition, const FString &message) { } } -void UlxUtilityLibrary::CallFunctionByName(UObject *object, const FString &namepart1, const FString &namepart2, const FString &fallback) { +void UlxUtilityLibrary::CallFunctionByName(UObject *object, const FString &namepart1, const FString &namepart2, const FString &fallback, bool bFailIfNotFound) { FString fullname = namepart1 + namepart2; if (!IsValid(object)) { const FBlueprintExceptionInfo ExceptionInfo( @@ -26,6 +26,9 @@ void UlxUtilityLibrary::CallFunctionByName(UObject *object, const FString &namep if (function == nullptr) { function = object->FindFunction(FName(*fallback)); if (function == nullptr) { + if (!bFailIfNotFound) { + return; + } const FBlueprintExceptionInfo ExceptionInfo( EBlueprintExceptionType::FatalError, LOCTEXT("CallFunctionByName_NoSuchFunction", "In CallFunctionByName, cannot find the named function or the fallback function.") diff --git a/Source/Integration/UtilityLibrary.h b/Source/Integration/UtilityLibrary.h index 9e916cec..8d3dde94 100644 --- a/Source/Integration/UtilityLibrary.h +++ b/Source/Integration/UtilityLibrary.h @@ -27,7 +27,7 @@ public: // the fallback function instead. If that isn't found either, returns false. // UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Luprex|Utility") - static void CallFunctionByName(UObject *target, const FString &NamePart1, const FString &NamePart2, const FString &fallback); + static void CallFunctionByName(UObject *target, const FString &NamePart1, const FString &NamePart2, const FString &fallback, bool bFailIfNotFound = true); // Get the axis-aligned bounding box of an actor. //