mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
move bunch of things to depricated folder
This commit is contained in:
parent
86828a94e2
commit
21f8893095
156 changed files with 193 additions and 93 deletions
|
@ -43,16 +43,25 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
set
|
||||
{
|
||||
if (value != _settingUniversalScaling && value == false)
|
||||
ResetTargetHeight();
|
||||
_localAvatarScaler.UseTargetHeight = false;
|
||||
|
||||
_settingUniversalScaling = value;
|
||||
SetTargetHeight(_lastTargetHeight); // immediate height update
|
||||
_localAvatarScaler.UseTargetHeight = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Setting_AnimationClipScalingOverride;
|
||||
public bool Setting_PersistentHeight;
|
||||
private float _lastTargetHeight = -1;
|
||||
private float _lastTargetHeight = -1f;
|
||||
public float LastTargetHeight
|
||||
{
|
||||
get => _lastTargetHeight;
|
||||
set
|
||||
{
|
||||
_lastTargetHeight = value;
|
||||
ModSettings.EntryHiddenAvatarHeight.Value = _lastTargetHeight;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -122,21 +131,6 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
while (enabled)
|
||||
{
|
||||
yield return _heightUpdateYield;
|
||||
|
||||
// update local scaler
|
||||
if (_localAvatarScaler != null && _localAvatarScaler.heightNeedsUpdate)
|
||||
{
|
||||
if (_localAvatarScaler.ApplyTargetHeight())
|
||||
AvatarScaleEvents.OnLocalAvatarHeightChanged.Invoke(_localAvatarScaler);
|
||||
}
|
||||
|
||||
// update networked scalers (probably a better way to do this)
|
||||
foreach (var netScaler in _networkedScalers)
|
||||
{
|
||||
if (!netScaler.Value.heightNeedsUpdate) continue;
|
||||
if (netScaler.Value.ApplyTargetHeight())
|
||||
AvatarScaleEvents.OnRemoteAvatarHeightChanged.Invoke(netScaler.Key, netScaler.Value);
|
||||
}
|
||||
}
|
||||
|
||||
// ReSharper disable once IteratorNeverReturns
|
||||
|
@ -179,31 +173,11 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
public void SetTargetHeight(float targetHeight)
|
||||
{
|
||||
_lastTargetHeight = targetHeight; // save for persistent height
|
||||
ModSettings.EntryHiddenAvatarHeight.Value = targetHeight; // save for restart
|
||||
|
||||
if (!_settingUniversalScaling)
|
||||
return;
|
||||
|
||||
if (_localAvatarScaler == null)
|
||||
return;
|
||||
|
||||
_localAvatarScaler.SetTargetHeight(_lastTargetHeight);
|
||||
_localAvatarScaler.heightNeedsUpdate = true; // only local scaler forces update
|
||||
}
|
||||
|
||||
public void ResetTargetHeight()
|
||||
{
|
||||
if (_localAvatarScaler == null)
|
||||
return;
|
||||
|
||||
if (!_localAvatarScaler.IsForcingHeight())
|
||||
return;
|
||||
|
||||
// TODO: doesnt work when hitting Reset on slider in BTK UI (is it on main thread?)
|
||||
CohtmlHud.Instance.ViewDropTextImmediate("(Local) AvatarScaleMod", "Avatar Scale Reset!",
|
||||
"Universal Scaling is now disabled.");
|
||||
|
||||
SetTargetHeight(-1f);
|
||||
_localAvatarScaler.TargetHeight = _lastTargetHeight;
|
||||
}
|
||||
|
||||
public float GetHeight()
|
||||
|
@ -285,7 +259,7 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
internal void OnNetworkHeightUpdateReceived(string playerId, float targetHeight)
|
||||
{
|
||||
if (_networkedScalers.TryGetValue(playerId, out NetworkScaler scaler))
|
||||
scaler.SetTargetHeight(targetHeight);
|
||||
scaler.TargetHeight = targetHeight;
|
||||
else
|
||||
SetupHeightScalerForNetwork(playerId, targetHeight);
|
||||
}
|
||||
|
@ -352,7 +326,7 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
_networkedScalers[playerId] = scaler;
|
||||
|
||||
scaler.SetTargetHeight(targetHeight); // set initial height
|
||||
scaler.TargetHeight = targetHeight;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -52,18 +52,52 @@ public class BaseScaler : MonoBehaviour
|
|||
#endregion
|
||||
|
||||
#region Variables
|
||||
|
||||
// Height update requested
|
||||
public bool heightNeedsUpdate { get; internal set; }
|
||||
|
||||
private float _targetHeight;
|
||||
public float TargetHeight
|
||||
{
|
||||
get => _targetHeight;
|
||||
set
|
||||
{
|
||||
if (value < float.Epsilon)
|
||||
{
|
||||
// reset to animated height
|
||||
_targetHeight = _animatedHeight;
|
||||
_targetScale = _animatedScale;
|
||||
_scaleFactor = _animatedScaleFactor;
|
||||
_targetHeightChanged = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_targetHeight = Mathf.Clamp(value, AvatarScaleManager.MinHeight, AvatarScaleManager.MaxHeight);
|
||||
_scaleFactor = Mathf.Max(_targetHeight / _initialHeight, 0.01f); //safety
|
||||
_targetScale = _initialScale * _scaleFactor;
|
||||
_targetHeightChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected bool _useTargetHeight;
|
||||
public bool UseTargetHeight
|
||||
{
|
||||
get => _useTargetHeight;
|
||||
set
|
||||
{
|
||||
if (_useTargetHeight == value)
|
||||
return;
|
||||
|
||||
_useTargetHeight = value;
|
||||
_targetHeightChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Config variables
|
||||
public bool avatarIsHidden { get; set; }
|
||||
public bool useTargetHeight { get; set; }
|
||||
public bool overrideAnimationHeight { get; set; }
|
||||
|
||||
// State variables
|
||||
internal bool _isAvatarInstantiated;
|
||||
internal bool _shouldForceHeight => useTargetHeight || avatarIsHidden; // universal or hidden avatar
|
||||
private bool _shouldForceHeight => _useTargetHeight || avatarIsHidden;
|
||||
private bool _targetHeightChanged;
|
||||
|
||||
// Avatar info
|
||||
internal Transform _avatarTransform;
|
||||
|
@ -74,7 +108,6 @@ public class BaseScaler : MonoBehaviour
|
|||
internal Vector3 _initialScale;
|
||||
|
||||
// Forced scaling (Universal & Hidden Avatar)
|
||||
internal float _targetHeight = -1;
|
||||
internal Vector3 _targetScale = Vector3.one;
|
||||
internal float _scaleFactor = 1f;
|
||||
|
||||
|
@ -121,7 +154,6 @@ public class BaseScaler : MonoBehaviour
|
|||
_isAvatarInstantiated = false;
|
||||
|
||||
_avatarTransform = null;
|
||||
heightNeedsUpdate = false;
|
||||
ClearComponentLists();
|
||||
}
|
||||
|
||||
|
@ -133,36 +165,11 @@ public class BaseScaler : MonoBehaviour
|
|||
public float GetTargetHeight() => _targetHeight;
|
||||
public float GetAnimatedHeight() => _animatedHeight;
|
||||
public bool IsForcingHeight() => _shouldForceHeight;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
public void SetTargetHeight(float height)
|
||||
{
|
||||
if (height < float.Epsilon)
|
||||
{
|
||||
ResetTargetHeight();
|
||||
return;
|
||||
}
|
||||
|
||||
_targetHeight = Mathf.Clamp(height, AvatarScaleManager.MinHeight, AvatarScaleManager.MaxHeight);
|
||||
_scaleFactor = Mathf.Max(_targetHeight / _initialHeight, 0.01f); //safety
|
||||
_targetScale = _initialScale * _scaleFactor;
|
||||
|
||||
InvokeTargetHeightChanged();
|
||||
}
|
||||
|
||||
public void ResetTargetHeight()
|
||||
{
|
||||
// if (Math.Abs(_initialHeight - _targetHeight) < float.Epsilon)
|
||||
// return; // no need to change, is close enough
|
||||
|
||||
useTargetHeight = false;
|
||||
|
||||
_targetHeight = _animatedHeight;
|
||||
_targetScale = _animatedScale;
|
||||
_scaleFactor = _animatedScaleFactor;
|
||||
|
||||
InvokeTargetHeightReset();
|
||||
}
|
||||
|
||||
public bool ApplyTargetHeight()
|
||||
{
|
||||
if (!_isAvatarInstantiated || _initialHeight == 0)
|
||||
|
@ -171,17 +178,29 @@ public class BaseScaler : MonoBehaviour
|
|||
if (_avatarTransform == null)
|
||||
return false;
|
||||
|
||||
heightNeedsUpdate = false;
|
||||
|
||||
ScaleAvatarRoot();
|
||||
UpdateAnimatorParameter();
|
||||
ApplyComponentScaling();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void ResetTargetHeight()
|
||||
{
|
||||
if (!_isAvatarInstantiated)
|
||||
return;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
if (_avatarTransform == null)
|
||||
return;
|
||||
|
||||
_targetHeight = _initialHeight;
|
||||
_targetScale = _initialScale;
|
||||
_scaleFactor = 1f;
|
||||
_targetHeightChanged = true;
|
||||
|
||||
ScaleAvatarRoot();
|
||||
UpdateAnimatorParameter();
|
||||
ApplyComponentScaling();
|
||||
}
|
||||
|
||||
private void ScaleAvatarRoot()
|
||||
{
|
||||
|
@ -203,10 +222,17 @@ public class BaseScaler : MonoBehaviour
|
|||
if (!_isAvatarInstantiated)
|
||||
return; // no avatar
|
||||
|
||||
if (!_shouldForceHeight)
|
||||
return; // not universal scaling or hidden avatar
|
||||
if (!_targetHeightChanged
|
||||
&& _useTargetHeight)
|
||||
ScaleAvatarRoot();
|
||||
|
||||
ScaleAvatarRoot();
|
||||
if (!_targetHeightChanged)
|
||||
return;
|
||||
|
||||
if (_useTargetHeight)
|
||||
ApplyTargetHeight();
|
||||
else
|
||||
ResetTargetHeight();
|
||||
}
|
||||
|
||||
internal virtual void OnDestroy()
|
||||
|
|
|
@ -12,8 +12,6 @@ public class LocalScaler : BaseScaler
|
|||
public void Initialize()
|
||||
{
|
||||
_animatorManager = GetComponentInParent<PlayerSetup>().animatorManager;
|
||||
|
||||
heightNeedsUpdate = false;
|
||||
_isAvatarInstantiated = false;
|
||||
}
|
||||
|
||||
|
@ -78,7 +76,7 @@ public class LocalScaler : BaseScaler
|
|||
InvokeAnimatedHeightChanged();
|
||||
|
||||
if (overrideAnimationHeight
|
||||
|| !useTargetHeight)
|
||||
|| !_useTargetHeight)
|
||||
return false; // user has disabled animation height override or is not using universal scaling
|
||||
|
||||
// animation scale changed and now will override universal scaling
|
||||
|
|
|
@ -17,7 +17,6 @@ public class NetworkScaler : BaseScaler
|
|||
|
||||
_animatorManager = GetComponentInParent<PuppetMaster>().animatorManager;
|
||||
|
||||
heightNeedsUpdate = false;
|
||||
_isAvatarInstantiated = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue