Skip to content

Commit

Permalink
fixed compat issue with rune magic caused by prefab processors not ex…
Browse files Browse the repository at this point in the history
…pecting the piece component to be destroyed
  • Loading branch information
ontrigger committed Aug 27, 2021
1 parent 0ddc6c2 commit 4e18be8
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public static void Postfix(ZoneSystem __instance)

// skip prefabs with multiple mods for now
if (prefab.GetComponentsInChildren<TerrainModifier>().Length > 1) { continue; }

// skip viewless prefabs
if (prefab.GetComponentInChildren<ZNetView>() == null) {continue;}
if (prefab.GetComponentInChildren<ZNetView>() == null) { continue; }

ExtractPrefabProcessors(prefab);

Expand All @@ -94,7 +94,6 @@ public static void Postfix(ZoneSystem __instance)
ZNetView.StartGhostInit();

CreateZoneSystemPool(maxObjectsByVegetation);

CreateZNetScenePool(maxObjectsByVegetation);
ZNetView.FinishGhostInit();
}
Expand Down Expand Up @@ -203,6 +202,7 @@ private static void WearNTearDisabledProcessor(ComponentCache componentCache)
private static void PieceEnabledProcessor(ComponentCache componentCache)
{
var piece = componentCache.Piece;
if (piece == null) { return; }

Piece.m_allPieces.Add(piece);
piece.m_myListIndex = Piece.m_allPieces.Count - 1;
Expand All @@ -211,6 +211,9 @@ private static void PieceEnabledProcessor(ComponentCache componentCache)

private static void PieceDisabledProcessor(ComponentCache componentCache)
{
// RuneMagic destroys the piece component on some rocks causing the unchecked code to crash
if (componentCache.Piece == null) { return; }

componentCache.Piece.OnDestroy();
}

Expand Down

0 comments on commit 4e18be8

Please sign in to comment.