mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 10:29:22 +00:00
Ignoring local player's pointers option
Settings hide
This commit is contained in:
parent
fa5a0334b9
commit
f983f2909c
3 changed files with 28 additions and 2 deletions
|
@ -16,6 +16,7 @@ Optional mod's settings with [BTKUILib](https://github.com/BTK-Development/BTKUI
|
|||
* **Use gravity:** enables/disables gravity for ragdoll; `true` by default.
|
||||
* Note: Forcibly enabled in worlds that don't allow flight.
|
||||
* **Pointers reaction:** enables ragdoll state when player collides with trigger colliders with CVRPointer component of `ragdoll` type (avatars, props and world included); `true` by default.
|
||||
* **Ignore local pointers:** enables/disables ignoring of CVRPointer components of `ragdoll` type on local player's avatar; `true` by default.
|
||||
* **Combat reaction:** enables ragdoll state upon death in worlds with combat system; `true` by default.
|
||||
* **Auto recover:** enables automatic recovering after specific time delay; `false` by default.
|
||||
* **Velocity multiplier:** velocity force multiplier based on player's movement direction; `2.0` by default.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_prm
|
||||
|
@ -32,7 +33,7 @@ namespace ml_prm
|
|||
void OnTriggerEnter(Collider p_other)
|
||||
{
|
||||
CVRPointer l_pointer = p_other.GetComponent<CVRPointer>();
|
||||
if((l_pointer != null) && (l_pointer.type == "ragdoll") && (m_lastTrigger != p_other))
|
||||
if((l_pointer != null) && (l_pointer.type == "ragdoll") && !IsIgnored(l_pointer.transform) && (m_lastTrigger != p_other))
|
||||
{
|
||||
m_lastTrigger = p_other;
|
||||
m_triggered = true;
|
||||
|
@ -51,5 +52,10 @@ namespace ml_prm
|
|||
m_triggered = false;
|
||||
return l_state;
|
||||
}
|
||||
|
||||
static bool IsIgnored(Transform p_transform)
|
||||
{
|
||||
return (Settings.IgnoreLocal && (p_transform.root == PlayerSetup.Instance.transform));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace ml_prm
|
|||
AngularDrag,
|
||||
Gravity,
|
||||
PointersReaction,
|
||||
IgnoreLocal,
|
||||
CombatReaction,
|
||||
AutoRecover,
|
||||
RecoverDelay
|
||||
|
@ -27,6 +28,7 @@ namespace ml_prm
|
|||
RestorePosition,
|
||||
Gravity,
|
||||
PointersReaction,
|
||||
IgnoreLocal,
|
||||
CombatReaction,
|
||||
AutoRecover,
|
||||
VelocityMultiplier,
|
||||
|
@ -42,6 +44,7 @@ namespace ml_prm
|
|||
public static float AngularDrag { get; private set; } = 2f;
|
||||
public static bool Gravity { get; private set; } = true;
|
||||
public static bool PointersReaction { get; private set; } = true;
|
||||
public static bool IgnoreLocal { get; private set; } = true;
|
||||
public static bool CombatReaction { get; private set; } = true;
|
||||
public static bool AutoRecover { get; private set; } = false;
|
||||
public static float RecoverDelay { get; private set; } = 3f;
|
||||
|
@ -54,6 +57,7 @@ namespace ml_prm
|
|||
static public event Action<float> AngularDragChange;
|
||||
static public event Action<bool> GravityChange;
|
||||
static public event Action<bool> PointersReactionChange;
|
||||
static public event Action<bool> IgnoreLocalChange;
|
||||
static public event Action<bool> CombatReactionChange;
|
||||
static public event Action<bool> AutoRecoverChange;
|
||||
static public event Action<float> RecoverDelayChange;
|
||||
|
@ -65,7 +69,7 @@ namespace ml_prm
|
|||
|
||||
internal static void Init()
|
||||
{
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("PRM");
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("PRM", null, true);
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.Hotkey.ToString(), Hotkey),
|
||||
|
@ -75,6 +79,7 @@ namespace ml_prm
|
|||
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)
|
||||
|
@ -87,6 +92,7 @@ namespace ml_prm
|
|||
AngularDrag = Mathf.Clamp((float)ms_entries[(int)ModSetting.MovementDrag].BoxedValue, 0f, 50f);
|
||||
Gravity = (bool)ms_entries[(int)ModSetting.Gravity].BoxedValue;
|
||||
PointersReaction = (bool)ms_entries[(int)ModSetting.PointersReaction].BoxedValue;
|
||||
IgnoreLocal = (bool)ms_entries[(int)ModSetting.IgnoreLocal].BoxedValue;
|
||||
CombatReaction = (bool)ms_entries[(int)ModSetting.CombatReaction].BoxedValue;
|
||||
AutoRecover = (bool)ms_entries[(int)ModSetting.AutoRecover].BoxedValue;
|
||||
RecoverDelay = Mathf.Clamp((float)ms_entries[(int)ModSetting.RecoverDelay].BoxedValue, 1f, 10f);
|
||||
|
@ -141,6 +147,14 @@ namespace ml_prm
|
|||
PointersReactionChange?.Invoke(state);
|
||||
};
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Ignore local pointers", "Ignore local avatar's CVRPointer components of 'ragdoll' type", IgnoreLocal));
|
||||
(ms_uiElements[(int)UiElementIndex.IgnoreLocal] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
IgnoreLocal = state;
|
||||
ms_entries[(int)ModSetting.IgnoreLocal].BoxedValue = state;
|
||||
IgnoreLocalChange?.Invoke(state);
|
||||
};
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Combat reaction", "Ragdoll upon combat system death", CombatReaction));
|
||||
(ms_uiElements[(int)UiElementIndex.CombatReaction] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
|
@ -211,6 +225,11 @@ namespace ml_prm
|
|||
(ms_uiElements[(int)UiElementIndex.PointersReaction] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = true;
|
||||
PointersReactionChange?.Invoke(true);
|
||||
|
||||
IgnoreLocal = true;
|
||||
ms_entries[(int)ModSetting.IgnoreLocal].BoxedValue = true;
|
||||
(ms_uiElements[(int)UiElementIndex.IgnoreLocal] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = true;
|
||||
IgnoreLocalChange?.Invoke(true);
|
||||
|
||||
CombatReaction = true;
|
||||
ms_entries[(int)ModSetting.CombatReaction].BoxedValue = true;
|
||||
(ms_uiElements[(int)UiElementIndex.CombatReaction] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue