mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 10:29:22 +00:00
Merge branch 'unity6'
This commit is contained in:
commit
6115bf8e95
2 changed files with 57 additions and 14 deletions
|
@ -24,9 +24,6 @@ namespace ml_pam
|
|||
public Transform m_rightHandTarget;
|
||||
}
|
||||
|
||||
const KeyCode c_leftKey = KeyCode.Q;
|
||||
const KeyCode c_rightKey = KeyCode.E;
|
||||
|
||||
static ArmMover ms_instance = null;
|
||||
|
||||
static readonly Quaternion ms_offsetLeft = Quaternion.Euler(270f, 90f, 0f);
|
||||
|
@ -177,13 +174,13 @@ namespace ml_pam
|
|||
{
|
||||
case HandState.Empty:
|
||||
{
|
||||
if(Settings.Enabled && Settings.HandsExtension && Input.GetKey(c_leftKey) && !ViewManager.Instance.IsAnyMenuOpen)
|
||||
if(Settings.Enabled && Settings.HandsExtension && Input.GetKey(Settings.LeftHandKey) && !ViewManager.Instance.IsAnyMenuOpen)
|
||||
m_leftHandState = HandState.Extended;
|
||||
}
|
||||
break;
|
||||
case HandState.Extended:
|
||||
{
|
||||
if(!Input.GetKey(c_leftKey))
|
||||
if(!Input.GetKey(Settings.LeftHandKey))
|
||||
m_leftHandState = HandState.Empty;
|
||||
}
|
||||
break;
|
||||
|
@ -192,13 +189,13 @@ namespace ml_pam
|
|||
{
|
||||
case HandState.Empty:
|
||||
{
|
||||
if(Settings.Enabled && Settings.HandsExtension && Input.GetKey(c_rightKey) && !ViewManager.Instance.IsAnyMenuOpen)
|
||||
if(Settings.Enabled && Settings.HandsExtension && Input.GetKey(Settings.RightHandKey) && !ViewManager.Instance.IsAnyMenuOpen)
|
||||
m_rightHandState = HandState.Extended;
|
||||
}
|
||||
break;
|
||||
case HandState.Extended:
|
||||
{
|
||||
if(!Input.GetKey(c_rightKey))
|
||||
if(!Input.GetKey(Settings.RightHandKey))
|
||||
m_rightHandState = HandState.Empty;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_pam
|
||||
{
|
||||
|
@ -20,7 +21,9 @@ namespace ml_pam
|
|||
GrabOffset,
|
||||
LeadHand,
|
||||
HandsExtension,
|
||||
ExtensionSpeed
|
||||
ExtensionSpeed,
|
||||
LeftHandKey,
|
||||
RightHandKey
|
||||
}
|
||||
public enum LeadHand
|
||||
{
|
||||
|
@ -34,6 +37,8 @@ namespace ml_pam
|
|||
public static LeadHand LeadingHand { get; private set; } = LeadHand.Right;
|
||||
public static bool HandsExtension { get; private set; } = true;
|
||||
public static float ExtensionSpeed { get; private set; } = 10f;
|
||||
public static KeyCode LeftHandKey { get; private set; } = KeyCode.Q;
|
||||
public static KeyCode RightHandKey { get; private set; } = KeyCode.E;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
@ -43,25 +48,34 @@ namespace ml_pam
|
|||
public static readonly SettingEvent<LeadHand> OnLeadingHandChanged = new SettingEvent<LeadHand>();
|
||||
public static readonly SettingEvent<bool> OnHandsExtensionChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<float> OnExtensionSpeedChanged = new SettingEvent<float>();
|
||||
public static readonly SettingEvent<KeyCode> OnLeftHandKeyChanged = new SettingEvent<KeyCode>();
|
||||
public static readonly SettingEvent<KeyCode> OnRightHandKeyChanged = new SettingEvent<KeyCode>();
|
||||
|
||||
internal static void Init()
|
||||
{
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("PAM", null, true);
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("PAM", "Pickup Arm Movement");
|
||||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.Enabled.ToString(), Enabled),
|
||||
ms_category.CreateEntry(ModSetting.GrabOffset.ToString(), (int)(GrabOffset * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.LeadHand.ToString(), (int)LeadHand.Right),
|
||||
ms_category.CreateEntry(ModSetting.HandsExtension.ToString(), HandsExtension),
|
||||
ms_category.CreateEntry(ModSetting.ExtensionSpeed.ToString(), (int)ExtensionSpeed),
|
||||
ms_category.CreateEntry(ModSetting.Enabled.ToString(), Enabled, null, null, true),
|
||||
ms_category.CreateEntry(ModSetting.GrabOffset.ToString(), (int)(GrabOffset * 100f), null, null, true),
|
||||
ms_category.CreateEntry(ModSetting.LeadHand.ToString(), (int)LeadHand.Right, null, null, true),
|
||||
ms_category.CreateEntry(ModSetting.HandsExtension.ToString(), HandsExtension, null, null, true),
|
||||
ms_category.CreateEntry(ModSetting.ExtensionSpeed.ToString(), (int)ExtensionSpeed, null, null, true),
|
||||
ms_category.CreateEntry(ModSetting.LeftHandKey.ToString(), LeftHandKey, "Left hand key"),
|
||||
ms_category.CreateEntry(ModSetting.RightHandKey.ToString(), RightHandKey, "Right hand key")
|
||||
};
|
||||
|
||||
ms_entries[(int)ModSetting.LeftHandKey].OnEntryValueChangedUntyped.Subscribe(OnMelonSettingSave_LeftHandKey);
|
||||
ms_entries[(int)ModSetting.RightHandKey].OnEntryValueChangedUntyped.Subscribe(OnMelonSettingSave_RightHandKey);
|
||||
|
||||
Enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
GrabOffset = (int)ms_entries[(int)ModSetting.GrabOffset].BoxedValue * 0.01f;
|
||||
LeadingHand = (LeadHand)(int)ms_entries[(int)ModSetting.LeadHand].BoxedValue;
|
||||
HandsExtension = (bool)ms_entries[(int)ModSetting.HandsExtension].BoxedValue;
|
||||
ExtensionSpeed = Math.Clamp((int)ms_entries[(int)ModSetting.ExtensionSpeed].BoxedValue, 1f, 50f);
|
||||
LeftHandKey = (KeyCode)ms_entries[(int)ModSetting.LeftHandKey].BoxedValue;
|
||||
RightHandKey = (KeyCode)ms_entries[(int)ModSetting.RightHandKey].BoxedValue;
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
|
||||
}
|
||||
|
@ -91,6 +105,38 @@ namespace ml_pam
|
|||
};
|
||||
}
|
||||
|
||||
static void OnMelonSettingSave_LeftHandKey(object p_oldValue, object p_newValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(p_newValue is KeyCode code)
|
||||
{
|
||||
LeftHandKey = code;
|
||||
OnLeftHandKeyChanged.Invoke(LeftHandKey);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnMelonSettingSave_RightHandKey(object p_oldValue, object p_newValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(p_newValue is KeyCode code)
|
||||
{
|
||||
RightHandKey = code;
|
||||
OnRightHandKeyChanged.Invoke(RightHandKey);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnToggleUpdate(string p_name, string p_value)
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue