Skip to content

Commit

Permalink
Fixed missing reference when a prefab unloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Metious committed Dec 2, 2023
1 parent 5201093 commit cdd31f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Nautilus/Assets/ModPrefabRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ internal class ModPrefabRequest: IPrefabRequest

private TaskResult<GameObject> taskResult;

internal bool done;

public ModPrefabRequest(PrefabInfo prefabInfo)
{
this.prefabInfo = prefabInfo;
Expand Down Expand Up @@ -50,6 +52,10 @@ public object Current
public bool TryGetPrefab(out GameObject result)
{
result = taskResult.Get();
if (!done)
{
done = result;
}
return result != null;
}

Expand Down
7 changes: 7 additions & 0 deletions Nautilus/Patchers/PrefabDatabasePatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ private static IPrefabRequest GetModPrefabAsync(string classId)
}

if(ModPrefabCache.Requests.TryGetValue(prefabInfo.ClassID, out var request))
{
if (request.done && !request.TryGetPrefab(out _))
{
return new ModPrefabRequest(prefabInfo);
}

return request;
}

return new ModPrefabRequest(prefabInfo);
}
Expand Down

0 comments on commit cdd31f6

Please sign in to comment.