mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
fixed centered collision, updated skinwidth to match latest patch
This commit is contained in:
parent
27c442a41b
commit
32c3ebc6ef
4 changed files with 31 additions and 22 deletions
|
@ -17,6 +17,8 @@ public class MenuScalePatch : MelonMod
|
||||||
private static MelonPreferences_Entry<bool> m_entryScaleCollision;
|
private static MelonPreferences_Entry<bool> m_entryScaleCollision;
|
||||||
private static MelonPreferences_Entry<bool> m_entrySkinWidthLimit;
|
private static MelonPreferences_Entry<bool> m_entrySkinWidthLimit;
|
||||||
|
|
||||||
|
private static float defaultSkinWidth = 0f;
|
||||||
|
|
||||||
public override void OnApplicationStart()
|
public override void OnApplicationStart()
|
||||||
{
|
{
|
||||||
m_categoryMenuScalePatch = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
|
m_categoryMenuScalePatch = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
|
||||||
|
@ -41,12 +43,11 @@ public class MenuScalePatch : MelonMod
|
||||||
|
|
||||||
if (!m_entryScaleCollision.Value)
|
if (!m_entryScaleCollision.Value)
|
||||||
{
|
{
|
||||||
controller.skinWidth = 0.08f;
|
controller.skinWidth = defaultSkinWidth;
|
||||||
MovementSystem.Instance.UpdateAvatarHeightFactor(1f);
|
MovementSystem.Instance.UpdateAvatarHeightFactor(1f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
controller.skinWidth = (m_entrySkinWidthLimit.Value ? 0.001f : 0.08f);
|
|
||||||
float _avatarHeight = Traverse.Create(PlayerSetup.Instance).Field("_avatarHeight").GetValue<float>();
|
float _avatarHeight = Traverse.Create(PlayerSetup.Instance).Field("_avatarHeight").GetValue<float>();
|
||||||
MovementSystem.Instance.UpdateAvatarHeightFactor(_avatarHeight);
|
MovementSystem.Instance.UpdateAvatarHeightFactor(_avatarHeight);
|
||||||
}
|
}
|
||||||
|
@ -65,21 +66,29 @@ public class MenuScalePatch : MelonMod
|
||||||
if (!_controllerScaleCollision) return;
|
if (!_controllerScaleCollision) return;
|
||||||
//avatar height = viewpoint height
|
//avatar height = viewpoint height
|
||||||
//heightfactor = viewpoint height * scale difference
|
//heightfactor = viewpoint height * scale difference
|
||||||
//___controller.stepOffset = 0.0001f; (this is 0.3 or 0 based on groundedraw..)
|
|
||||||
//unity docs say to not put skinwidth too low, or you chance getting stuck often
|
//unity docs say to not put skinwidth too low, or you chance getting stuck often
|
||||||
//because i cant overwrite stepOffset, ill limit height to min of 0.3 to prevent console spam
|
//but removing skinWidth allows your character to completely touch the floor
|
||||||
|
|
||||||
|
//grab the original skinWidth if it wasn't already logged
|
||||||
|
if (defaultSkinWidth == 0f) defaultSkinWidth = ___controller.skinWidth;
|
||||||
|
|
||||||
|
float skinWidth = (m_entrySkinWidthLimit.Value ? 0.001f : defaultSkinWidth);
|
||||||
|
//to prevent falling anims when smol- take skinWidth into maths
|
||||||
|
___controller.skinWidth = skinWidth;
|
||||||
|
___groundDistance = ___controller.radius + skinWidth;
|
||||||
|
___groundCheck.localPosition = ____colliderCenter + Vector3.up * skinWidth;
|
||||||
|
|
||||||
|
//scale charactercontroller collision (take allow small player collider setting into account)
|
||||||
___controller.height = Mathf.Max(____avatarHeightFactor, ____minimumColliderRadius);
|
___controller.height = Mathf.Max(____avatarHeightFactor, ____minimumColliderRadius);
|
||||||
___controller.radius = Mathf.Max(____avatarHeightFactor / 6f, ____minimumColliderRadius); ;
|
___controller.radius = Mathf.Max(____avatarHeightFactor / 6f, ____minimumColliderRadius);
|
||||||
___controller.center = Vector3.up * (___controller.height * 0.5f);
|
___controller.center = ____colliderCenter + Vector3.up * (___controller.height * 0.5f);
|
||||||
___groundDistance = ___controller.radius;
|
|
||||||
|
|
||||||
|
//match the proxy and force colliders to the scaled charactercontroller
|
||||||
___proxyCollider.height = ___controller.height;
|
___proxyCollider.height = ___controller.height;
|
||||||
___proxyCollider.radius = ___controller.radius;
|
___proxyCollider.radius = ___controller.radius;
|
||||||
___proxyCollider.center = ___controller.center;
|
___proxyCollider.center = ___controller.center;
|
||||||
|
|
||||||
___forceObject.transform.localScale = new Vector3(___controller.radius + 0.1f, ___controller.height, ___controller.radius + 0.1f);
|
___forceObject.transform.localScale = new Vector3(___controller.radius + 0.1f, ___controller.height, ___controller.radius + 0.1f);
|
||||||
___groundCheck.localPosition = ____colliderCenter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
|
@ -105,7 +114,7 @@ public class MenuScalePatch : MelonMod
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ViewManager), "SetScale")]
|
[HarmonyPatch(typeof(ViewManager), "SetScale")]
|
||||||
private static void CheckLegit(float avatarHeight, ref ViewManager __instance, ref float ___cachedScreenAspectRatio, ref float ___cachedAvatarHeight, out bool __state)
|
private static void CheckLegit(float avatarHeight, ref float ___cachedAvatarHeight, out bool __state)
|
||||||
{
|
{
|
||||||
if (___cachedAvatarHeight == avatarHeight)
|
if (___cachedAvatarHeight == avatarHeight)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.2.32630.192
|
VisualStudioVersion = 17.2.32630.192
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvatarScaleUpdater", "AvatarScaleUpdater.csproj", "{1B069D34-0AD6-43A4-A116-C325F37D33A6}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MenuScalePatch", "MenuScalePatch.csproj", "{19D9CD91-0387-4E35-AFCD-BAB15AEC9765}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -11,15 +11,15 @@ Global
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{1B069D34-0AD6-43A4-A116-C325F37D33A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{19D9CD91-0387-4E35-AFCD-BAB15AEC9765}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{1B069D34-0AD6-43A4-A116-C325F37D33A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{19D9CD91-0387-4E35-AFCD-BAB15AEC9765}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1B069D34-0AD6-43A4-A116-C325F37D33A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{19D9CD91-0387-4E35-AFCD-BAB15AEC9765}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1B069D34-0AD6-43A4-A116-C325F37D33A6}.Release|Any CPU.Build.0 = Release|Any CPU
|
{19D9CD91-0387-4E35-AFCD-BAB15AEC9765}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {67335521-EBA9-453E-A0E2-3DE0E3A86EBF}
|
SolutionGuid = {4E0D4C6B-166C-4456-BAD7-6A358308116E}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -25,6 +25,6 @@ using System.Reflection;
|
||||||
namespace MenuScalePatch.Properties;
|
namespace MenuScalePatch.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "1.0.0";
|
public const string Version = "1.1.0";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"_id": -1,
|
"_id": 95,
|
||||||
"name": "MenuScalePatch",
|
"name": "MenuScalePatch",
|
||||||
"modversion": "1.0.0",
|
"modversion": "1.1.0",
|
||||||
"gameversion": "2022r168",
|
"gameversion": "2022r168",
|
||||||
"loaderversion": "0.5.4",
|
"loaderversion": "0.5.4",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
"author": "NotAKidoS",
|
"author": "NotAKidoS",
|
||||||
"description": "Corrects MM and QM position when avatar is scaled.",
|
"description": "Corrects MM and QM position when avatar is scaled.\nAdditional option to scale player collision.",
|
||||||
"searchtags": [
|
"searchtags": [
|
||||||
"menu",
|
"menu",
|
||||||
"scale",
|
"scale",
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r1/MenuScalePatch.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r2/MenuScalePatch.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
|
||||||
"changelog": "Initial Release.",
|
"changelog": "Added option to scale player collision. Fixed some VR specific issues.",
|
||||||
"embedcolor": "804221"
|
"embedcolor": "804221"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue