mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-04 02:49:23 +00:00
Not harsh world restrictions
This commit is contained in:
parent
0e72b04386
commit
0808b5aaaa
4 changed files with 27 additions and 14 deletions
|
@ -49,8 +49,7 @@ namespace ml_prm
|
||||||
);
|
);
|
||||||
|
|
||||||
// Whitelist the toggle script
|
// Whitelist the toggle script
|
||||||
var l_localComponentWhitelist = typeof(SharedFilter).GetField("_localComponentWhitelist", BindingFlags.NonPublic | BindingFlags.Static)!.GetValue(null) as HashSet<Type>;
|
(typeof(SharedFilter).GetField("_localComponentWhitelist", BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null) as HashSet<Type>)?.Add(typeof(RagdollToggle));
|
||||||
l_localComponentWhitelist!.Add(typeof(RagdollToggle));
|
|
||||||
|
|
||||||
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,8 @@ namespace ml_prm
|
||||||
if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen())
|
if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen())
|
||||||
SwitchRagdoll();
|
SwitchRagdoll();
|
||||||
|
|
||||||
if (m_avatarRagdollToggle != null && m_avatarRagdollToggle.isActiveAndEnabled && m_avatarRagdollToggle.shouldOverride) {
|
if((m_avatarRagdollToggle != null) && m_avatarRagdollToggle.isActiveAndEnabled && m_avatarRagdollToggle.shouldOverride && (m_enabled != m_avatarRagdollToggle.isOn))
|
||||||
if (m_enabled != m_avatarRagdollToggle.isOn)
|
SwitchRagdoll();
|
||||||
SwitchRagdoll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LateUpdate()
|
void LateUpdate()
|
||||||
|
@ -98,6 +96,7 @@ namespace ml_prm
|
||||||
m_vrIK = null;
|
m_vrIK = null;
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
m_avatarReady = false;
|
m_avatarReady = false;
|
||||||
|
m_avatarRagdollToggle = null;
|
||||||
m_rigidBodies.Clear();
|
m_rigidBodies.Clear();
|
||||||
m_colliders.Clear();
|
m_colliders.Clear();
|
||||||
m_avatarReferences = new BipedRagdollReferences();
|
m_avatarReferences = new BipedRagdollReferences();
|
||||||
|
@ -158,7 +157,7 @@ namespace ml_prm
|
||||||
l_body.isKinematic = true;
|
l_body.isKinematic = true;
|
||||||
l_body.angularDrag = Settings.AngularDrag;
|
l_body.angularDrag = Settings.AngularDrag;
|
||||||
l_body.drag = Settings.MovementDrag;
|
l_body.drag = Settings.MovementDrag;
|
||||||
l_body.useGravity = Settings.Gravity;
|
l_body.useGravity = (!Utils.IsWorldSafe() || Settings.Gravity);
|
||||||
l_body.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
l_body.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +209,15 @@ namespace ml_prm
|
||||||
internal void OnWorldSpawn()
|
internal void OnWorldSpawn()
|
||||||
{
|
{
|
||||||
if(m_enabled && m_avatarReady)
|
if(m_enabled && m_avatarReady)
|
||||||
SwitchRagdoll(true);
|
SwitchRagdoll();
|
||||||
|
|
||||||
|
if(m_avatarReady)
|
||||||
|
{
|
||||||
|
foreach(Rigidbody l_body in m_rigidBodies)
|
||||||
|
{
|
||||||
|
l_body.useGravity = (!Utils.IsWorldSafe() || Settings.Gravity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IK updates
|
// IK updates
|
||||||
|
@ -250,15 +257,14 @@ namespace ml_prm
|
||||||
if(m_avatarReady)
|
if(m_avatarReady)
|
||||||
{
|
{
|
||||||
foreach(Rigidbody l_body in m_rigidBodies)
|
foreach(Rigidbody l_body in m_rigidBodies)
|
||||||
l_body.useGravity = p_state;
|
l_body.useGravity = (!Utils.IsWorldSafe() || p_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arbitrary
|
// Arbitrary
|
||||||
void SwitchRagdoll() => SwitchRagdoll(false);
|
public void SwitchRagdoll()
|
||||||
public void SwitchRagdoll(bool p_force = false)
|
|
||||||
{
|
{
|
||||||
if(m_avatarReady && (MovementSystem.Instance.lastSeat == null) && !BodySystem.isCalibrating && (Utils.IsWorldSafe() || p_force))
|
if(m_avatarReady && (MovementSystem.Instance.lastSeat == null) && !BodySystem.isCalibrating)
|
||||||
{
|
{
|
||||||
m_enabled = !m_enabled;
|
m_enabled = !m_enabled;
|
||||||
|
|
||||||
|
@ -273,7 +279,7 @@ namespace ml_prm
|
||||||
foreach(Rigidbody l_body in m_rigidBodies)
|
foreach(Rigidbody l_body in m_rigidBodies)
|
||||||
l_body.isKinematic = false;
|
l_body.isKinematic = false;
|
||||||
|
|
||||||
Vector3 l_velocity = m_velocity * Settings.VelocityMultiplier;
|
Vector3 l_velocity = m_velocity * Mathf.Clamp(Settings.VelocityMultiplier, 1f, (Utils.IsWorldSafe() ? Utils.GetWorldFlyMultiplier() : 1f));
|
||||||
foreach(Rigidbody l_body in m_rigidBodies)
|
foreach(Rigidbody l_body in m_rigidBodies)
|
||||||
{
|
{
|
||||||
l_body.velocity = l_velocity;
|
l_body.velocity = l_velocity;
|
||||||
|
|
|
@ -6,7 +6,14 @@ namespace ml_prm
|
||||||
static class Utils
|
static class Utils
|
||||||
{
|
{
|
||||||
public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);
|
public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);
|
||||||
public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying && CVRWorld.Instance.allowSpawnables);
|
public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying);
|
||||||
|
public static float GetWorldFlyMultiplier()
|
||||||
|
{
|
||||||
|
float l_result = 1f;
|
||||||
|
if(CVRWorld.Instance != null)
|
||||||
|
l_result = CVRWorld.Instance.flyMultiplier;
|
||||||
|
return l_result;
|
||||||
|
}
|
||||||
|
|
||||||
public static void CopyGlobal(this Transform p_source, Transform p_target)
|
public static void CopyGlobal(this Transform p_source, Transform p_target)
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,6 +89,7 @@
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="RagdollController.cs" />
|
<Compile Include="RagdollController.cs" />
|
||||||
|
<Compile Include="RagdollToggle.cs" />
|
||||||
<Compile Include="Settings.cs" />
|
<Compile Include="Settings.cs" />
|
||||||
<Compile Include="Utils.cs" />
|
<Compile Include="Utils.cs" />
|
||||||
<Compile Include="vendor\RootMotion\PuppetMaster\Scripts\AnimationBlocker.cs" />
|
<Compile Include="vendor\RootMotion\PuppetMaster\Scripts\AnimationBlocker.cs" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue