Skip to content

Commit

Permalink
fix: prefab cache preferred parent of ObjectDB from prefab instead of…
Browse files Browse the repository at this point in the history
… main scene
  • Loading branch information
MSchmoecker committed Dec 20, 2022
1 parent de34be7 commit a9d8db9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## Version 2.10.1
* Added [Server Troubleshooting](https://github.com/Valheim-Modding/Wiki/wiki/Server-Troubleshooting) link as a button to the compatibility window
* Changed "open log file" button to "open log folder" in the compatibility window
* Fixed an edge case where PrefabManager.Cache preferred the prefab for ObjectDB parent instead of the scene object
* Fixed an error when an independent mod adds a prefab twice to ObjectDB. A warning will be logged with the prefab name and hash to help debugging, but vanilla or other mods may still have issues with the double prefab
* Fixed an error when available pieces in the build hammer where not initialized properly
* Fixed an error that could occur when a build tab is localized
Expand Down
9 changes: 9 additions & 0 deletions JotunnLib/Managers/PrefabManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,15 @@ private static Object FindBestAsset(IDictionary<string, Object> map, Object unit
return unityObject;
}

// if a ObjectDB parent exists in the main scene, prefer it over the prefab
if (name == "_NetScene" && cached is GameObject cachedGo && unityObject is GameObject newGo)
{
if (!cachedGo.activeInHierarchy && newGo.activeInHierarchy)
{
return newGo;
}
}

bool cachedHasParent = GetParent(cached);
bool otherHasParent = GetParent(unityObject);

Expand Down

0 comments on commit a9d8db9

Please sign in to comment.