mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
[AvatarScaleMod] i forgotr
This commit is contained in:
parent
2861957e3d
commit
92bbd72338
16 changed files with 544 additions and 305 deletions
|
@ -1,5 +1,7 @@
|
|||
using ABI_RC.Core.IO;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Player.AvatarTracking;
|
||||
using ABI_RC.Core.UI;
|
||||
using ABI_RC.Systems.GameEventSystem;
|
||||
using NAK.AvatarScaleMod.Components;
|
||||
using NAK.AvatarScaleMod.Networking;
|
||||
|
@ -25,7 +27,7 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
set
|
||||
{
|
||||
if (value != _settingUniversalScaling && value == false)
|
||||
SetHeight(-1f);
|
||||
ResetHeight();
|
||||
|
||||
_settingUniversalScaling = value;
|
||||
}
|
||||
|
@ -54,13 +56,11 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
_settingUniversalScaling = ModSettings.EntryUseUniversalScaling.Value;
|
||||
|
||||
CVRGameEventSystem.Instance.OnConnected.AddListener(OnInstanceConnected);
|
||||
//SchedulerSystem.AddJob(new SchedulerSystem.Job(ForceHeightUpdate), 0f, 10f, -1);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
CVRGameEventSystem.Instance.OnConnected.RemoveListener(OnInstanceConnected);
|
||||
//SchedulerSystem.RemoveJob(new SchedulerSystem.Job(ForceHeightUpdate));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -121,18 +121,25 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
public void ResetHeight()
|
||||
{
|
||||
if (!_settingUniversalScaling)
|
||||
if (_localAvatarScaler == null)
|
||||
return;
|
||||
|
||||
if (!_localAvatarScaler.IsHeightAdjustedFromInitial())
|
||||
return;
|
||||
|
||||
CohtmlHud.Instance.ViewDropTextImmediate("(Local) AvatarScaleMod", "Avatar Scale Reset!",
|
||||
"Universal Scaling is now disabled.");
|
||||
|
||||
if (_localAvatarScaler != null)
|
||||
_localAvatarScaler.ResetHeight();
|
||||
ModNetwork.SendNetworkHeight(-1f);
|
||||
SetHeight(-1f);
|
||||
}
|
||||
|
||||
public float GetHeight()
|
||||
{
|
||||
if (_localAvatarScaler == null)
|
||||
return -1f;
|
||||
return PlayerAvatarPoint.defaultAvatarHeight;
|
||||
|
||||
if (!_localAvatarScaler.IsHeightAdjustedFromInitial())
|
||||
return PlayerSetup.Instance.GetAvatarHeight();
|
||||
|
||||
return _localAvatarScaler.GetHeight();
|
||||
}
|
||||
|
@ -161,10 +168,7 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
public bool IsHeightAdjustedFromInitial()
|
||||
{
|
||||
if (_localAvatarScaler == null)
|
||||
return false;
|
||||
|
||||
return _localAvatarScaler.IsHeightAdjustedFromInitial();
|
||||
return _localAvatarScaler != null && _localAvatarScaler.IsHeightAdjustedFromInitial();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -174,9 +178,14 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
public float GetNetworkHeight(string playerId)
|
||||
{
|
||||
if (_networkedScalers.TryGetValue(playerId, out NetworkScaler scaler))
|
||||
return scaler.GetHeight();
|
||||
if (scaler.IsHeightAdjustedFromInitial()) return scaler.GetHeight();
|
||||
|
||||
//doesn't have mod, get from player avatar directly
|
||||
//doesn't have mod or has no custom height, get from player avatar directly
|
||||
CVRPlayerEntity playerEntity = CVRPlayerManager.Instance.NetworkPlayers.Find((players) => players.Uuid == playerId);
|
||||
if (playerEntity != null && playerEntity.PuppetMaster != null)
|
||||
return playerEntity.PuppetMaster.GetAvatarHeight();
|
||||
|
||||
// player is invalid???
|
||||
return -1f;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,8 @@ public class BaseScaler : MonoBehaviour
|
|||
|
||||
public void SetTargetHeight(float height)
|
||||
{
|
||||
if (Math.Abs(height - _targetHeight) < float.Epsilon)
|
||||
if (_isHeightAdjustedFromInitial
|
||||
&& Math.Abs(height - _targetHeight) < float.Epsilon)
|
||||
return;
|
||||
|
||||
if (height < float.Epsilon)
|
||||
|
@ -70,7 +71,7 @@ public class BaseScaler : MonoBehaviour
|
|||
ResetHeight();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!_isHeightAdjustedFromInitial)
|
||||
_legacyAnimationScale = Vector3.zero;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.UI;
|
||||
using ABI.CCK.Components;
|
||||
using NAK.AvatarScaleMod.AvatarScaling;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -16,7 +18,7 @@ public class LocalScaler : BaseScaler
|
|||
_isAvatarInstantiated = false;
|
||||
_isHeightAdjustedFromInitial = false;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
|
@ -25,7 +27,7 @@ public class LocalScaler : BaseScaler
|
|||
{
|
||||
if (avatarObject == null)
|
||||
return;
|
||||
|
||||
|
||||
base.OnAvatarInstantiated(avatarObject, initialHeight, initialScale);
|
||||
await FindComponentsOfTypeAsync(scalableComponentTypes);
|
||||
|
||||
|
@ -83,6 +85,7 @@ public class LocalScaler : BaseScaler
|
|||
_legacyAnimationScale = _avatarTransform.localScale;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue