using System; using System.Collections; using System.Collections.Generic; using BITFALL.Player.Equip; using BITKit; using BITKit.Entities; using UnityEngine; using UnityEngine.InputSystem; namespace BITFALL.Player.Movement { public class EquipSway : EntityBehavior { [SerializeField] private float rotDelta; [SerializeField] private float rotValue; [SerializeField] private float posDelta; [SerializeField] private float posValue; [SerializeField] private LocationAdditive locationAdditive; private Quaternion currentRotation; private Vector3 currentPosition; private IEntityMovement _movement; private IEquipService _equipService; public override void OnAwake() { _movement = UnityEntity.Get(); _equipService = UnityEntity.Get(); } public override void OnLateUpdate(float deltaTime) { deltaTime = Mathf.Clamp(deltaTime, 0, 0.32f); var velocity = _movement.LocomotionBasedVelocity; var angularVelocity = _movement.AngularVelocity; if (_equipService.Zoom.Allow) { velocity = default; if (_equipService.AllowScope is false) angularVelocity = default; } currentPosition = Vector3.Lerp(currentPosition,velocity * posValue,posDelta * deltaTime); currentRotation = Quaternion.Slerp(currentRotation,Quaternion.Euler(angularVelocity * rotValue),rotDelta * deltaTime); currentPosition+= new Vector3( angularVelocity.y, angularVelocity.x, angularVelocity.z ) * (posValue * deltaTime * 4); locationAdditive.AddEuler(currentRotation.eulerAngles); locationAdditive.AddPosition(currentPosition); } } }