diff --git a/SilentHillF/UETools.cpp b/SilentHillF/UETools.cpp new file mode 100644 index 0000000..053239b --- /dev/null +++ b/SilentHillF/UETools.cpp @@ -0,0 +1,17 @@ +#include "UETools.hpp" +#include "SDK/Engine_classes.hpp" + +SDK::APawn* GetPawnFromWorld(SDK::UWorld* world) { + if (!world) world = SDK::UWorld::GetWorld(); + if (!world) return nullptr; + + SDK::UGameInstance* gameInstance = world->OwningGameInstance; + if (!gameInstance || gameInstance->LocalPlayers.Num() == 0) return nullptr; + SDK::ULocalPlayer* localPlayer = gameInstance->LocalPlayers[0]; + if (!localPlayer) return nullptr; + SDK::APlayerController* pc = localPlayer->PlayerController; + if (!pc) return nullptr; + SDK::APawn* pawn = pc->AcknowledgedPawn; + + return pawn; +} \ No newline at end of file diff --git a/SilentHillF/UETools.hpp b/SilentHillF/UETools.hpp new file mode 100644 index 0000000..0c14d54 --- /dev/null +++ b/SilentHillF/UETools.hpp @@ -0,0 +1,16 @@ +#pragma once + +namespace SDK { + class UWorld; + class APawn; + class UGameInstance; + class ULocalPlayer; + class APlayerController; +} +// Unreal Engine functions +/** + * @brief Gets the current player Pawn from the world. + * @param world Optional UWorld pointer. + * @return Player Pawn or nullptr. + */ +SDK::APawn* GetPawnFromWorld(SDK::UWorld* world = nullptr); \ No newline at end of file