Skip to content

Commit

Permalink
fixed issue with modifying the parent coordinates of a piece of furni…
Browse files Browse the repository at this point in the history
…ture, causing the player to fall through the world
  • Loading branch information
WulfMarius committed Jun 22, 2018
1 parent ae3cb7b commit b8ef14d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions VisualStudio/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0")]
[assembly: AssemblyFileVersion("2.1.0")]
[assembly: AssemblyVersion("2.1.1")]
[assembly: AssemblyFileVersion("2.1.1")]
10 changes: 10 additions & 0 deletions VisualStudio/src/BetterPlacing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ internal static void PrepareGearItems()
RemovePickupHelper(Resources.Load<GameObject>("GEAR_PackMatches"));
}

internal static GameObject getFurnitureRoot(GameObject gameObject)
{
if (gameObject.GetComponent<LODGroup>() != null)
{
return gameObject;
}

return getFurnitureRoot(gameObject.transform.parent.gameObject);
}

internal static void PreparePlacableFurniture(GameObject gameObject)
{
if (!gameObject.GetComponentInChildren<Renderer>().isPartOfStaticBatch)
Expand Down
17 changes: 7 additions & 10 deletions VisualStudio/src/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ private static bool Prefix(BreakDown __instance, string text)
return true;
}

__instance.gameObject.SetActive(true);
BetterPlacing.PreparePlacableFurniture(__instance.gameObject);

__instance.transform.parent.position = saveData.m_Position;
__instance.gameObject.SetActive(true);
GameObject root = BetterPlacing.getFurnitureRoot(__instance.gameObject);

root.transform.position = saveData.m_Position;
if (saveData.m_Rotation.x != 0 || saveData.m_Rotation.y != 0 || saveData.m_Rotation.z != 0)
{
__instance.transform.parent.rotation = Quaternion.Euler(saveData.m_Rotation);
root.transform.rotation = Quaternion.Euler(saveData.m_Rotation);
}

return false;
Expand Down Expand Up @@ -235,13 +237,8 @@ public static bool Prefix(PlayerManager __instance)
{
BetterPlacing.PreparePlacableFurniture(gameObject);

LODGroup lodGroup = gameObject.GetComponentInParent<LODGroup>();
if (lodGroup != null)
{
gameObject = lodGroup.gameObject;
}

__instance.StartPlaceMesh(gameObject, 5f, false);
GameObject root = BetterPlacing.getFurnitureRoot(gameObject);
__instance.StartPlaceMesh(root, 5f, false);

return false;
}
Expand Down

0 comments on commit b8ef14d

Please sign in to comment.