@@ -9,7 +9,11 @@ local LocationsManager = {}
9
9
function LocationToString (Location )
10
10
if not Location or not Location .Name then return " " end
11
11
12
- return Location .Name .. " : Coordinates " .. VectorToString (Location .Location ) .. " , Rotation: " .. RotatorToString (Location .Rotation )
12
+ local result = Location .Name .. " : Coordinates " .. VectorToString (Location .Location ) .. " , Rotation: " .. RotatorToString (Location .Rotation )
13
+ if Location .LevelName then
14
+ result = result .. " , LevelName: " .. Location .LevelName
15
+ end
16
+ return result
13
17
end
14
18
15
19
--- @param Name string
@@ -77,14 +81,20 @@ function LocationsManager.LoadLocation(Name)
77
81
local myPlayer = AFUtils .GetMyPlayer ()
78
82
if myPlayer then
79
83
if location .LevelName then
80
- local outSuccess = { bSuccess = false }
81
- local outNotLoaded = { bNotLoaded = false }
82
- AFUtils .GetLevelStreamingCustom ():LoadStreamLevel (myPlayer , location .LevelName , true , false , outSuccess , outNotLoaded )
83
- LogDebug (" LoadLocation: LoadStreamLevel Success: " , outSuccess .bSuccess )
84
- LogDebug (" LoadLocation: LoadStreamLevel NotLoaded: " .. outNotLoaded .bNotLoaded )
85
- if not outSuccess or not outSuccess .bSuccess then
86
- LogError (" LoadLocation: Failed to LoadStreamLevel, LevelName: " .. location .LevelName )
87
- return false
84
+ local myPlayerController = AFUtils .GetMyPlayerController ()
85
+ if myPlayerController and myPlayerController .ActiveLevelName :ToString () ~= location .LevelName then
86
+ LogDebug (" LoadLocation: ActiveLevelName: " .. myPlayerController .ActiveLevelName :ToString ())
87
+ local outSuccess = { bSuccess = false }
88
+ local outNotLoaded = { bNotLoaded = false }
89
+ LogDebug (" LoadLocation: LoadStreamLevel with name: " .. location .LevelName )
90
+ local steamLevel = AFUtils .GetLevelStreamingCustom ():LoadStreamLevel (myPlayerController :GetWorld (), location .LevelName , false , false , outSuccess , outNotLoaded )
91
+ LogDebug (" LoadLocation: LoadStreamLevel Success: " , outSuccess .bSuccess )
92
+ LogDebug (" LoadLocation: LoadStreamLevel NotLoaded: " , outNotLoaded .bNotLoaded )
93
+ if not outSuccess or not outSuccess .bSuccess then
94
+ LogError (" LoadLocation: Failed to LoadStreamLevel, LevelName: " .. location .LevelName )
95
+ end
96
+ else
97
+ LogDebug (" LoadLocation: Skip LoadStreamLevel, ActiveLevelName and location LevelName are the same" )
88
98
end
89
99
else
90
100
LogInfo (" LoadLocation: Warning! Loading a Location wtihout a LevelName!" )
0 commit comments