Removed jump height

Added changable ragdoll button
Minor edits
This commit is contained in:
SDraw 2023-09-19 11:26:43 +03:00
parent 0fccd9e892
commit 6f9a278694
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
21 changed files with 59 additions and 86 deletions

View file

@ -1,7 +1,7 @@
[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.0.8", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.0.9", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonPriority(2)]
[assembly: MelonLoader.MelonOptionalDependencies("BTKUILib")]
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
[assembly: MelonLoader.MelonAdditionalCredits("kafeijao, NotAKidOnSteam")]
[assembly: MelonLoader.MelonAdditionalCredits("kafeijao, NotAKidOnSteam")]

View file

@ -34,6 +34,9 @@ Optional mod's settings page with [BTKUILib](https://github.com/BTK-Development/
* **Recover delay:** time delay for enabled `Auto recover` in seconds; `3.0` by default.
* **Reset settings:** resets mod settings to default.
Optional mod's settings in [UIExpansionKit](https://github.com/ddakebono/ChilloutMods):
* **Hotkey:** system key that is used to switch ragdoll state; `R` by default.
Available additional parameters for AAS animator:
* **`Ragdolled`:** defines current ragdoll state; boolean.
* Note: Can be set as local-only (not synced) if starts with `#` character.

View file

@ -15,6 +15,8 @@ namespace ml_prm
[DisallowMultipleComponent]
public class RagdollController : MonoBehaviour
{
const float c_defaultFriction = 0.6f;
public static RagdollController Instance { get; private set; } = null;
VRIK m_vrIK = null;
@ -56,8 +58,8 @@ namespace ml_prm
m_jointAnchors = new List<System.Tuple<CharacterJoint, Vector3>>();
m_physicsMaterial = new PhysicMaterial("Ragdoll");
m_physicsMaterial.dynamicFriction = 0.5f;
m_physicsMaterial.staticFriction = 0.5f;
m_physicsMaterial.dynamicFriction = c_defaultFriction;
m_physicsMaterial.staticFriction = c_defaultFriction;
m_physicsMaterial.frictionCombine = PhysicMaterialCombine.Average;
m_physicsMaterial.bounciness = 0f;
m_physicsMaterial.bounceCombine = PhysicMaterialCombine.Average;
@ -145,7 +147,7 @@ namespace ml_prm
if((m_customTrigger != null) && m_customTrigger.GetStateWithReset() && m_avatarReady && !m_enabled && Settings.PointersReaction)
SwitchRagdoll();
if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen())
if(Settings.Hotkey && Input.GetKeyDown(Settings.HotkeyKey) && !ViewManager.Instance.isGameMenuOpen())
SwitchRagdoll();
if(m_avatarReady && m_enabled && CVRInputManager.Instance.jump && Settings.JumpRecover)
@ -415,8 +417,8 @@ namespace ml_prm
{
bool l_slipperiness = (Settings.Slipperiness && Utils.IsWorldSafe());
bool l_bounciness = (Settings.Bounciness && Utils.IsWorldSafe());
m_physicsMaterial.dynamicFriction = (l_slipperiness ? 0f : 0.5f);
m_physicsMaterial.staticFriction = (l_slipperiness ? 0f : 0.5f);
m_physicsMaterial.dynamicFriction = (l_slipperiness ? 0f : c_defaultFriction);
m_physicsMaterial.staticFriction = (l_slipperiness ? 0f : c_defaultFriction);
m_physicsMaterial.frictionCombine = (l_slipperiness ? PhysicMaterialCombine.Minimum : PhysicMaterialCombine.Average);
m_physicsMaterial.bounciness = (l_bounciness ? 1f : 0f);
m_physicsMaterial.bounceCombine = (l_bounciness ? PhysicMaterialCombine.Maximum : PhysicMaterialCombine.Average);

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace ml_prm
@ -10,6 +9,7 @@ namespace ml_prm
public enum ModSetting
{
Hotkey = 0,
HotkeyKey,
VelocityMultiplier,
MovementDrag,
AngularDrag,
@ -26,6 +26,7 @@ namespace ml_prm
}
public static bool Hotkey { get; private set; } = true;
public static KeyCode HotkeyKey { get; private set; } = KeyCode.R;
public static float VelocityMultiplier { get; private set; } = 2f;
public static float MovementDrag { get; private set; } = 2f;
public static float AngularDrag { get; private set; } = 2f;
@ -41,6 +42,7 @@ namespace ml_prm
public static bool JumpRecover { get; private set; } = false;
static public event Action<bool> HotkeyChange;
static public event Action<KeyCode> HotkeyKeyChange;
static public event Action<float> VelocityMultiplierChange;
static public event Action<float> MovementDragChange;
static public event Action<float> AngularDragChange;
@ -60,26 +62,31 @@ namespace ml_prm
internal static void Init()
{
ms_category = MelonLoader.MelonPreferences.CreateCategory("PRM", null, true);
ms_category = MelonLoader.MelonPreferences.CreateCategory("PRM", "Player Ragdoll Mod");
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
{
ms_category.CreateEntry(ModSetting.Hotkey.ToString(), Hotkey),
ms_category.CreateEntry(ModSetting.VelocityMultiplier.ToString(), VelocityMultiplier),
ms_category.CreateEntry(ModSetting.MovementDrag.ToString(), MovementDrag),
ms_category.CreateEntry(ModSetting.AngularDrag.ToString(), AngularDrag),
ms_category.CreateEntry(ModSetting.Gravity.ToString(), Gravity),
ms_category.CreateEntry(ModSetting.PointersReaction.ToString(), PointersReaction),
ms_category.CreateEntry(ModSetting.IgnoreLocal.ToString(), IgnoreLocal),
ms_category.CreateEntry(ModSetting.CombatReaction.ToString(), CombatReaction),
ms_category.CreateEntry(ModSetting.AutoRecover.ToString(), AutoRecover),
ms_category.CreateEntry(ModSetting.RecoverDelay.ToString(), RecoverDelay),
ms_category.CreateEntry(ModSetting.Slipperiness.ToString(), Slipperiness),
ms_category.CreateEntry(ModSetting.Bounciness.ToString(), Bounciness),
ms_category.CreateEntry(ModSetting.ViewVelocity.ToString(), ViewVelocity),
ms_category.CreateEntry(ModSetting.JumpRecover.ToString(), JumpRecover)
ms_category.CreateEntry(ModSetting.Hotkey.ToString(), Hotkey, null, null, true),
ms_category.CreateEntry(ModSetting.HotkeyKey.ToString(), HotkeyKey, "Hotkey"),
ms_category.CreateEntry(ModSetting.VelocityMultiplier.ToString(), VelocityMultiplier, null, null, true),
ms_category.CreateEntry(ModSetting.MovementDrag.ToString(), MovementDrag, null, null, true),
ms_category.CreateEntry(ModSetting.AngularDrag.ToString(), AngularDrag, null, null, true),
ms_category.CreateEntry(ModSetting.Gravity.ToString(), Gravity, null, null, true),
ms_category.CreateEntry(ModSetting.PointersReaction.ToString(), PointersReaction, null, null, true),
ms_category.CreateEntry(ModSetting.IgnoreLocal.ToString(), IgnoreLocal, null, null, true),
ms_category.CreateEntry(ModSetting.CombatReaction.ToString(), CombatReaction, null, null, true),
ms_category.CreateEntry(ModSetting.AutoRecover.ToString(), AutoRecover, null, null, true),
ms_category.CreateEntry(ModSetting.RecoverDelay.ToString(), RecoverDelay, null, null, true),
ms_category.CreateEntry(ModSetting.Slipperiness.ToString(), Slipperiness, null, null, true),
ms_category.CreateEntry(ModSetting.Bounciness.ToString(), Bounciness, null, null, true),
ms_category.CreateEntry(ModSetting.ViewVelocity.ToString(), ViewVelocity, null, null, true),
ms_category.CreateEntry(ModSetting.JumpRecover.ToString(), JumpRecover, null, null, true)
};
ms_entries[(int)ModSetting.HotkeyKey].OnEntryValueChangedUntyped.Subscribe(OnMelonSettingSave_HotkeyKey);
Hotkey = (bool)ms_entries[(int)ModSetting.Hotkey].BoxedValue;
HotkeyKey = (KeyCode)ms_entries[(int)ModSetting.HotkeyKey].BoxedValue;
VelocityMultiplier = Mathf.Clamp((float)ms_entries[(int)ModSetting.VelocityMultiplier].BoxedValue, 1f, 50f);
MovementDrag = Mathf.Clamp((float)ms_entries[(int)ModSetting.MovementDrag].BoxedValue, 0f, 50f);
AngularDrag = Mathf.Clamp((float)ms_entries[(int)ModSetting.AngularDrag].BoxedValue, 0f, 50f);
@ -95,6 +102,15 @@ namespace ml_prm
JumpRecover = (bool)ms_entries[(int)ModSetting.JumpRecover].BoxedValue;
}
static void OnMelonSettingSave_HotkeyKey(object p_oldValue, object p_newValue)
{
if(p_newValue is KeyCode)
{
HotkeyKey = (KeyCode)p_newValue;
HotkeyKeyChange?.Invoke(HotkeyKey);
}
}
public static void SetSetting(ModSetting p_settings, object p_value)
{
switch(p_settings)

View file

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<Platforms>x64</Platforms>
<PackageId>PlayerRagdollMod</PackageId>
<Version>1.0.8</Version>
<Version>1.0.9</Version>
<Authors>SDraw</Authors>
<Company>None</Company>
<Product>PlayerRagdollMod</Product>