mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39: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
|
||||
var l_localComponentWhitelist = typeof(SharedFilter).GetField("_localComponentWhitelist", BindingFlags.NonPublic | BindingFlags.Static)!.GetValue(null) as HashSet<Type>;
|
||||
l_localComponentWhitelist!.Add(typeof(RagdollToggle));
|
||||
(typeof(SharedFilter).GetField("_localComponentWhitelist", BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null) as HashSet<Type>)?.Add(typeof(RagdollToggle));
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
||||
}
|
||||
|
|
|
@ -70,10 +70,8 @@ namespace ml_prm
|
|||
if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen())
|
||||
SwitchRagdoll();
|
||||
|
||||
if (m_avatarRagdollToggle != null && m_avatarRagdollToggle.isActiveAndEnabled && m_avatarRagdollToggle.shouldOverride) {
|
||||
if (m_enabled != m_avatarRagdollToggle.isOn)
|
||||
SwitchRagdoll();
|
||||
}
|
||||
if((m_avatarRagdollToggle != null) && m_avatarRagdollToggle.isActiveAndEnabled && m_avatarRagdollToggle.shouldOverride && (m_enabled != m_avatarRagdollToggle.isOn))
|
||||
SwitchRagdoll();
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
|
@ -98,6 +96,7 @@ namespace ml_prm
|
|||
m_vrIK = null;
|
||||
m_enabled = false;
|
||||
m_avatarReady = false;
|
||||
m_avatarRagdollToggle = null;
|
||||
m_rigidBodies.Clear();
|
||||
m_colliders.Clear();
|
||||
m_avatarReferences = new BipedRagdollReferences();
|
||||
|
@ -158,7 +157,7 @@ namespace ml_prm
|
|||
l_body.isKinematic = true;
|
||||
l_body.angularDrag = Settings.AngularDrag;
|
||||
l_body.drag = Settings.MovementDrag;
|
||||
l_body.useGravity = Settings.Gravity;
|
||||
l_body.useGravity = (!Utils.IsWorldSafe() || Settings.Gravity);
|
||||
l_body.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
||||
}
|
||||
|
||||
|
@ -210,7 +209,15 @@ namespace ml_prm
|
|||
internal void OnWorldSpawn()
|
||||
{
|
||||
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
|
||||
|
@ -250,15 +257,14 @@ namespace ml_prm
|
|||
if(m_avatarReady)
|
||||
{
|
||||
foreach(Rigidbody l_body in m_rigidBodies)
|
||||
l_body.useGravity = p_state;
|
||||
l_body.useGravity = (!Utils.IsWorldSafe() || p_state);
|
||||
}
|
||||
}
|
||||
|
||||
// Arbitrary
|
||||
void SwitchRagdoll() => SwitchRagdoll(false);
|
||||
public void SwitchRagdoll(bool p_force = false)
|
||||
public void SwitchRagdoll()
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -273,7 +279,7 @@ namespace ml_prm
|
|||
foreach(Rigidbody l_body in m_rigidBodies)
|
||||
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)
|
||||
{
|
||||
l_body.velocity = l_velocity;
|
||||
|
|
|
@ -6,7 +6,14 @@ namespace ml_prm
|
|||
static class Utils
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RagdollController.cs" />
|
||||
<Compile Include="RagdollToggle.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
<Compile Include="vendor\RootMotion\PuppetMaster\Scripts\AnimationBlocker.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue