Skip to content

Commit

Permalink
refactor(UEHelpers): In GetWorld() get UWorld from PlayerController, …
Browse files Browse the repository at this point in the history
…fallback to GameInstance if a PlayerController doesn't exist
  • Loading branch information
igromanru authored and UE4SS committed Nov 26, 2024
1 parent 65a9727 commit b47690f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions assets/Mods/shared/UEHelpers/UEHelpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ local WorldCache = CreateInvalidObject() ---@cast WorldCache UWorld
function UEHelpers.GetWorld()
if WorldCache:IsValid() then return WorldCache end

local GameInstance = UEHelpers.GetGameInstance()
if GameInstance:IsValid() then
WorldCache = GameInstance:GetWorld()
else -- Worst case fallback, usaully should never happen
local PlayerController = UEHelpers.GetPlayerController()
if PlayerController:IsValid() then
WorldCache = PlayerController:GetWorld()
local PlayerController = UEHelpers.GetPlayerController()
if PlayerController:IsValid() then
WorldCache = PlayerController:GetWorld()
else
local GameInstance = UEHelpers.GetGameInstance()
if GameInstance:IsValid() then
WorldCache = GameInstance:GetWorld()
end
end
return WorldCache
Expand Down

0 comments on commit b47690f

Please sign in to comment.