Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue when yield returning same request #498

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed missing reference when a prefab unloads
  • Loading branch information
Metious committed Dec 2, 2023
commit cdd31f63118a085b634765d0d129b8d580ac7487
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