66 lines
2.6 KiB
C#
66 lines
2.6 KiB
C#
using SLSFramework.General;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
{
|
|
public class CameraRotationSubmodule : SubmoduleBase<PlayerViewSubcontroller>
|
|
{
|
|
private Player player => owner.player;
|
|
private PlayerViewSubcontroller viewSc => owner;
|
|
private PlayerInputSubcontroller inputSc => player.inputSc;
|
|
|
|
private const float RotateThreshold = 0.01f;
|
|
|
|
public float cinemachineTargetYaw;
|
|
public float cinemachineEndLockYaw;
|
|
public float cinemachineTargetPitch;
|
|
|
|
public float topClamp = 70.0f;
|
|
public float bottomClamp = -30.0f;
|
|
public float cameraAngleOverride = 0.0f;
|
|
public bool lockCameraPosition = false;
|
|
|
|
public CameraRotationSubmodule(PlayerViewSubcontroller owner, float initialYaw) : base(owner)
|
|
{
|
|
this.cinemachineTargetYaw = initialYaw;
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (inputSc.Look.sqrMagnitude >= RotateThreshold && !lockCameraPosition)
|
|
{
|
|
float deltaTimeMultiplier = inputSc.CurrentScheme == "KeyboardMouse" ? 1.0f : Time.deltaTime;
|
|
//if (!viewSc.lockTargetModule.isLockedMelee)
|
|
{
|
|
cinemachineTargetYaw += inputSc.Look.x * deltaTimeMultiplier;
|
|
cinemachineTargetPitch += inputSc.Look.y * deltaTimeMultiplier;
|
|
}
|
|
}
|
|
|
|
cinemachineTargetYaw = MathExtensions.ClampAngle(cinemachineTargetYaw, float.MinValue, float.MaxValue);
|
|
cinemachineTargetPitch = MathExtensions.ClampAngle(cinemachineTargetPitch, bottomClamp, topClamp);
|
|
|
|
viewSc.cameraTarget.rotation = Quaternion.Euler(
|
|
cinemachineTargetPitch + cameraAngleOverride /*- viewSc.muzzleLiftModule.currentMuzzlePositionY*/, cinemachineTargetYaw, 0.0f);
|
|
/*
|
|
if (player.motionController.characterRotationType == PlayerMotionController.CharacterRotationType.ByAiming)
|
|
{
|
|
player.transform.rotation = Quaternion.Euler(0.0f, cinemachineTargetYaw, 0.0f);
|
|
|
|
if (viewSc.lockTargetModule.isLockedMelee)
|
|
{
|
|
//cinemachineEndLockYaw = player.viewController.lockingCamera.transform.eulerAngles.y;
|
|
//player.transform.rotation = Quaternion.Euler(0.0f, cinemachineEndLockYaw, 0.0f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (viewSc.lockTargetModule.isLockedMelee)
|
|
{
|
|
cinemachineEndLockYaw = viewSc.lockingCamera.transform.eulerAngles.y;
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
} |