i dont rememebr

This commit is contained in:
NotAKidoS 2024-01-01 11:58:25 -06:00
parent 374ab6c11e
commit 86828a94e2
48 changed files with 1637 additions and 841 deletions

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.Player;
using ABI_RC.Core.UI;
using ABI.CCK.Components;
using NAK.AvatarScaleMod.AvatarScaling;
using UnityEngine;
@ -14,31 +13,23 @@ public class LocalScaler : BaseScaler
{
_animatorManager = GetComponentInParent<PlayerSetup>().animatorManager;
_heightNeedsUpdate = false;
heightNeedsUpdate = false;
_isAvatarInstantiated = false;
_isHeightAdjustedFromInitial = false;
}
#endregion
#region Overrides
public override async void OnAvatarInstantiated(GameObject avatarObject, float initialHeight, Vector3 initialScale)
public override void OnAvatarInstantiated(GameObject avatarObject, float initialHeight, Vector3 initialScale)
{
if (avatarObject == null)
return;
base.OnAvatarInstantiated(avatarObject, initialHeight, initialScale);
await FindComponentsOfTypeAsync(scalableComponentTypes);
_targetHeight = initialHeight;
_scaleFactor = 1f;
_isHeightAdjustedFromInitial = false;
_legacyAnimationScale = Vector3.zero;
}
internal override void UpdateAnimatorParameter()
protected override void UpdateAnimatorParameter()
{
if (_animatorManager == null)
return;
@ -49,14 +40,8 @@ public class LocalScaler : BaseScaler
public override void LateUpdate()
{
if (!_isHeightAdjustedFromInitial)
return;
if (!_isAvatarInstantiated)
return;
if (!CheckForAnimationScaleChange())
ScaleAvatarRoot();
base.LateUpdate();
}
#endregion
@ -65,30 +50,43 @@ public class LocalScaler : BaseScaler
private bool CheckForAnimationScaleChange()
{
if (_avatarTransform == null) return false;
if (_avatarTransform == null)
return false;
//scale matches last recorded animation scale
if (_avatarTransform.localScale == _legacyAnimationScale)
Vector3 localScale = _avatarTransform.localScale;
// scale matches last recorded animation scale
if (localScale == _animatedScale)
return false;
// avatar may not have scale animation, check if it isn't equal to targetScale
if (_avatarTransform.localScale == _targetScale)
if (localScale == _targetScale)
return false;
// scale was likely reset or not initiated
if (_legacyAnimationScale == Vector3.zero)
// this is the first time we've seen the avatar animated scale, record it!
if (_animatedScale == Vector3.zero)
{
_legacyAnimationScale = _avatarTransform.localScale;
_animatedScale = localScale;
return false;
}
_legacyAnimationScale = _avatarTransform.localScale;
// animation scale changed, record it!
Vector3 scaleDifference = PlayerSetup.DivideVectors(localScale - _initialScale, _initialScale);
_animatedScaleFactor = scaleDifference.y;
_animatedHeight = (_initialHeight * _animatedScaleFactor) + _initialHeight;
_animatedScale = localScale;
InvokeAnimatedHeightChanged();
if (overrideAnimationHeight
|| !useTargetHeight)
return false; // user has disabled animation height override or is not using universal scaling
// animation scale changed and now will override universal scaling
ResetTargetHeight();
InvokeAnimatedHeightOverride();
AvatarScaleMod.Logger.Msg("AnimationClip-based avatar scaling detected. Disabling Universal Scaling.");
CohtmlHud.Instance.ViewDropTextImmediate("(Local) AvatarScaleMod", "Avatar Scale Changed!", "Universal Scaling is now disabled in favor of built-in avatar scaling.");
AvatarScaleManager.Instance.ResetHeight(); // disable mod, user used a scale slider
return true;
}
#endregion
}