фыв
This commit is contained in:
@@ -39,6 +39,12 @@ public sealed partial class Dedugan : Component, IUseContext, Component.INetwork
|
||||
|
||||
private Vector3 _wishDirection;
|
||||
|
||||
// Кэш для оптимизации
|
||||
private bool _isOwner;
|
||||
private float _lastBodyYaw;
|
||||
private float _lastCameraYaw;
|
||||
private bool _bodyRotationDirty = true;
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
InventoryStart();
|
||||
@@ -66,9 +72,12 @@ public sealed partial class Dedugan : Component, IUseContext, Component.INetwork
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
_isOwner = Network.IsOwner;
|
||||
|
||||
UpdateCustomAnimations();
|
||||
InventoryUpdate();
|
||||
if ( Network.IsOwner )
|
||||
|
||||
if ( _isOwner )
|
||||
{
|
||||
EyeAngles += Input.AnalogLook;
|
||||
EyeAngles = EyeAngles.WithPitch( MathX.Clamp( EyeAngles.pitch, -89f, 89f ) );
|
||||
@@ -122,6 +131,21 @@ public sealed partial class Dedugan : Component, IUseContext, Component.INetwork
|
||||
/// </summary>
|
||||
private void UpdateBodyRotation()
|
||||
{
|
||||
var currentBodyYaw = Renderer.LocalRotation.Yaw();
|
||||
var currentCameraYaw = EyeAngles.yaw;
|
||||
|
||||
// Проверяем, изменились ли углы
|
||||
if ( Math.Abs( currentBodyYaw - _lastBodyYaw ) < 0.1f &&
|
||||
Math.Abs( currentCameraYaw - _lastCameraYaw ) < 0.1f &&
|
||||
!_bodyRotationDirty )
|
||||
{
|
||||
return; // Пропускаем обновление, если углы не изменились
|
||||
}
|
||||
|
||||
_lastBodyYaw = currentBodyYaw;
|
||||
_lastCameraYaw = currentCameraYaw;
|
||||
_bodyRotationDirty = false;
|
||||
|
||||
var targetRotation = Rotation.LookAt( Rotation.FromYaw( EyeAngles.yaw ).Forward, -_directionToAxis );
|
||||
var currentForward = Renderer.LocalRotation.Forward;
|
||||
float angleDiff = currentForward.Angle( targetRotation.Forward );
|
||||
@@ -162,6 +186,7 @@ public sealed partial class Dedugan : Component, IUseContext, Component.INetwork
|
||||
{
|
||||
Renderer.LocalRotation = Rotation.Slerp( Renderer.LocalRotation, Rotation.FromYaw( EyeAngles.yaw ),
|
||||
Time.Delta * 3f );
|
||||
_bodyRotationDirty = true; // Помечаем, что тело повернулось
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user