A Bunch of miscellaneous refactoring

This commit is contained in:
2024-09-24 22:13:56 -04:00
parent 0b7049cf5a
commit a295ff5e53
13 changed files with 33 additions and 36 deletions

View File

@@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -143,11 +143,20 @@ void AIntegrationGameModeBase::UpdateTangibles() {
}
void AIntegrationGameModeBase::UpdatePossessedTangible() {
bool updated = TangibleManager->SetPossessedTangible(PlayerId);
if (updated) {
UlxTangible *ptan = TangibleManager->GetPossessedTangible();
UlxTangible *tan = TangibleManager->GetTangible(PlayerId);
APlayerController *ctrl = GetWorld()->GetFirstPlayerController();
APawn *pawn = nullptr;
if (tan != nullptr) pawn = Cast<APawn>(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);
}
}
}

View File

@@ -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();
};

View File

@@ -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.

View File

@@ -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.
//

View File

@@ -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.")

View File

@@ -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.
//