Skip to content

Commit

Permalink
Fixed equipment not showing and camera lock when action menu opened
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikeiwa committed Feb 14, 2022
1 parent 020add2 commit d52f223
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
13 changes: 8 additions & 5 deletions PluginSolution/PlayerModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class MenuControl
private List<MenuControl> menuControls;


private bool showMenu;
public static bool showMenu { get; private set; }
private Rect windowRect;
private CursorLockMode oldCursorLockState = CursorLockMode.Confined;
private bool oldCursorVisible = false;
Expand Down Expand Up @@ -204,7 +204,6 @@ private void LateUpdate()

if (showMenu)
{
SetUnlockCursor();
if(hasChangedParam > 0)
hasChangedParam--;
}
Expand All @@ -214,8 +213,6 @@ private void OnGUI()
{
if (showMenu)
{
SetUnlockCursor();

windowRect = new Rect(Screen.width, Screen.height, 250, 400);
windowRect.x -= windowRect.width;
windowRect.y -= windowRect.height;
Expand Down Expand Up @@ -660,7 +657,7 @@ public void ToggleEquipments(bool visible = false)
itemInstance?.SetActive(visible || avatarDescriptor.showCape);
foreach (SkinnedMeshRenderer skinnedMeshRenderer in itemInstance.GetComponentsInChildren<SkinnedMeshRenderer>())
{
skinnedMeshRenderer.forceRenderingOff = visible;
skinnedMeshRenderer.forceRenderingOff = false;
skinnedMeshRenderer.updateWhenOffscreen = true;
}
}
Expand All @@ -681,6 +678,12 @@ public void ToggleEquipments(bool visible = false)
attachTransform.ogAttach.localRotation = attachTransform.ogRotation;
attachTransform.ogAttach.localScale = attachTransform.ogScale;
}

foreach (SkinnedMeshRenderer skinnedMeshRenderer in ogVisual.GetComponentsInChildren<SkinnedMeshRenderer>())
{
skinnedMeshRenderer.forceRenderingOff = false;
skinnedMeshRenderer.updateWhenOffscreen = true;
}
}

requestHide = false;
Expand Down
24 changes: 24 additions & 0 deletions PluginSolution/PlayerModelPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,29 @@ static void Postfix(Terminal __instance, string text, bool silentFail = false, b
}
}
}

[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
static class Patch_GameCamera_UpdateMouseCapture
{
[HarmonyPrefix]
static bool Prefix(GameCamera __instance)
{
if (PluginConfig.enablePlayerModels.Value && PlayerModel.showMenu)
return false;
return true;
}
}

[HarmonyPatch(typeof(Player), "SetMouseLook")]
static class Patch_Player_SetMouseLook
{
[HarmonyPrefix]
static bool Prefix(Player __instance)
{
if (PluginConfig.enablePlayerModels.Value && PlayerModel.showMenu)
return false;
return true;
}
}
}
#endif
2 changes: 1 addition & 1 deletion PluginSolution/ValheimPlayerModels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="if $(ConfigurationName) == SDK (&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\UnitySDK\ValheimPlayerModelsSDK\&quot; /y&#xD;&#xA;) ELSE (&#xD;&#xA; echo Edit the Post-build event to export the plugin in your game folder&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;F:\Steam\steamapps\common\Valheim\BepInEx\plugins\$(TargetFileName)&quot; /y&#xD;&#xA;)" />
<Exec Command="if $(ConfigurationName) == SDK (&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\UnitySDK\ValheimPlayerModelsSDK\&quot; /y&#xD;&#xA;) ELSE (&#xD;&#xA; echo Edit the Post-build event to export the plugin in your game folder&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;C:\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\plugins\$(TargetFileName)&quot; /y&#xD;&#xA;)" />
</Target>
</Project>

0 comments on commit d52f223

Please sign in to comment.