Pose transitions in FBT with enabled game's option for running FBT animations

Limit movement drag to 50
Settings listener on destroy
This commit is contained in:
SDraw 2023-04-09 13:59:53 +00:00 committed by SDraw
parent 327f5d6cdd
commit fe5e1dfd3c
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
6 changed files with 28 additions and 11 deletions

View file

@ -4,7 +4,7 @@ Merged set of MelonLoader mods for ChilloutVR.
| Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | Current Status | Notes |
|-----------|------------|----------------|-----------------------------------------------------------------|----------------|-------|
| Avatar Change Info | ml_aci | 1.0.3 | Retired | Retired | Superseded by `Extended Game Notifications`
| Avatar Motion Tweaker | ml_amt | 1.2.4 | Yes | Working |
| Avatar Motion Tweaker | ml_amt | 1.2.5 | Yes, update review | Working |
| Desktop Head Tracking | ml_dht | 1.1.2 | Yes | Working |
| Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working |
| Extended Game Notifications | ml_egn | 1.0.1 | Yes | Working

View file

@ -1,4 +1,5 @@
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.MovementSystem;
@ -37,6 +38,7 @@ namespace ml_amt
Transform m_avatarHips = null;
float m_viewPointHeight = 1f;
bool m_inVR = false;
bool m_fbtAnimations = true;
bool m_avatarReady = false;
bool m_compatibleAvatar = false;
@ -93,6 +95,9 @@ namespace ml_amt
Settings.FollowHipsChange += this.SetFollowHips;
Settings.MassCenterChange += this.OnMassCenterChange;
Settings.ScaledStepsChange += this.OnScaledStepsChange;
m_fbtAnimations = MetaPort.Instance.settings.GetSettingsBool("GeneralEnableRunningAnimationFullBody");
MetaPort.Instance.settings.settingBoolChanged.AddListener(this.OnGameSettingBoolChange);
}
void OnDestroy()
@ -108,6 +113,8 @@ namespace ml_amt
Settings.DetectEmotesChange -= this.SetDetectEmotes;
Settings.FollowHipsChange -= this.SetFollowHips;
Settings.MassCenterChange -= this.OnMassCenterChange;
MetaPort.Instance.settings.settingBoolChanged.RemoveListener(this.OnGameSettingBoolChange);
}
void Update()
@ -147,8 +154,8 @@ namespace ml_amt
if(m_poseTransitions)
{
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", (m_poseState == PoseState.Crouching) && !m_compatibleAvatar && !BodySystem.isCalibratedAsFullBody);
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", (m_poseState == PoseState.Proning) && !m_compatibleAvatar && !BodySystem.isCalibratedAsFullBody);
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", (m_poseState == PoseState.Crouching) && !m_compatibleAvatar && (!BodySystem.isCalibratedAsFullBody || m_fbtAnimations));
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", (m_poseState == PoseState.Proning) && !m_compatibleAvatar && (!BodySystem.isCalibratedAsFullBody || m_fbtAnimations));
}
}
@ -441,6 +448,13 @@ namespace ml_amt
}
}
// Game settings
void OnGameSettingBoolChange(string p_name, bool p_state)
{
if(p_name == "GeneralEnableRunningAnimationFullBody")
m_fbtAnimations = p_state;
}
// Arbitrary
float GetRelativeScale()
{

View file

@ -1,10 +1,10 @@
using System.Reflection;
[assembly: AssemblyTitle("AvatarMotionTweaker")]
[assembly: AssemblyVersion("1.2.4")]
[assembly: AssemblyFileVersion("1.2.4")]
[assembly: AssemblyVersion("1.2.5")]
[assembly: AssemblyFileVersion("1.2.5")]
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.2.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.2.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]

View file

@ -111,6 +111,8 @@ namespace ml_lme
{
Settings.EnabledChange -= this.OnEnableChange;
Settings.InputChange -= this.OnInputChange;
MetaPort.Instance.settings.settingBoolChanged.RemoveListener(this.OnGameSettingBoolChange);
}
void Update()

View file

@ -284,6 +284,7 @@ namespace ml_prm
if(BodySystem.isCalibratedAsFullBody)
BodySystem.TrackingPositionWeight = 0f;
// Copy before set to non-kinematic to reduce stacked forces
foreach(var l_link in m_boneLinks)
l_link.Item2.CopyGlobal(l_link.Item1);
@ -322,10 +323,10 @@ namespace ml_prm
}
}
}
}
foreach(Collider l_collider in m_colliders)
l_collider.enabled = m_enabled;
foreach(Collider l_collider in m_colliders)
l_collider.enabled = m_enabled;
}
}
public bool IsRagdolled() => (m_enabled && m_avatarReady);

View file

@ -62,7 +62,7 @@ namespace ml_prm
Hotkey = (bool)ms_entries[(int)ModSetting.Hotkey].BoxedValue;
VelocityMultiplier = UnityEngine.Mathf.Clamp((float)ms_entries[(int)ModSetting.VelocityMultiplier].BoxedValue, 0f, 50f);
RestorePosition = (bool)ms_entries[(int)ModSetting.RestorePosition].BoxedValue;
MovementDrag = UnityEngine.Mathf.Clamp((float)ms_entries[(int)ModSetting.MovementDrag].BoxedValue, 0f, 100f);
MovementDrag = UnityEngine.Mathf.Clamp((float)ms_entries[(int)ModSetting.MovementDrag].BoxedValue, 0f, 50f);
AngularDrag = UnityEngine.Mathf.Clamp((float)ms_entries[(int)ModSetting.MovementDrag].BoxedValue, 0.5f, 50f);
Gravity = (bool)ms_entries[(int)ModSetting.Gravity].BoxedValue;
@ -116,7 +116,7 @@ namespace ml_prm
VelocityMultiplierChange?.Invoke(value);
};
ms_uiElements.Add(l_page.AddSlider("Movement drag", "Movement resistance", MovementDrag, 0f, 100f));
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;