Skip to content

Commit

Permalink
more nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tonetfal committed Dec 11, 2024
1 parent b5aeacc commit c8da4a1
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 5 deletions.
Binary file modified Docs/all_nodes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Plugins/TonetfalCommonUtilities/Content/BML_Common.uasset
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "GameFramework/PlayerState.h"
#include "Kismet/GameplayStatics.h"

#define LOCTEXT_NAMESPACE "TonetfalCommonUtilities"

#pragma region Blueprints
#pragma region TypedGetters
AGameStateBase* UTCU_Library::GetTypedGameState(const UObject* ContextObject,
Expand Down Expand Up @@ -66,10 +68,28 @@ const AWorldSettings* UTCU_Library::GetWorldSettings(const UObject* ContextObjec
}

APlayerController* UTCU_Library::GetTypedPlayerController(const UObject* ContextObject,
TSubclassOf<APlayerController> Class, int32 PlayerIndex)
TSubclassOf<APlayerController> Class, int32 PlayerIndex, bool bLocalOnly)
{
APlayerController* Controller = UGameplayStatics::GetPlayerController(ContextObject, PlayerIndex);
return IsValid(Controller) && Controller->IsA(Class) ? Controller : nullptr;
if (!bLocalOnly)
{
APlayerController* Controller = UGameplayStatics::GetPlayerController(ContextObject, PlayerIndex);
return IsValid(Controller) && Controller->IsA(Class) ? Controller : nullptr;
}

const UWorld* World = GEngine->GetWorldFromContextObject(ContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (IsValid(World))
{
for (FConstPlayerControllerIterator Iterator = World->GetPlayerControllerIterator(); Iterator; ++Iterator)
{
APlayerController* PlayerController = Iterator->Get();
if (IsValid(PlayerController) && bLocalOnly && PlayerController->IsLocalController())
{
return PlayerController;
}
}
}

return nullptr;
}

ULocalPlayer* UTCU_Library::GetTypedLocalPlayer(const UObject* ContextObject, TSubclassOf<ULocalPlayer> Class,
Expand Down Expand Up @@ -500,3 +520,24 @@ bool UTCU_Library::IsDedicatedServer(const UObject* WorldContextObject)
}
#pragma endregion
#pragma endregion

UTCU_Settings::UTCU_Settings()
{
CategoryName = "Plugins";
SectionName = "Tonetfal's Common Utilities";
}

#if WITH_EDITOR
FText UTCU_Settings::GetSectionText() const
{
return LOCTEXT("SettingsDisplayName", "Tonetfal's Common Utilities");
}
#endif

float UTCU_Settings::GetMaxWaitingTime()
{
const auto* This = GetDefault<ThisClass>();
return This->MaxWaitingTime;
}

#undef LOCTEXT_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TONETFALCOMMONUTILITIES_API UTCU_Library

UFUNCTION(BlueprintPure, Category="Game", meta=(WorldContext="ContextObject", DeterminesOutputType="Class"))
static APlayerController* GetTypedPlayerController(const UObject* ContextObject,
TSubclassOf<APlayerController> Class, int32 PlayerIndex);
TSubclassOf<APlayerController> Class, int32 PlayerIndex, bool bLocalOnly);

UFUNCTION(BlueprintPure, Category="Game", meta=(DefaultToSelf="ContextObject", HidePin="ContextObject",
DeterminesOutputType="SettingsClass"))
Expand Down Expand Up @@ -497,3 +497,27 @@ int32 UTCU_Library::GetHighestIndex(const TArray<UserClass>& Array, int32 Index)
}
#pragma endregion
#pragma endregion

UCLASS(DefaultConfig, Config="Engine")
class TONETFALCOMMONUTILITIES_API UTCU_Settings
: public UDeveloperSettings
{
GENERATED_BODY()

public:
UTCU_Settings();

#if WITH_EDITOR
//~UDeveloperSettings Interface
virtual FText GetSectionText() const override;
//~End of UDeveloperSettings Interface
#endif

UFUNCTION(BlueprintPure)
static float GetMaxWaitingTime();

public:
/** Max time WaitUntilValid can be active for. Any non-positive value means that there's no limit. */
UPROPERTY(Config, EditAnywhere, meta=(Units="seconds"))
float MaxWaitingTime = 60.f;
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public TonetfalCommonUtilities(ReadOnlyTargetRules Target) : base(Target)
new string[]
{
"Core",
"DeveloperSettings",
}
);

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ into your project's root.

## Usage

<img src="Docs/all_nodes.png" alt="Docs/all_nodes.png">
<img src="Docs/all_nodes.png" alt="Docs/all_nodes.png">
<img src="Docs/settings.png" alt="Docs/settings.png">

0 comments on commit c8da4a1

Please sign in to comment.