Merge branch 'unity6'

This commit is contained in:
SDraw 2025-04-04 09:15:34 +03:00
commit 6115bf8e95
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
2 changed files with 57 additions and 14 deletions

View file

@ -24,9 +24,6 @@ namespace ml_pam
public Transform m_rightHandTarget; public Transform m_rightHandTarget;
} }
const KeyCode c_leftKey = KeyCode.Q;
const KeyCode c_rightKey = KeyCode.E;
static ArmMover ms_instance = null; static ArmMover ms_instance = null;
static readonly Quaternion ms_offsetLeft = Quaternion.Euler(270f, 90f, 0f); static readonly Quaternion ms_offsetLeft = Quaternion.Euler(270f, 90f, 0f);
@ -177,13 +174,13 @@ namespace ml_pam
{ {
case HandState.Empty: 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; m_leftHandState = HandState.Extended;
} }
break; break;
case HandState.Extended: case HandState.Extended:
{ {
if(!Input.GetKey(c_leftKey)) if(!Input.GetKey(Settings.LeftHandKey))
m_leftHandState = HandState.Empty; m_leftHandState = HandState.Empty;
} }
break; break;
@ -192,13 +189,13 @@ namespace ml_pam
{ {
case HandState.Empty: 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; m_rightHandState = HandState.Extended;
} }
break; break;
case HandState.Extended: case HandState.Extended:
{ {
if(!Input.GetKey(c_rightKey)) if(!Input.GetKey(Settings.RightHandKey))
m_rightHandState = HandState.Empty; m_rightHandState = HandState.Empty;
} }
break; break;

View file

@ -1,6 +1,7 @@
using ABI_RC.Core.InteractionSystem; using ABI_RC.Core.InteractionSystem;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine;
namespace ml_pam namespace ml_pam
{ {
@ -20,7 +21,9 @@ namespace ml_pam
GrabOffset, GrabOffset,
LeadHand, LeadHand,
HandsExtension, HandsExtension,
ExtensionSpeed ExtensionSpeed,
LeftHandKey,
RightHandKey
} }
public enum LeadHand public enum LeadHand
{ {
@ -34,6 +37,8 @@ namespace ml_pam
public static LeadHand LeadingHand { get; private set; } = LeadHand.Right; public static LeadHand LeadingHand { get; private set; } = LeadHand.Right;
public static bool HandsExtension { get; private set; } = true; public static bool HandsExtension { get; private set; } = true;
public static float ExtensionSpeed { get; private set; } = 10f; 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 MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = 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<LeadHand> OnLeadingHandChanged = new SettingEvent<LeadHand>();
public static readonly SettingEvent<bool> OnHandsExtensionChanged = new SettingEvent<bool>(); public static readonly SettingEvent<bool> OnHandsExtensionChanged = new SettingEvent<bool>();
public static readonly SettingEvent<float> OnExtensionSpeedChanged = new SettingEvent<float>(); 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() 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_entries = new List<MelonLoader.MelonPreferences_Entry>()
{ {
ms_category.CreateEntry(ModSetting.Enabled.ToString(), Enabled), ms_category.CreateEntry(ModSetting.Enabled.ToString(), Enabled, null, null, true),
ms_category.CreateEntry(ModSetting.GrabOffset.ToString(), (int)(GrabOffset * 100f)), ms_category.CreateEntry(ModSetting.GrabOffset.ToString(), (int)(GrabOffset * 100f), null, null, true),
ms_category.CreateEntry(ModSetting.LeadHand.ToString(), (int)LeadHand.Right), ms_category.CreateEntry(ModSetting.LeadHand.ToString(), (int)LeadHand.Right, null, null, true),
ms_category.CreateEntry(ModSetting.HandsExtension.ToString(), HandsExtension), ms_category.CreateEntry(ModSetting.HandsExtension.ToString(), HandsExtension, null, null, true),
ms_category.CreateEntry(ModSetting.ExtensionSpeed.ToString(), (int)ExtensionSpeed), 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; Enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
GrabOffset = (int)ms_entries[(int)ModSetting.GrabOffset].BoxedValue * 0.01f; GrabOffset = (int)ms_entries[(int)ModSetting.GrabOffset].BoxedValue * 0.01f;
LeadingHand = (LeadHand)(int)ms_entries[(int)ModSetting.LeadHand].BoxedValue; LeadingHand = (LeadHand)(int)ms_entries[(int)ModSetting.LeadHand].BoxedValue;
HandsExtension = (bool)ms_entries[(int)ModSetting.HandsExtension].BoxedValue; HandsExtension = (bool)ms_entries[(int)ModSetting.HandsExtension].BoxedValue;
ExtensionSpeed = Math.Clamp((int)ms_entries[(int)ModSetting.ExtensionSpeed].BoxedValue, 1f, 50f); 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()); 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) static void OnToggleUpdate(string p_name, string p_value)
{ {
try try