mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 10:29:22 +00:00
Settings rework
Velocity limit rework View direction and VR camera ragdoll following
This commit is contained in:
parent
2540a4fca2
commit
4501e858c7
3 changed files with 192 additions and 155 deletions
|
@ -1,6 +1,7 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Player.AvatarTracking.Local;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using ABI_RC.Systems.MovementSystem;
|
||||
using RootMotion.Dynamics;
|
||||
|
@ -17,6 +18,8 @@ namespace ml_prm
|
|||
|
||||
VRIK m_vrIK = null;
|
||||
float m_vrIkWeight = 1f;
|
||||
LocalHeadPoint m_headPoint = null;
|
||||
bool m_inVr = false;
|
||||
|
||||
bool m_enabled = false;
|
||||
|
||||
|
@ -64,6 +67,9 @@ namespace ml_prm
|
|||
// Unity events
|
||||
void Start()
|
||||
{
|
||||
m_inVr = Utils.IsInVR();
|
||||
m_headPoint = this.GetComponent<LocalHeadPoint>();
|
||||
|
||||
m_puppetRoot = new GameObject("[PlayerAvatarPuppet]").transform;
|
||||
m_puppetRoot.parent = PlayerSetup.Instance.transform;
|
||||
m_puppetRoot.localPosition = Vector3.zero;
|
||||
|
@ -136,6 +142,12 @@ namespace ml_prm
|
|||
|
||||
foreach(var l_link in m_boneLinks)
|
||||
l_link.Item1.CopyGlobal(l_link.Item2);
|
||||
|
||||
if(m_inVr && Settings.VrFollow)
|
||||
{
|
||||
Transform l_camera = PlayerSetup.Instance.GetActiveCamera().transform;
|
||||
l_camera.position = m_headPoint.GetPointPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,6 +176,8 @@ namespace ml_prm
|
|||
|
||||
internal void OnAvatarSetup()
|
||||
{
|
||||
m_inVr = Utils.IsInVR();
|
||||
|
||||
if(PlayerSetup.Instance._animator.isHuman)
|
||||
{
|
||||
BipedRagdollReferences l_avatarReferences = BipedRagdollReferences.FromAvatar(PlayerSetup.Instance._animator);
|
||||
|
@ -282,12 +296,7 @@ namespace ml_prm
|
|||
if(m_enabled && m_avatarReady)
|
||||
SwitchRagdoll();
|
||||
|
||||
if(m_avatarReady)
|
||||
{
|
||||
foreach(Rigidbody l_body in m_rigidBodies)
|
||||
l_body.useGravity = (!Utils.IsWorldSafe() || Settings.Gravity);
|
||||
}
|
||||
|
||||
OnGravityChange(Settings.Gravity);
|
||||
OnPhysicsMaterialChange(true);
|
||||
}
|
||||
|
||||
|
@ -394,7 +403,12 @@ namespace ml_prm
|
|||
foreach(Rigidbody l_body in m_rigidBodies)
|
||||
l_body.isKinematic = false;
|
||||
|
||||
Vector3 l_velocity = m_velocity * Mathf.Clamp(Settings.VelocityMultiplier, 1f, (Utils.IsWorldSafe() ? Utils.GetWorldFlyMultiplier() : 1f));
|
||||
Vector3 l_velocity = Vector3.ClampMagnitude(m_velocity * (Utils.IsWorldSafe() ? Settings.VelocityMultiplier : 1f), Utils.GetWorldMovementLimit());
|
||||
if(Settings.ViewVelocity && Utils.IsWorldSafe())
|
||||
{
|
||||
float l_mag = l_velocity.magnitude;
|
||||
l_velocity = PlayerSetup.Instance.GetActiveCamera().transform.forward * l_mag;
|
||||
}
|
||||
|
||||
foreach(Rigidbody l_body in m_rigidBodies)
|
||||
{
|
||||
|
@ -428,7 +442,7 @@ namespace ml_prm
|
|||
|
||||
if(!Settings.RestorePosition)
|
||||
{
|
||||
if(Utils.IsInVR())
|
||||
if(m_inVr)
|
||||
{
|
||||
Vector3 l_diff = l_hipsPos - PlayerSetup.Instance._avatar.transform.position;
|
||||
Vector3 l_playerPos = PlayerSetup.Instance.transform.position;
|
||||
|
|
|
@ -21,7 +21,9 @@ namespace ml_prm
|
|||
AutoRecover,
|
||||
RecoverDelay,
|
||||
Slipperiness,
|
||||
Bounciness
|
||||
Bounciness,
|
||||
ViewVelocity,
|
||||
VrFollow,
|
||||
}
|
||||
|
||||
enum UiElementIndex
|
||||
|
@ -35,10 +37,14 @@ namespace ml_prm
|
|||
AutoRecover,
|
||||
Slipperiness,
|
||||
Bounciness,
|
||||
ViewVelocity,
|
||||
VrFollow,
|
||||
VelocityMultiplier,
|
||||
MovementDrag,
|
||||
AngularDrag,
|
||||
RecoverDelay
|
||||
RecoverDelay,
|
||||
|
||||
Count
|
||||
}
|
||||
|
||||
public static bool Hotkey { get; private set; } = true;
|
||||
|
@ -54,6 +60,8 @@ namespace ml_prm
|
|||
public static float RecoverDelay { get; private set; } = 3f;
|
||||
public static bool Slipperiness { get; private set; } = false;
|
||||
public static bool Bounciness { get; private set; } = false;
|
||||
public static bool ViewVelocity { get; private set; } = false;
|
||||
public static bool VrFollow { get; private set; } = true;
|
||||
|
||||
static public event Action SwitchChange;
|
||||
static public event Action<bool> HotkeyChange;
|
||||
|
@ -69,6 +77,8 @@ namespace ml_prm
|
|||
static public event Action<float> RecoverDelayChange;
|
||||
static public event Action<bool> SlipperinessChange;
|
||||
static public event Action<bool> BouncinessChange;
|
||||
static public event Action<bool> ViewVelocityChange;
|
||||
static public event Action<bool> VrFollowChange;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
@ -92,7 +102,9 @@ namespace ml_prm
|
|||
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.Bounciness.ToString(), Bounciness),
|
||||
ms_category.CreateEntry(ModSetting.ViewVelocity.ToString(), ViewVelocity),
|
||||
ms_category.CreateEntry(ModSetting.VrFollow.ToString(), VrFollow)
|
||||
};
|
||||
|
||||
Hotkey = (bool)ms_entries[(int)ModSetting.Hotkey].BoxedValue;
|
||||
|
@ -108,6 +120,8 @@ namespace ml_prm
|
|||
RecoverDelay = Mathf.Clamp((float)ms_entries[(int)ModSetting.RecoverDelay].BoxedValue, 1f, 10f);
|
||||
Slipperiness = (bool)ms_entries[(int)ModSetting.Slipperiness].BoxedValue;
|
||||
Bounciness = (bool)ms_entries[(int)ModSetting.Bounciness].BoxedValue;
|
||||
ViewVelocity = (bool)ms_entries[(int)ModSetting.ViewVelocity].BoxedValue;
|
||||
VrFollow = (bool)ms_entries[(int)ModSetting.VrFollow].BoxedValue;
|
||||
|
||||
if(MelonLoader.MelonMod.RegisteredMelons.FirstOrDefault(m => m.Info.Name == "BTKUILib") != null)
|
||||
{
|
||||
|
@ -122,182 +136,186 @@ namespace ml_prm
|
|||
l_page.MenuTitle = "Ragdoll settings";
|
||||
var l_categoryMod = l_page.AddCategory("Settings");
|
||||
|
||||
l_categoryMod.AddButton("Switch ragdoll", "", "Switch between normal and ragdoll state").OnPress += () =>
|
||||
{
|
||||
SwitchChange?.Invoke();
|
||||
};
|
||||
l_categoryMod.AddButton("Switch ragdoll", "", "Switch between normal and ragdoll state").OnPress += () => SwitchChange?.Invoke();
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Use hotkey", "Switch ragdoll mode with 'R' key", Hotkey));
|
||||
(ms_uiElements[(int)UiElementIndex.Hotkey] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
Hotkey = state;
|
||||
ms_entries[(int)ModSetting.Hotkey].BoxedValue = state;
|
||||
HotkeyChange?.Invoke(state);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.Hotkey] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.Hotkey, state);
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Restore position", "Bring avatar back where ragdoll state was activated", RestorePosition));
|
||||
(ms_uiElements[(int)UiElementIndex.RestorePosition] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
RestorePosition = state;
|
||||
ms_entries[(int)ModSetting.RestorePosition].BoxedValue = state;
|
||||
RestorePositionChange?.Invoke(state);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.RestorePosition] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.RestorePosition, state);
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Use gravity", "Apply gravity to ragdoll", Gravity));
|
||||
(ms_uiElements[(int)UiElementIndex.Gravity] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
Gravity = state;
|
||||
ms_entries[(int)ModSetting.Gravity].BoxedValue = state;
|
||||
GravityChange?.Invoke(state);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.Gravity] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.Gravity, state);
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Pointers reaction", "React to trigger colliders with CVRPointer component of 'ragdoll' type", PointersReaction));
|
||||
(ms_uiElements[(int)UiElementIndex.PointersReaction] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
PointersReaction = state;
|
||||
ms_entries[(int)ModSetting.PointersReaction].BoxedValue = state;
|
||||
PointersReactionChange?.Invoke(state);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.PointersReaction] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.PointersReaction, 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[(int)UiElementIndex.IgnoreLocal] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.IgnoreLocal, 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) =>
|
||||
{
|
||||
CombatReaction = state;
|
||||
ms_entries[(int)ModSetting.CombatReaction].BoxedValue = state;
|
||||
CombatReactionChange?.Invoke(state);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.CombatReaction] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.CombatReaction, state);
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Auto recover", "Automatically unragdoll after set recover delay", AutoRecover));
|
||||
(ms_uiElements[(int)UiElementIndex.AutoRecover] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
AutoRecover = state;
|
||||
ms_entries[(int)ModSetting.AutoRecover].BoxedValue = state;
|
||||
AutoRecoverChange?.Invoke(state);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.AutoRecover] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.AutoRecover, state);
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Slipperiness", "Enables/disables friction of ragdoll", Slipperiness));
|
||||
(ms_uiElements[(int)UiElementIndex.Slipperiness] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
Slipperiness = state;
|
||||
ms_entries[(int)ModSetting.Slipperiness].BoxedValue = state;
|
||||
SlipperinessChange?.Invoke(state);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.Slipperiness] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.Slipperiness, state);
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("Bounciness", "Enables/disables bounciness of ragdoll", Bounciness));
|
||||
(ms_uiElements[(int)UiElementIndex.Bounciness] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) =>
|
||||
{
|
||||
Bounciness = state;
|
||||
ms_entries[(int)ModSetting.Bounciness].BoxedValue = state;
|
||||
BouncinessChange?.Invoke(state);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.Bounciness] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.Bounciness, state);
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("View direction velocity", "Apply velocity to camera view direction", ViewVelocity));
|
||||
(ms_uiElements[(int)UiElementIndex.ViewVelocity] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(ModSetting.ViewVelocity, state);
|
||||
|
||||
ms_uiElements.Add(l_categoryMod.AddToggle("VR camera follow", "Forces VR camera to follow ragdoll", VrFollow));
|
||||
(ms_uiElements[(int)UiElementIndex.VrFollow] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate( ModSetting.VrFollow, state);
|
||||
|
||||
ms_uiElements.Add(l_page.AddSlider("Velocity multiplier", "Velocity multiplier upon entering ragdoll state", VelocityMultiplier, 1f, 50f));
|
||||
(ms_uiElements[(int)UiElementIndex.VelocityMultiplier] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) =>
|
||||
{
|
||||
VelocityMultiplier = value;
|
||||
ms_entries[(int)ModSetting.VelocityMultiplier].BoxedValue = value;
|
||||
VelocityMultiplierChange?.Invoke(value);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.VelocityMultiplier] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(ModSetting.VelocityMultiplier, value);
|
||||
|
||||
ms_uiElements.Add(l_page.AddSlider("Movement drag", "Movement resistance", MovementDrag, 0f, 50f));
|
||||
(ms_uiElements[(int)UiElementIndex.MovementDrag] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) =>
|
||||
{
|
||||
MovementDrag = value;
|
||||
ms_entries[(int)ModSetting.MovementDrag].BoxedValue = value;
|
||||
MovementDragChange?.Invoke(value);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.MovementDrag] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(ModSetting.MovementDrag, value);
|
||||
|
||||
ms_uiElements.Add(l_page.AddSlider("Angular movement drag", "Rotation movement resistance", AngularDrag, 0f, 50f));
|
||||
(ms_uiElements[(int)UiElementIndex.AngularDrag] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) =>
|
||||
{
|
||||
AngularDrag = value;
|
||||
ms_entries[(int)ModSetting.AngularDrag].BoxedValue = value;
|
||||
AngularDragChange?.Invoke(value);
|
||||
};
|
||||
(ms_uiElements[(int)UiElementIndex.AngularDrag] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(ModSetting.AngularDrag, value);
|
||||
|
||||
ms_uiElements.Add(l_page.AddSlider("Recover delay (seconds)", "Recover delay for automatic recover", RecoverDelay, 1f, 10f));
|
||||
(ms_uiElements[(int)UiElementIndex.RecoverDelay] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) =>
|
||||
(ms_uiElements[(int)UiElementIndex.RecoverDelay] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(ModSetting.RecoverDelay, value);
|
||||
|
||||
l_categoryMod.AddButton("Reset settings", "", "Reset mod settings to default").OnPress += Reset;
|
||||
}
|
||||
|
||||
static void OnToggleUpdate(ModSetting p_setting, bool p_state, UiElementIndex p_uiIndex = UiElementIndex.Count)
|
||||
{
|
||||
switch(p_setting)
|
||||
{
|
||||
RecoverDelay = value;
|
||||
ms_entries[(int)ModSetting.RecoverDelay].BoxedValue = value;
|
||||
RecoverDelayChange?.Invoke(value);
|
||||
};
|
||||
case ModSetting.Hotkey:
|
||||
{
|
||||
Hotkey = p_state;
|
||||
HotkeyChange?.Invoke(p_state);
|
||||
}
|
||||
break;
|
||||
|
||||
l_categoryMod.AddButton("Reset settings", "", "Reset mod settings to default").OnPress += () =>
|
||||
case ModSetting.RestorePosition:
|
||||
{
|
||||
RestorePosition = p_state;
|
||||
RestorePositionChange?.Invoke(p_state);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Gravity:
|
||||
{
|
||||
Gravity = p_state;
|
||||
GravityChange?.Invoke(p_state);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.PointersReaction:
|
||||
{
|
||||
PointersReaction = p_state;
|
||||
PointersReactionChange?.Invoke(p_state);
|
||||
} break;
|
||||
|
||||
case ModSetting.IgnoreLocal:
|
||||
{
|
||||
IgnoreLocal = p_state;
|
||||
IgnoreLocalChange?.Invoke(p_state);
|
||||
} break;
|
||||
|
||||
case ModSetting.CombatReaction:
|
||||
{
|
||||
CombatReaction = p_state;
|
||||
CombatReactionChange?.Invoke(p_state);
|
||||
} break;
|
||||
|
||||
case ModSetting.AutoRecover:
|
||||
{
|
||||
AutoRecover = p_state;
|
||||
AutoRecoverChange?.Invoke(p_state);
|
||||
} break;
|
||||
|
||||
case ModSetting.Slipperiness:
|
||||
{
|
||||
Slipperiness = p_state;
|
||||
SlipperinessChange?.Invoke(p_state);
|
||||
} break;
|
||||
|
||||
case ModSetting.Bounciness:
|
||||
{
|
||||
Bounciness = p_state;
|
||||
BouncinessChange?.Invoke(p_state);
|
||||
} break;
|
||||
|
||||
case ModSetting.ViewVelocity:
|
||||
{
|
||||
ViewVelocity = p_state;
|
||||
ViewVelocityChange?.Invoke(p_state);
|
||||
} break;
|
||||
|
||||
case ModSetting.VrFollow:
|
||||
{
|
||||
VrFollow = p_state;
|
||||
VrFollowChange?.Invoke(p_state);
|
||||
} break;
|
||||
}
|
||||
|
||||
ms_entries[(int)p_setting].BoxedValue = p_state;
|
||||
if(p_uiIndex != UiElementIndex.Count)
|
||||
(ms_uiElements[(int)p_uiIndex] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = p_state;
|
||||
}
|
||||
|
||||
static void OnSliderUpdate(ModSetting p_setting, float p_value, UiElementIndex p_uiIndex = UiElementIndex.Count)
|
||||
{
|
||||
switch(p_setting)
|
||||
{
|
||||
Hotkey = true;
|
||||
(ms_uiElements[(int)UiElementIndex.Hotkey] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = true;
|
||||
ms_entries[(int)ModSetting.Hotkey].BoxedValue = true;
|
||||
HotkeyChange?.Invoke(true);
|
||||
case ModSetting.VelocityMultiplier:
|
||||
{
|
||||
VelocityMultiplier = p_value;
|
||||
VelocityMultiplierChange?.Invoke(p_value);
|
||||
} break;
|
||||
|
||||
RestorePosition = false;
|
||||
ms_entries[(int)ModSetting.RestorePosition].BoxedValue = false;
|
||||
(ms_uiElements[(int)UiElementIndex.RestorePosition] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = false;
|
||||
RestorePositionChange?.Invoke(false);
|
||||
case ModSetting.MovementDrag:
|
||||
{
|
||||
MovementDrag = p_value;
|
||||
MovementDragChange?.Invoke(p_value);
|
||||
} break;
|
||||
|
||||
Gravity = true;
|
||||
ms_entries[(int)ModSetting.Gravity].BoxedValue = true;
|
||||
(ms_uiElements[(int)UiElementIndex.Gravity] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = true;
|
||||
GravityChange?.Invoke(true);
|
||||
case ModSetting.AngularDrag:
|
||||
{
|
||||
AngularDrag = p_value;
|
||||
AngularDragChange?.Invoke(p_value);
|
||||
} break;
|
||||
|
||||
PointersReaction = true;
|
||||
ms_entries[(int)ModSetting.PointersReaction].BoxedValue = true;
|
||||
(ms_uiElements[(int)UiElementIndex.PointersReaction] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = true;
|
||||
PointersReactionChange?.Invoke(true);
|
||||
case ModSetting.RecoverDelay:
|
||||
{
|
||||
RecoverDelay = p_value;
|
||||
RecoverDelayChange?.Invoke(p_value);
|
||||
} break;
|
||||
}
|
||||
|
||||
IgnoreLocal = true;
|
||||
ms_entries[(int)ModSetting.IgnoreLocal].BoxedValue = true;
|
||||
(ms_uiElements[(int)UiElementIndex.IgnoreLocal] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = true;
|
||||
IgnoreLocalChange?.Invoke(true);
|
||||
ms_entries[(int)p_setting].BoxedValue = p_value;
|
||||
if(p_uiIndex != UiElementIndex.Count)
|
||||
(ms_uiElements[(int)p_uiIndex] as BTKUILib.UIObjects.Components.SliderFloat).SetSliderValue(p_value);
|
||||
}
|
||||
|
||||
CombatReaction = true;
|
||||
ms_entries[(int)ModSetting.CombatReaction].BoxedValue = true;
|
||||
(ms_uiElements[(int)UiElementIndex.CombatReaction] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = true;
|
||||
CombatReactionChange?.Invoke(true);
|
||||
|
||||
AutoRecover = false;
|
||||
ms_entries[(int)ModSetting.AutoRecover].BoxedValue = false;
|
||||
(ms_uiElements[(int)UiElementIndex.AutoRecover] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = false;
|
||||
AutoRecoverChange?.Invoke(false);
|
||||
|
||||
Slipperiness = false;
|
||||
ms_entries[(int)ModSetting.Slipperiness].BoxedValue = false;
|
||||
(ms_uiElements[(int)UiElementIndex.Slipperiness] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = false;
|
||||
SlipperinessChange?.Invoke(false);
|
||||
|
||||
Bounciness = false;
|
||||
ms_entries[(int)ModSetting.Bounciness].BoxedValue = false;
|
||||
(ms_uiElements[(int)UiElementIndex.Bounciness] as BTKUILib.UIObjects.Components.ToggleButton).ToggleValue = false;
|
||||
BouncinessChange?.Invoke(false);
|
||||
|
||||
VelocityMultiplier = 2f;
|
||||
ms_entries[(int)ModSetting.VelocityMultiplier].BoxedValue = 2f;
|
||||
(ms_uiElements[(int)UiElementIndex.VelocityMultiplier] as BTKUILib.UIObjects.Components.SliderFloat).SetSliderValue(2f);
|
||||
VelocityMultiplierChange?.Invoke(2f);
|
||||
|
||||
MovementDrag = 2f;
|
||||
ms_entries[(int)ModSetting.MovementDrag].BoxedValue = 2f;
|
||||
(ms_uiElements[(int)UiElementIndex.MovementDrag] as BTKUILib.UIObjects.Components.SliderFloat).SetSliderValue(2f);
|
||||
MovementDragChange?.Invoke(2f);
|
||||
|
||||
AngularDrag = 2f;
|
||||
ms_entries[(int)ModSetting.AngularDrag].BoxedValue = 2f;
|
||||
(ms_uiElements[(int)UiElementIndex.AngularDrag] as BTKUILib.UIObjects.Components.SliderFloat).SetSliderValue(2f);
|
||||
AngularDragChange?.Invoke(2f);
|
||||
|
||||
RecoverDelay = 3f;
|
||||
ms_entries[(int)ModSetting.RecoverDelay].BoxedValue = 3f;
|
||||
(ms_uiElements[(int)UiElementIndex.RecoverDelay] as BTKUILib.UIObjects.Components.SliderFloat).SetSliderValue(3f);
|
||||
RecoverDelayChange?.Invoke(3f);
|
||||
};
|
||||
static void Reset()
|
||||
{
|
||||
OnToggleUpdate(ModSetting.Hotkey, true, UiElementIndex.Hotkey);
|
||||
OnToggleUpdate(ModSetting.RestorePosition, false, UiElementIndex.RestorePosition);
|
||||
OnToggleUpdate(ModSetting.Gravity, true, UiElementIndex.Gravity);
|
||||
OnToggleUpdate(ModSetting.PointersReaction, true, UiElementIndex.PointersReaction);
|
||||
OnToggleUpdate(ModSetting.IgnoreLocal, true, UiElementIndex.IgnoreLocal);
|
||||
OnToggleUpdate(ModSetting.CombatReaction, true, UiElementIndex.CombatReaction);
|
||||
OnToggleUpdate(ModSetting.AutoRecover, false, UiElementIndex.AutoRecover);
|
||||
OnToggleUpdate(ModSetting.Slipperiness, false, UiElementIndex.Slipperiness);
|
||||
OnToggleUpdate(ModSetting.Bounciness, false, UiElementIndex.Bounciness);
|
||||
OnToggleUpdate(ModSetting.ViewVelocity, false, UiElementIndex.ViewVelocity);
|
||||
OnToggleUpdate(ModSetting.VrFollow, true, UiElementIndex.VrFollow);
|
||||
OnSliderUpdate(ModSetting.VelocityMultiplier, 2f, UiElementIndex.VelocityMultiplier);
|
||||
OnSliderUpdate(ModSetting.MovementDrag, 2f, UiElementIndex.MovementDrag);
|
||||
OnSliderUpdate(ModSetting.AngularDrag, 2f, UiElementIndex.AngularDrag);
|
||||
OnSliderUpdate(ModSetting.RecoverDelay, 3f, UiElementIndex.RecoverDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,16 @@ namespace ml_prm
|
|||
|
||||
public static bool IsInVR() => ((CheckVR.Instance != null) && CheckVR.Instance.hasVrDeviceLoaded);
|
||||
public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying);
|
||||
public static float GetWorldFlyMultiplier()
|
||||
public static float GetWorldMovementLimit()
|
||||
{
|
||||
float l_result = 1f;
|
||||
if(CVRWorld.Instance != null)
|
||||
l_result = CVRWorld.Instance.flyMultiplier;
|
||||
{
|
||||
l_result = CVRWorld.Instance.baseMovementSpeed;
|
||||
l_result *= CVRWorld.Instance.sprintMultiplier;
|
||||
l_result *= CVRWorld.Instance.inAirMovementMultiplier;
|
||||
l_result *= CVRWorld.Instance.flyMultiplier;
|
||||
}
|
||||
return l_result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue