private int UpdateViewModeTransitionTime(PlayerEntity player, ViewCameraConfig config) { if (!player.hasOxygenEnergyInterface) { return(config.DefaltFovTransitionTime); } bool isGunSight = _state.Dict[(int)SubCameraMotorType.View].NowMode == (byte)ECameraViewMode.GunSight; bool isHoldBreath = player.oxygenEnergyInterface.Oxygen.InShiftState; bool isOffGunSight = _state.Dict[(int)SubCameraMotorType.View].LastMode == (byte)ECameraViewMode.GunSight; if (isGunSight) { if (isHoldBreath) { return(config.OnHoldBreathTransitionTime); } if (player.oxygenEnergyInterface.Oxygen.ShiftVeryTime > _state.Dict[(int)SubCameraMotorType.View].ModeTime) { return(config.OffHoldBreathTransitionTime); } return(SingletonManager.Get <CharacterStateConfigManager>() .GetPostureTransitionTime(PostureInConfig.Null, PostureInConfig.Sight)); } if (isOffGunSight) { return(SingletonManager.Get <CharacterStateConfigManager>() .GetPostureTransitionTime(PostureInConfig.Sight, PostureInConfig.Null)); } return(config.DefaltFovTransitionTime); }
private void SmoothFov(PlayerEntity player, ViewCameraConfig viewConfig) { var comp = player.cameraStateOutputNew; lastAimFov = lastAimFov == 0 ? comp.Fov : lastAimFov; if (comp.Fov != lastFov) { if (player.time.ClientTime - lastVeryTime < lastTransitionTime) { lastAimFov = player.cameraStateOutputNew.Fov; } lastVeryTime = player.time.ClientTime; } lastVeryTime = comp.Fov == lastFov ? lastVeryTime : player.time.ClientTime; lastFov = comp.Fov; var period = UpdateViewModeTransitionTime(player, viewConfig); var percent = CalcuPercent(player.time.ClientTime, lastVeryTime, period); var result = Mathf.Lerp(lastAimFov, comp.Fov, percent); if (result == comp.Fov) { lastAimFov = result; } comp.Fov = result; }