Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/BoatSimulator.cs
2026-02-21 16:45:37 +08:00

1238 lines
34 KiB
C#

using System;
using System.Collections.Generic;
using BitStrap;
using UltimateWater;
using UnityEngine;
public class BoatSimulator : MonoBehaviour
{
public enum BoatState
{
IDLE = 0,
PLAYER_FISHING = 1,
PLAYER_DRIVING = 2
}
[ReadOnly]
public BoatState currentState;
public Transform enterPosition;
public Transform enterPositionVR;
public Transform exitPosition;
public Transform startPosition;
public Transform returnPosition;
public Transform fishingPosition;
public List<GameObject> turnOffWhileDriving = new List<GameObject>();
public List<GameObject> turnOffWhileKeepMoving = new List<GameObject>();
[Space(10f)]
public BoatGauge gaugeSpeed;
public BoatGauge gaugeFuel;
public BoatGauge gaugeDirection;
[Space(10f)]
public Transform watchFishPosition;
public Transform watchPlayerPosition;
public bool watchFishOnSide;
public float netSitDownHeight = -1f;
public RodStand rodStand;
public bool permanentRodStand;
[Space(10f)]
public BoatInteractive interactiveEnter;
public BoatInteractive interactiveExit;
public BoatInteractive interactiveDriveStart;
public BoatInteractive interactiveDriveStop;
[ReadOnly]
public WaterVolumeSubtract waterVolumeSubstract;
public Transform fishScareCollider;
[Space(10f)]
public GameObject modelParent;
public GameObject paddles;
public GameObject propeller;
public float propellerSpeed = 100f;
public GameObject steeringWheel;
public float wheelRotationSpeed = 10f;
public float maxWheelRotationF = 180f;
[ReadOnly]
public float currentWheelRotation;
[ReadOnly]
public float currentWheelFactor;
[Space(10f)]
public Transform forcePosition;
public Vector3 rotateVector = Vector3.zero;
public float forwardForce = 500f;
public float backwardForce = 500f;
public float turnForce = 100f;
public float trollingForceMultiplier = 0.5f;
public float minFishTrollingSpeed = 2.5f;
[ReadOnly]
public bool keepMovingForward;
public Vector2 dragIdle = Vector2.one;
public Vector2 dragEngine = Vector2.one;
[Space(10f)]
public string engineSound = string.Empty;
public string waterSound = string.Empty;
public string collisionDefaultSound = string.Empty;
public string collisionTerrainSound = string.Empty;
public string engineIdleSound = string.Empty;
public string engineStartSound = string.Empty;
public string engineStopSound = string.Empty;
[ReadOnly]
public float collisionSoundTimer;
[HideInInspector]
public AudioObject engineAudioObject;
[HideInInspector]
public AudioObject engineIdleAudioObject;
[HideInInspector]
public AudioObject waterAudioObject;
public Vector2 engineVolume = new Vector2(0f, 1f);
public Vector2 enginePitch = new Vector2(0.5f, 1.1f);
public Vector2 waterVolume = new Vector2(0f, 1f);
public float trollingEngineSoundVolume = 0.5f;
[ReadOnly]
public float engineForce;
public float engineForceSpeed = 0.1f;
[Space(10f)]
public bool changePlayerParent = true;
public bool freezeRotation = true;
public bool isKayak;
public float kayakSitHeight = 1.3f;
[HideInInspector]
public Rigidbody myRigidbody;
private bool keyPressedW;
private bool keyPressedA;
private bool keyPressedS;
private bool keyPressedD;
[ReadOnly]
public float noTurningTimer;
public List<ParticleEmitter> waterEmitters = new List<ParticleEmitter>();
public List<GameObject> waterEffects = new List<GameObject>();
[HideInInspector]
public List<ParticleSystem> waterSplashEffects = new List<ParticleSystem>();
public List<GameObject> waterSplashEffectsPos = new List<GameObject>();
private float waterSplashTimer = 5f;
private float waterSplashSmallTimer = 2f;
public float wakeEffectSpeed = 1f;
public float blurFactor = 1f;
public float speedFxThreshold = 30f;
[ReadOnly]
public float currentSpeedFx;
[Header("Waves")]
public bool pauseFloating;
public Transform objectsParent;
public Transform engineParent;
public float engineParentMaxRotationX = 2f;
public Vector2 engineParentMaxRotationZ = new Vector2(5f, 5f);
public Vector3 engineParentRotationSpeed = Vector3.one;
private Vector3 engineParentPrevRotation = Vector3.zero;
public Transform centerParent;
private Vector3 floatingCurrent = Vector3.zero;
private Vector3 floatingTarget = Vector3.one;
public float floatingTargetMultiplier = 1f;
private Vector3 floatingPrevTarget = Vector3.zero;
private Vector3 floatingSpeed = Vector3.one;
public float floatingSpeedMultiplier = 2f;
public AnimationCurve floatingLerpCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
public AnimationCurve rotateLerpCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
[ReadOnly]
public FishPartAnim animPosY;
public float animPosYMaxMultiplier = 1f;
public Vector2 animPosYDuration = new Vector2(0.3f, 2f);
[Space(10f)]
public float centerParentMoveYMax = 0.5f;
public float centerParentRotXMax = 2f;
public float centerParentRotXSpeed = 7f;
public float centerParentRotZMax = 1f;
public float centerParentRotZSpeed = 8f;
[HideInInspector]
public FishingPlayer fishingPlayer;
[ReadOnly]
public bool initialized;
[Header("Player")]
public Vector2 playerForwardMoveMax = new Vector2(-0.3f, 0.1f);
public Vector2 playerForwardMoveSpeed = new Vector2(1f, 1f);
public float playerSideRotateMax = 15f;
public float playerSideRotateSpeed = 1f;
public float playerDownRotateMax = 15f;
public Vector3 playerCurrentMove = Vector3.zero;
public Vector3 playerCurrentRotation = Vector3.zero;
public bool showCameraDrops = true;
[Space(10f)]
public VRBoatWheel vrBoatWheel;
public float vrBoatWheelPow = 2f;
public List<GameObject> allMovingPlatforms = new List<GameObject>();
private void Awake()
{
if ((bool)FisheryEditor.Instance)
{
foreach (GameObject waterEffect in waterEffects)
{
waterEffect.SetActive(false);
}
if ((bool)fishScareCollider)
{
fishScareCollider.gameObject.SetActive(false);
}
Collider[] components = GetComponents<Collider>();
Collider[] array = components;
foreach (Collider collider in array)
{
collider.isTrigger = true;
}
Collider[] componentsInChildren = GetComponentsInChildren<Collider>();
Collider[] array2 = componentsInChildren;
foreach (Collider collider2 in array2)
{
collider2.gameObject.SetActive(false);
collider2.gameObject.SetActive(true);
collider2.enabled = false;
}
}
if ((bool)FisheryEditor.Instance)
{
return;
}
myRigidbody = GetComponent<Rigidbody>();
if (VRManager.IsVROn() && (bool)enterPositionVR)
{
enterPosition.position = enterPositionVR.position;
enterPosition.rotation = enterPositionVR.rotation;
}
if ((bool)centerParent)
{
objectsParent.SetParent(engineParent);
engineParent.SetParent(centerParent);
centerParent.localPosition -= new Vector3(0f, centerParentMoveYMax * 0.5f, 0f);
animPosY = centerParent.GetComponent<FishPartAnim>();
if ((bool)animPosY)
{
animPosY.unscaledTime = false;
}
}
engineAudioObject = AudioController.Play(engineSound);
if (!isKayak && engineAudioObject == null)
{
Debug.LogError("engineAudioObject == null");
}
engineIdleAudioObject = AudioController.Play(engineIdleSound, base.transform);
if ((bool)engineIdleAudioObject)
{
engineIdleAudioObject.Pause();
}
waterAudioObject = AudioController.Play(waterSound, base.transform);
if (waterAudioObject != null)
{
waterAudioObject.Pause();
}
UpdateEngineSound(false);
if ((bool)fishScareCollider)
{
fishScareCollider.parent = null;
fishScareCollider.gameObject.SetActive(true);
Utilities.SetLayerRecursively(fishScareCollider.gameObject, "Boat");
}
RefreshRodStands();
ChangeState(BoatState.IDLE);
}
private void Start()
{
}
public void Initialize()
{
if ((bool)FisheryEditor.Instance)
{
return;
}
if (startPosition.parent != null)
{
startPosition.parent = null;
startPosition.localScale = Vector3.one;
startPosition.position = base.transform.position;
startPosition.eulerAngles = base.transform.eulerAngles;
}
fishingPlayer = GameController.Instance.fishingPlayer;
if (!GameController.Instance.iceLevel)
{
InitializeWaterSubstract();
LeanTween.delayedCall(3f, (Action)delegate
{
InitializeWaterSubstract();
});
}
for (int num = 0; num < waterSplashEffectsPos.Count; num++)
{
ParticleSystem particleSystem = UnityEngine.Object.Instantiate(GameController.Instance.waterEffectsManager.GetSplashParticlePrefab(WaterEffectsManager.SplashSize.LARGE));
particleSystem.transform.parent = waterSplashEffectsPos[num].transform;
particleSystem.transform.localPosition = Vector3.zero;
particleSystem.transform.localEulerAngles = Vector3.zero;
waterSplashEffects.Add(particleSystem);
}
initialized = true;
}
private void OnCollisionEnter(Collision col)
{
if (!FisheryEditor.Instance && initialized && currentState == BoatState.PLAYER_DRIVING && collisionSoundTimer <= 0f && (col.gameObject.layer == LayerMask.NameToLayer("Default") || col.gameObject.layer == LayerMask.NameToLayer("Terrain")))
{
string empty = string.Empty;
CollisionSound component = col.gameObject.GetComponent<CollisionSound>();
empty = (component ? component.GetSound() : ((!col.gameObject.HasTag("TERRAIN")) ? collisionDefaultSound : collisionTerrainSound));
float num = currentSpeedFx * 5f;
Debug.Log("collisionSoundName: " + empty + " col: " + col.gameObject.name + " volume: " + num);
AudioController.Play(empty, base.transform, num);
collisionSoundTimer = 1f;
}
}
public void InitializeWaterSubstract()
{
waterVolumeSubstract = GetComponentInChildren<WaterVolumeSubtract>(true);
if ((bool)waterVolumeSubstract)
{
waterVolumeSubstract.gameObject.SetActive(false);
waterVolumeSubstract.AssignTo(null);
waterVolumeSubstract.gameObject.SetActive(true);
waterVolumeSubstract.enabled = true;
waterVolumeSubstract.AssignTo(GameController.Instance.water);
if (propeller != null)
{
Utilities.SetLayerRecursively(waterVolumeSubstract.gameObject, "TransparentFX");
}
}
if (waterVolumeSubstract == null)
{
Utilities.LogError("InitializeWaterSubstract() waterVolumeSubstract == null");
}
if (GameController.Instance.water == null)
{
Utilities.LogError("InitializeWaterSubstract() GameController.Instance.water");
}
}
public void ResetRotations()
{
engineParent.localEulerAngles = Vector3.zero;
centerParent.localEulerAngles = Vector3.zero;
engineParentPrevRotation = Vector3.zero;
playerCurrentMove = Vector3.zero;
playerCurrentRotation = Vector3.zero;
keyPressedW = false;
keyPressedS = false;
keyPressedA = false;
keyPressedD = false;
}
public void ChangeState(BoatState newState)
{
StopBoat();
ResetRotations();
interactiveEnter.GetComponent<Collider>().enabled = newState == BoatState.IDLE;
interactiveEnter.GetComponent<BoatInteractive>().canInteract = newState == BoatState.IDLE;
if ((bool)interactiveExit)
{
interactiveExit.gameObject.SetActive(newState != BoatState.IDLE);
interactiveExit.GetComponent<Collider>().enabled = newState == BoatState.PLAYER_FISHING;
}
interactiveDriveStart.GetComponent<Collider>().enabled = newState == BoatState.PLAYER_FISHING;
keepMovingForward = false;
if ((bool)VRManager.Instance && ((VRManager.Instance.IsControllersInput() && UtilitiesInput.GetButton("VR_BOAT_THROTTLE_UP")) || (!VRManager.Instance.IsControllersInput() && UtilitiesInput.moveAxis.y > 0.3f)) && newState == BoatState.PLAYER_FISHING && !isKayak)
{
keepMovingForward = true;
}
foreach (GameObject item in turnOffWhileDriving)
{
item.SetActive(newState != BoatState.PLAYER_DRIVING);
}
if (keepMovingForward)
{
foreach (GameObject item2 in turnOffWhileKeepMoving)
{
item2.SetActive(false);
}
}
foreach (GameObject waterEffect in waterEffects)
{
Color color = waterEffect.GetComponent<MeshRenderer>().material.GetColor("_TintColor");
if (keepMovingForward)
{
color.a = 0.65f;
}
else if (newState != BoatState.PLAYER_DRIVING)
{
color.a = 0f;
}
waterEffect.GetComponent<MeshRenderer>().material.SetColor("_TintColor", color);
}
if (newState == BoatState.PLAYER_DRIVING)
{
myRigidbody.isKinematic = false;
if ((bool)fishingPlayer)
{
fishingPlayer.amplifyMotionEffect.CameraMotionMult = 0f;
}
if (!rodStand || rodStand.rodPlacesOccupied == 0)
{
GameController.Instance.fishViewCurrentDistance = 0f;
}
if (VRManager.IsVROn())
{
ChangeTeleportPlatformsLayers(false);
fishingPlayer.ChangeVRCameraHeight(fishingPlayer.vrWheelMoveLastPosition);
}
}
else if (newState != BoatState.PLAYER_DRIVING)
{
myRigidbody.isKinematic = true;
if ((bool)fishingPlayer)
{
fishingPlayer.amplifyMotionEffect.CameraMotionMult = 1f;
if (VRManager.IsVROn())
{
fishingPlayer.ChangeVRCameraHeight(VRManager.Instance.cameraHeight);
}
}
GameController.Instance.fishViewCurrentDistance = GameController.Instance.fishViewDistance;
UtilitiesInput.StopVibration();
}
pauseFloating = false;
currentState = newState;
}
public void PlayEngineStartSound(bool start)
{
if (!(engineIdleAudioObject == null))
{
if (start)
{
AudioController.Play(engineStartSound, base.transform);
engineIdleAudioObject.Play();
engineIdleAudioObject.FadeIn(1f);
}
else if (engineIdleAudioObject.IsPlaying())
{
AudioController.Play(engineStopSound, base.transform);
engineIdleAudioObject.Pause(2f);
}
}
}
public void EnterBoat(bool enter)
{
if (enter)
{
ChangeState(BoatState.PLAYER_FISHING);
}
else
{
ChangeState(BoatState.IDLE);
}
if (!enter)
{
base.transform.position = startPosition.position;
base.transform.rotation = startPosition.rotation;
}
GameController.Instance.hudManager.kgfMapSystem.SetTarget((!enter) ? fishingPlayer.gameObject : base.gameObject);
if (enter)
{
if ((bool)rodStand)
{
foreach (RodStand.RodPlace rodPlace in rodStand.rodPlaces)
{
rodPlace.rodTrigger.GetComponent<RodStandTrigger>().InteractDistance = ((!isKayak) ? 2.8f : 3.2f);
}
}
InitializeWaterSubstract();
}
StopBoat();
}
public void ReturnBoat()
{
base.transform.position = returnPosition.position;
base.transform.rotation = returnPosition.rotation;
StopBoat();
}
public void StopBoat()
{
myRigidbody.velocity = Vector3.zero;
myRigidbody.angularVelocity = Vector3.zero;
engineForce = 0f;
UpdateEngineSound(false);
}
private void Update()
{
if (Time.timeScale == 0f || ((bool)BugReporter.Instance && BugReporter.Instance.isVisible) || (VRManager.IsVROn() && GameController.Instance.IsQuickMenu()) || (bool)FisheryEditor.Instance || !initialized)
{
return;
}
if (exitPosition == null && GameController.Instance.spawnPoints != null && GameController.Instance.spawnPoints.Length > 0)
{
exitPosition = GameController.Instance.spawnPoints[0].transform;
}
if ((bool)fishScareCollider)
{
fishScareCollider.position = base.transform.position;
fishScareCollider.rotation = base.transform.rotation;
}
if ((!GlobalSettings.Instance || GlobalSettings.Instance.turnOnMyCheats) && Input.GetKeyDown(KeyCode.J))
{
InitializeWaterSubstract();
}
if (currentState == BoatState.PLAYER_DRIVING)
{
keyPressedW = false;
keyPressedS = false;
keyPressedA = false;
keyPressedD = false;
if (!HUDManager.Instance.hudMultiplayer.isInInputMode)
{
if ((VRManager.Instance.IsControllersInput() && UtilitiesInput.GetButton("VR_BOAT_THROTTLE_UP")) || (!VRManager.Instance.IsControllersInput() && UtilitiesInput.moveAxis.y > 0.3f))
{
keyPressedW = true;
float num = forwardForce;
if (HasRodsWithFishOnPod() || (HasRodsOnPod() && !UtilitiesInput.GetButton("RUN")))
{
num *= trollingForceMultiplier;
}
if ((bool)forcePosition)
{
myRigidbody.AddForceAtPosition(base.transform.forward * forwardForce * Time.deltaTime, forcePosition.position);
}
else
{
myRigidbody.AddForce(base.transform.forward * num * Time.deltaTime);
}
}
else if ((VRManager.Instance.IsControllersInput() && UtilitiesInput.GetButton("VR_BOAT_THROTTLE_DOWN")) || (!VRManager.Instance.IsControllersInput() && UtilitiesInput.moveAxis.y < -0.3f))
{
keyPressedS = true;
if ((bool)forcePosition)
{
myRigidbody.AddForceAtPosition(-base.transform.forward * backwardForce * Time.deltaTime, forcePosition.position);
}
else
{
myRigidbody.AddForce(-base.transform.forward * backwardForce * Time.deltaTime);
}
}
}
noTurningTimer -= Time.deltaTime;
if (noTurningTimer < 0f)
{
noTurningTimer = 0f;
}
float num2 = 0f;
bool flag = VRManager.Instance.IsVRDriveBoat() && !isKayak && (bool)vrBoatWheel;
if (!HUDManager.Instance.hudMultiplayer.isInInputMode)
{
if (flag)
{
num2 = vrBoatWheel.MakeUpdate();
currentWheelFactor = Mathf.Abs(num2);
}
else
{
currentWheelFactor = Mathf.Abs(currentWheelRotation / maxWheelRotationF);
}
if ((flag && num2 > 0.05f) || (!flag && UtilitiesInput.moveAxis.x < -0.5f))
{
if (keyPressedW || keyPressedS || isKayak)
{
keyPressedA = true;
if (flag)
{
myRigidbody.AddTorque(-base.transform.up * turnForce * Time.deltaTime * ((!keyPressedS) ? 1f : (-1f)) * (currentWheelFactor * 1.5f));
}
else
{
myRigidbody.AddTorque(-base.transform.up * turnForce * Time.deltaTime * ((!keyPressedS) ? 1f : (-1f)) * (currentWheelFactor + 0.5f));
}
noTurningTimer = 0.6f;
}
if (!flag)
{
currentWheelRotation += wheelRotationSpeed * Time.deltaTime;
}
}
else if ((flag && num2 < 0.05f) || (!flag && UtilitiesInput.moveAxis.x > 0.5f))
{
if (keyPressedW || keyPressedS || isKayak)
{
keyPressedD = true;
if (flag)
{
myRigidbody.AddTorque(base.transform.up * turnForce * Time.deltaTime * ((!keyPressedS) ? 1f : (-1f)) * (currentWheelFactor * 1.5f));
}
else
{
myRigidbody.AddTorque(base.transform.up * turnForce * Time.deltaTime * ((!keyPressedS) ? 1f : (-1f)) * (currentWheelFactor + 0.5f));
}
noTurningTimer = 0.6f;
}
if (!flag)
{
currentWheelRotation -= wheelRotationSpeed * Time.deltaTime;
}
}
else
{
if (currentWheelRotation > 0f)
{
currentWheelRotation -= wheelRotationSpeed * Time.deltaTime * 1f;
if (currentWheelRotation < 0f)
{
currentWheelRotation = 0f;
}
}
if (currentWheelRotation < 0f)
{
currentWheelRotation += wheelRotationSpeed * Time.deltaTime * 1f;
if (currentWheelRotation > 0f)
{
currentWheelRotation = 0f;
}
}
}
}
if (isKayak)
{
if (keyPressedW)
{
fishingPlayer.currentHands.kayakHandsAnimator.SetInteger("KayakHandsState", 1);
}
else if (keyPressedS)
{
fishingPlayer.currentHands.kayakHandsAnimator.SetInteger("KayakHandsState", -1);
}
else if (keyPressedD)
{
fishingPlayer.currentHands.kayakHandsAnimator.SetInteger("KayakHandsState", 2);
}
else if (keyPressedA)
{
fishingPlayer.currentHands.kayakHandsAnimator.SetInteger("KayakHandsState", 3);
}
else
{
fishingPlayer.currentHands.kayakHandsAnimator.SetInteger("KayakHandsState", 0);
}
}
if (!flag)
{
currentWheelRotation = Mathf.Clamp(currentWheelRotation, 0f - maxWheelRotationF, maxWheelRotationF);
steeringWheel.transform.localEulerAngles = new Vector3(0f, 0f, currentWheelRotation);
}
UpdateEngineSound(true);
foreach (GameObject waterEffect in waterEffects)
{
Color color = waterEffect.GetComponent<MeshRenderer>().material.GetColor("_TintColor");
color.a += wakeEffectSpeed * Time.deltaTime * ((!keyPressedW) ? (-1f) : 1f);
color.a = Mathf.Clamp(color.a, 0f, 0.7f);
waterEffect.GetComponent<MeshRenderer>().material.SetColor("_TintColor", color);
waterEffect.transform.eulerAngles = new Vector3(0f, waterEffect.transform.eulerAngles.y, 0f);
}
if ((bool)propeller)
{
propeller.transform.Rotate(Vector3.up * Time.deltaTime * propellerSpeed);
}
myRigidbody.drag = ((!keyPressedW) ? dragIdle.x : dragEngine.x);
myRigidbody.angularDrag = ((!keyPressedW) ? dragIdle.y : dragEngine.y);
}
else if (currentState == BoatState.PLAYER_FISHING && keepMovingForward)
{
Vector3 force = base.transform.forward * forwardForce * trollingForceMultiplier * Time.deltaTime;
if (HasRodsWithFishOnPod())
{
force *= 0.3f;
}
myRigidbody.AddForce(force);
myRigidbody.isKinematic = false;
foreach (GameObject waterEffect2 in waterEffects)
{
waterEffect2.transform.localEulerAngles = Vector3.zero;
}
if ((bool)propeller)
{
propeller.transform.Rotate(Vector3.up * Time.deltaTime * propellerSpeed);
}
UpdateEngineSound(true);
}
if ((bool)rodStand && (keyPressedW || keepMovingForward))
{
foreach (RodStand.RodPlace rodPlace in rodStand.rodPlaces)
{
if ((bool)rodPlace.fishingRod && (rodPlace.fishingRod.fishingHands.isSpinningRig || rodPlace.fishingRod.fishingHands.isFlyRig))
{
rodPlace.fishingRod.fishingHands.spinningMethodController.SpinningStateEvent(SpinningMethodController.SpinningState.MOVE_MEDIUM);
}
}
if (fishingPlayer.currentHands.baitWasThrown)
{
fishingPlayer.currentHands.spinningMethodController.SpinningStateEvent(SpinningMethodController.SpinningState.MOVE_MEDIUM);
}
}
currentSpeedFx = Mathf.Clamp01(myRigidbody.velocity.magnitude / speedFxThreshold);
UpdateBoatFloating();
if (collisionSoundTimer > 0f)
{
collisionSoundTimer -= Time.deltaTime;
}
if ((bool)gaugeSpeed)
{
gaugeSpeed.SetValue(myRigidbody.velocity.magnitude * 3.6f / 70f);
}
if ((bool)gaugeDirection)
{
gaugeDirection.SetValue(0.5f + (0f - Utilities.GetAngle180Range(engineParent.localEulerAngles.x)) / engineParentMaxRotationX * 0.5f);
}
}
private void LateUpdate()
{
if (Time.timeScale == 0f || (bool)FisheryEditor.Instance || !initialized)
{
return;
}
if (isKayak && (bool)fishingPlayer && fishingPlayer.boatSimulator == this)
{
if (((!fishingPlayer.ufpsCamera.enabled) ? fishingPlayer.ufpsCamera.transform.localPosition.y : fishingPlayer.ufpsCamera.PositionOffset.y) > kayakSitHeight)
{
fishingPlayer.SitDown(kayakSitHeight, false);
fishingPlayer.ufpsCamera.transform.localPosition = new Vector3(fishingPlayer.ufpsCamera.transform.localPosition.x, fishingPlayer.boatSimulator.kayakSitHeight, fishingPlayer.ufpsCamera.transform.localPosition.z);
}
fishingPlayer.currentHands.kayakHandsAnimation.transform.localPosition = fishingPlayer.currentHands.kayakHandsSwimPos;
}
if (keepMovingForward)
{
animPosY.updatePosition = false;
return;
}
animPosY.updatePosition = true;
Vector3 eulerAngles = base.transform.eulerAngles;
eulerAngles.x = 0f;
eulerAngles.z = 0f;
base.transform.eulerAngles = eulerAngles;
float num = 0f;
float num2 = 0f;
if (VRManager.Instance.IsComfortableDriveBoat())
{
animPosY.updatePosition = false;
animPosY.useX = false;
animPosY.useY = false;
animPosY.useZ = false;
}
else
{
if (currentState == BoatState.PLAYER_DRIVING)
{
}
if ((bool)animPosY)
{
animPosY.multiplier = 1f + currentSpeedFx * animPosYMaxMultiplier;
animPosY.duration = Mathf.Lerp(animPosYDuration.x, animPosYDuration.y, 1f - currentSpeedFx);
}
if (currentState == BoatState.PLAYER_DRIVING)
{
num = Utilities.GetSmoothFactor(maxValue: keyPressedW ? playerForwardMoveMax.x : ((!keyPressedS) ? 0f : playerForwardMoveMax.y), currentValue: playerCurrentMove.z, threshold: 0.75f);
if (keyPressedW)
{
playerCurrentMove.z -= playerForwardMoveSpeed.x * Time.deltaTime * num;
}
else if (keyPressedS)
{
playerCurrentMove.z += playerForwardMoveSpeed.y * Time.deltaTime * num;
}
else if (playerCurrentMove.z < 0f)
{
playerCurrentMove.z += playerForwardMoveSpeed.x * Time.deltaTime * 0.5f * num;
}
else if (playerCurrentMove.z > 0f)
{
playerCurrentMove.z -= playerForwardMoveSpeed.y * Time.deltaTime * 0.5f * num;
}
playerCurrentMove.z = Mathf.Clamp(playerCurrentMove.z, playerForwardMoveMax.x, playerForwardMoveMax.y);
num = Utilities.GetSmoothFactor(maxValue: keyPressedA ? (0f - playerSideRotateMax) : ((!keyPressedD) ? 0f : playerSideRotateMax), currentValue: playerCurrentRotation.z, threshold: 0.75f);
if (keyPressedA)
{
playerCurrentRotation.z -= playerSideRotateSpeed * Time.deltaTime * num;
}
else if (keyPressedD)
{
playerCurrentRotation.z += playerSideRotateSpeed * Time.deltaTime * num;
}
else if (playerCurrentRotation.z < 0f)
{
playerCurrentRotation.z += playerSideRotateSpeed * Time.deltaTime * 0.5f * num;
}
else if (playerCurrentRotation.z > 0f)
{
playerCurrentRotation.z -= playerSideRotateSpeed * Time.deltaTime * 0.5f * num;
}
playerCurrentRotation.z = Mathf.Clamp(playerCurrentRotation.z, 0f - playerSideRotateMax, playerSideRotateMax);
fishingPlayer.transform.localPosition = playerCurrentMove;
fishingPlayer.transform.localEulerAngles = playerCurrentRotation;
}
Vector3 localEulerAngles = engineParentPrevRotation;
if (localEulerAngles.x > 180f)
{
localEulerAngles.x -= 360f;
}
if (localEulerAngles.z > 180f)
{
localEulerAngles.z -= 360f;
}
num = Utilities.GetSmoothFactor(localEulerAngles.x, 0f - engineParentMaxRotationX, 0.85f);
if (keyPressedW)
{
localEulerAngles.x -= engineParentRotationSpeed.x * Time.deltaTime * num;
}
else
{
localEulerAngles.x += engineParentRotationSpeed.x * 1f * Time.deltaTime;
}
num = Utilities.GetSmoothFactor(localEulerAngles.z, (!keyPressedA) ? engineParentMaxRotationZ.x : engineParentMaxRotationZ.y, 0.7f);
if (keyPressedA)
{
localEulerAngles.z += engineParentRotationSpeed.z * Time.deltaTime * (currentWheelFactor + 0.5f) * num;
}
else if (keyPressedD)
{
localEulerAngles.z -= engineParentRotationSpeed.z * Time.deltaTime * (currentWheelFactor + 0.5f) * num;
}
else if (Mathf.Abs(localEulerAngles.z) < 0.1f)
{
localEulerAngles.z = 0f;
}
else
{
localEulerAngles.z += engineParentRotationSpeed.z * Time.deltaTime * Mathf.Lerp(0.05f, 1.2f, Mathf.Abs(localEulerAngles.z / engineParentMaxRotationZ.x)) * ((!(localEulerAngles.z > 0f)) ? 1f : (-1f)) * (1f - noTurningTimer / 0.6f);
}
localEulerAngles.x = Mathf.Clamp(localEulerAngles.x, 0f - engineParentMaxRotationX, 0f);
localEulerAngles.z = Mathf.Clamp(localEulerAngles.z, engineParentMaxRotationZ.x, engineParentMaxRotationZ.y);
engineParentPrevRotation = localEulerAngles;
engineParent.localEulerAngles = localEulerAngles;
}
if ((bool)fishingPlayer && fishingPlayer.currentState == FishingPlayer.PlayerState.WATCH_FISH && fishingPlayer.fish.watchStyle == Fish.WatchStyle.BOAT)
{
base.transform.position = new Vector3(base.transform.position.x, startPosition.position.y - 0.5f, base.transform.position.z);
}
else
{
base.transform.position = new Vector3(base.transform.position.x, startPosition.position.y, base.transform.position.z);
}
}
public void UpdateBoatFloating()
{
if (pauseFloating || ((bool)fishingPlayer.boatSimulator && VRManager.Instance.IsComfortableDriveBoat()))
{
return;
}
Vector3 localEulerAngles = centerParent.localEulerAngles;
bool flag = false;
if (floatingTarget.z > 0f)
{
floatingCurrent.z += floatingSpeed.z * Time.deltaTime;
if (floatingCurrent.z >= floatingTarget.z)
{
flag = true;
}
}
else
{
floatingCurrent.z -= floatingSpeed.z * Time.deltaTime;
if (floatingCurrent.z <= floatingTarget.z)
{
flag = true;
}
}
if (flag)
{
floatingPrevTarget.z = floatingTarget.z;
floatingTarget.z = UnityEngine.Random.Range(1f, centerParentRotZMax) * ((!(floatingTarget.z > 0f)) ? 1f : (-1f));
floatingSpeed.z = UnityEngine.Random.Range(0.8f * centerParentRotZSpeed, 1.2f * centerParentRotZSpeed);
floatingTarget.z *= 1f + currentSpeedFx * floatingTargetMultiplier;
floatingSpeed.z *= 1f + currentSpeedFx * floatingSpeedMultiplier;
}
float t = floatingLerpCurve.Evaluate(Mathf.Abs(floatingCurrent.z - floatingPrevTarget.z) / Mathf.Abs(floatingPrevTarget.z - floatingTarget.z));
localEulerAngles.z = Mathf.Lerp(floatingPrevTarget.z, floatingTarget.z, t);
flag = false;
if (floatingTarget.x > 0f)
{
floatingCurrent.x += floatingSpeed.x * Time.deltaTime;
if (floatingCurrent.x >= floatingTarget.x)
{
flag = true;
}
}
else
{
floatingCurrent.x -= floatingSpeed.x * Time.deltaTime;
if (floatingCurrent.x <= floatingTarget.x)
{
flag = true;
}
}
if (flag)
{
floatingPrevTarget.x = floatingTarget.x;
floatingTarget.x = UnityEngine.Random.Range(1f, centerParentRotXMax) * ((!(floatingTarget.x > 0f)) ? 1f : (-1f));
floatingSpeed.x = UnityEngine.Random.Range(0.8f * centerParentRotXSpeed, 1.2f * centerParentRotXSpeed);
floatingTarget.x *= 1f + currentSpeedFx * floatingTargetMultiplier;
floatingSpeed.x *= 1f + currentSpeedFx * floatingSpeedMultiplier;
}
t = floatingLerpCurve.Evaluate(Mathf.Abs(floatingCurrent.x - floatingPrevTarget.x) / Mathf.Abs(floatingPrevTarget.x - floatingTarget.x));
localEulerAngles.x = Mathf.Lerp(floatingPrevTarget.x, floatingTarget.x, t);
centerParent.localEulerAngles = localEulerAngles;
}
public void UpdateEngineSound(bool started)
{
bool flag = started;
if (flag)
{
flag = keyPressedW || keyPressedS || keepMovingForward;
}
if ((bool)engineAudioObject)
{
if (flag)
{
if (engineAudioObject.IsPaused())
{
engineAudioObject.Unpause();
}
if ((bool)waterAudioObject && waterAudioObject.IsPaused())
{
waterAudioObject.Unpause();
}
}
else
{
if (!engineAudioObject.IsPaused())
{
}
if ((bool)waterAudioObject && waterAudioObject.IsPaused())
{
}
}
}
foreach (ParticleEmitter waterEmitter in waterEmitters)
{
waterEmitter.emit = flag;
}
float num = ((keyPressedW || !keyPressedS) ? 1f : 0.7f);
if (flag && engineForce < num)
{
engineForce += engineForceSpeed * Time.deltaTime;
}
else
{
engineForce -= engineForceSpeed * 1.3f * Time.deltaTime;
}
if (flag)
{
engineForce = Mathf.Clamp(engineForce, 0.3f, 1f);
}
else
{
engineForce = Mathf.Clamp(engineForce, 0f, 1f);
}
float t = engineForce;
if ((bool)engineAudioObject)
{
if (keepMovingForward)
{
engineAudioObject.volume = Mathf.Lerp(engineVolume.x, engineVolume.y, trollingEngineSoundVolume) * AudioController.GetCategoryVolume("SFX");
engineAudioObject.pitch = Mathf.Lerp(enginePitch.x, enginePitch.y, trollingEngineSoundVolume);
if ((bool)waterAudioObject)
{
waterAudioObject.volume = Mathf.Lerp(waterVolume.x, waterVolume.y, trollingEngineSoundVolume) * AudioController.GetCategoryVolume("SFX");
}
}
else if (started)
{
engineAudioObject.volume = Mathf.Lerp(engineVolume.x, engineVolume.y, t) * AudioController.GetCategoryVolume("SFX");
engineAudioObject.pitch = Mathf.Lerp(enginePitch.x, enginePitch.y, t);
if ((bool)waterAudioObject)
{
waterAudioObject.volume = Mathf.Lerp(waterVolume.x, waterVolume.y, t) * AudioController.GetCategoryVolume("SFX");
}
}
else
{
engineAudioObject.volume = 0f;
engineAudioObject.pitch = 1f;
if ((bool)waterAudioObject)
{
waterAudioObject.volume = 0f;
}
}
}
if (!keyPressedW)
{
return;
}
if (engineForce > 0.6f)
{
waterSplashTimer -= Time.deltaTime;
if (waterSplashTimer <= 0f)
{
waterSplashTimer = UnityEngine.Random.Range(4f, 10f);
SplashWater(engineForce);
}
}
waterSplashSmallTimer -= Time.deltaTime;
if (waterSplashSmallTimer <= 0f)
{
waterSplashSmallTimer = UnityEngine.Random.Range(0.03f, 1f);
}
}
public void SplashWater(float strength)
{
if (showCameraDrops)
{
fishingPlayer.WaterSplash(strength, 0.2f);
}
AudioController.Play("SplashBoatBig_01", fishingPlayer.transform, strength);
for (int i = 0; i < waterSplashEffects.Count; i++)
{
waterSplashEffects[i].Play(true);
}
}
public void PauseFloating(bool pause)
{
if (VRManager.Instance.IsComfortableDriveBoat())
{
pause = true;
}
pauseFloating = pause;
animPosY.enabled = !pause;
}
public bool HasRodsOnPod()
{
if ((bool)rodStand)
{
foreach (RodStand.RodPlace rodPlace in rodStand.rodPlaces)
{
if ((bool)rodPlace.fishingRod)
{
return true;
}
}
}
return false;
}
public bool HasRodsWithFishOnPod()
{
if ((bool)rodStand)
{
for (int i = 0; i < rodStand.rodPlaces.Count; i++)
{
if ((bool)rodStand.rodPlaces[i].fishingRod && (bool)rodStand.rodPlaces[i].fishingRod.fishingHands.bait.fish)
{
return true;
}
}
}
return false;
}
public void StopKeepMoving()
{
keepMovingForward = false;
float num = 4f;
foreach (GameObject item in turnOffWhileKeepMoving)
{
item.SetActive(!keepMovingForward);
}
LeanTween.value(0.65f, 0f, num * 0.6f).setOnUpdate(delegate(float value)
{
foreach (GameObject waterEffect in waterEffects)
{
Color color = waterEffect.GetComponent<MeshRenderer>().material.GetColor("_TintColor");
color.a = value;
waterEffect.GetComponent<MeshRenderer>().material.SetColor("_TintColor", color);
}
});
myRigidbody.velocity = Vector3.zero;
myRigidbody.angularVelocity = Vector3.zero;
engineForce = 0f;
if (!keepMovingForward)
{
LeanTween.value(engineAudioObject.volume, 0f, num).setOnUpdate(delegate(float value)
{
engineAudioObject.volume = value;
});
LeanTween.value(waterAudioObject.volume, 0f, num).setOnUpdate(delegate(float value)
{
waterAudioObject.volume = value;
});
}
fishingPlayer.transform.parent = ((!keepMovingForward) ? enterPosition : null);
}
public void RefreshRodStands()
{
if (!GlobalSettings.Instance)
{
return;
}
bool flag = permanentRodStand;
if (GlobalSettings.Instance.equipmentManager.FindEquipment(EquipmentObject.EquipmentType.ROD_STAND, "BOAT_FISH_HOLDERS_01").isBought)
{
flag = true;
}
if ((bool)this.rodStand && !flag)
{
this.rodStand.gameObject.SetActive(false);
this.rodStand = null;
}
else
{
if ((bool)this.rodStand || !flag)
{
return;
}
RodStand[] componentsInChildren = GetComponentsInChildren<RodStand>(true);
RodStand[] array = componentsInChildren;
foreach (RodStand rodStand in array)
{
if (rodStand.transform.parent == objectsParent)
{
this.rodStand = rodStand;
}
}
if ((bool)this.rodStand)
{
this.rodStand.gameObject.SetActive(true);
}
}
}
public void ChangeTeleportPlatformsLayers(bool setMovingPlatforms)
{
}
}