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

989 lines
29 KiB
C#

using System.Collections.Generic;
using BitStrap;
using Moonlit.IceFishing;
using PhysicsTools;
using UnityEngine;
public class FishingLine : MonoBehaviour
{
public enum LineType
{
MONO = 0,
BRAID = 1,
FLUORO = 2,
FLY = 3
}
public enum LineColor
{
WHITE = 0,
YELLOW = 1,
RED = 2,
GREEN = 3,
PURPLE = 4,
BLACK = 5
}
public enum FlyLineType
{
FLOATING = 0,
SINKING = 1,
SINK_TIP = 2
}
public enum LineState
{
IDLE = 0,
FLY = 1,
REEL_IN = 2,
REEL_OUT = 3,
NEAR_COAST = 4
}
public LineType lineType;
public LineColor colorType;
public FlyLineType flyLineType;
public GameObject model;
public MeshRenderer lineModel;
public Material lineMaterial;
public Material lineMaterialOpaque;
public Color lineColor = Color.white;
public Color emissionColor = Color.white;
public float thikness = 0.3f;
public float thiknessDynamic = 0.09f;
public float thiknessStatic = 0.02f;
public float durability = 0.5f;
public float weightDurability;
public float scareFactor;
public bool useDragTension = true;
private float reelInFactor = 1.7f;
[ReadOnly]
[Space(10f)]
public float currentTension;
[HideInInspector]
public float prevTension;
[ReadOnly]
public float breakTensionTimer = 3f;
[ReadOnly]
public float currentTryReelTension;
[ReadOnly]
public float currentPumpTension;
[ReadOnly]
public float tryPullTension;
[ReadOnly]
public float pumpTension;
[HideInInspector]
public FishingRod fishingRod;
[HideInInspector]
public FishingReel fishingReel;
[HideInInspector]
public FishingHands fishingHands;
[HideInInspector]
public FishingLineController FLC;
[HideInInspector]
public Rope currentRope;
[HideInInspector]
public Rope floatRope;
[HideInInspector]
public float isReeling;
[ReadOnly]
public bool isLoose = true;
[ReadOnly]
public bool isLooseColliders = true;
[ReadOnly]
public bool isLooseCanReel = true;
[ReadOnly]
public float looseTensionFactor;
[ReadOnly]
public float looseTensionFactorColliders;
[ReadOnly]
public float stretchFactor;
[ReadOnly]
public float stretchToDistance;
[ReadOnly]
public float stretchTimer;
[ReadOnly]
public float looseLength;
[ReadOnly]
public float looseLengthColliders;
[ReadOnly]
public float looseLengthFloat;
[ReadOnly]
public bool canReelOut = true;
[ReadOnly]
public float currentThrowStrength01;
[ReadOnly]
public float flyRegenerateTimer;
[ReadOnly]
public float fakeStraightLineTimer;
[HideInInspector]
public GameController gameController;
[HideInInspector]
public bool dontUpdate;
[HideInInspector]
public bool canUseProtection = true;
[ReadOnly]
public LineState lineState;
private void Awake()
{
if ((bool)model)
{
model.SetActive(GameController.Instance == null);
}
CalculateWeightDurability();
}
public void ResetMaterial()
{
lineMaterial.color = Color.white;
lineMaterial.SetColor("_EmissionColor", Color.black);
lineMaterialOpaque.color = Color.white;
lineMaterialOpaque.SetColor("_EmissionColor", Color.black);
}
[Button]
public void UpdateModelViewer()
{
lineModel.material.color = lineColor;
}
[Button]
public void UpdateThickness()
{
thikness = Mathf.Lerp(10f, 70f, durability);
if (lineType == LineType.BRAID)
{
thikness *= 0.65f;
}
else if (lineType == LineType.FLY)
{
thikness *= 3f;
}
thikness = Mathf.RoundToInt(thikness);
thikness *= 0.01f;
}
public void MakeUpdate()
{
if (!fishingHands.baitWasThrown)
{
return;
}
if (dontUpdate)
{
dontUpdate = false;
return;
}
fishingReel.UpdateLineAmount(1f - currentRope.getLength() / fishingReel.maxLineLength);
if (gameController == null)
{
gameController = GameController.Instance;
}
lineState = LineState.IDLE;
float num = 0f;
float num2 = 0f;
CalculateLooseLengths();
UpdateLooseFactor();
if (!gameController.iceLevel && !fishingHands.ThrowObjectOnWater())
{
fishingHands.throwObject.transform.position = fishingHands.throwFakeObject.transform.position;
if ((bool)fishingHands.fishingFloat)
{
fishingHands.fishingFloat.transform.LookAt(fishingHands.fishingPlayer.transform.position);
}
currentRope.rate = 1f * FLC.flyRateFactor;
flyRegenerateTimer -= Time.deltaTime;
if (flyRegenerateTimer <= 0f)
{
currentRope.regenerateRope(true);
flyRegenerateTimer = Mathf.Lerp(0f, 0.5f, currentRope.getLength() / 50f);
if (fishingHands.isThrowingNear)
{
flyRegenerateTimer = 0f;
}
}
lineState = LineState.FLY;
return;
}
if (fishingRod.GetThrowObjectDistance() >= fishingReel.maxLineLength && (bool)fishingHands.fishingPlayer.fish && !fishingRod.isOnRodStand)
{
fishingRod.fishingPlayer.LineBreak(Utilities.GetTranslation("HUD_MESSAGE/FISH_ESCAPED") + "\n" + Utilities.GetTranslation("HUD_MESSAGE/NO_LINE"), 1f);
return;
}
UpdateTension();
UpdateCanReelOut();
canUseProtection = true;
if (isReeling != 0f)
{
num2 = (gameController.iceLevel ? Mathf.Lerp(fishingHands.ropeReelInSpeed.z, fishingHands.ropeReelInSpeed.w, (!(isReeling < 0f)) ? fishingHands.currentReelSpeed : fishingHands.currentUserReelSpeed) : Mathf.Lerp(fishingHands.ropeReelInSpeed.x, fishingHands.ropeReelInSpeed.y, (!(isReeling < 0f)) ? fishingHands.currentReelSpeed : fishingHands.currentUserReelSpeed));
if (VRManager.Instance.IsVRReeling())
{
num2 *= VRControllersManager.Instance.handLineSpeedMultiplier;
}
if (fishingHands.isFlyRig)
{
num2 *= 2f;
}
num2 *= 0f - isReeling;
if (isReeling < 0f)
{
num2 *= ((!gameController.iceLevel) ? 0.4f : 1f);
}
}
if ((bool)fishingRod.fishingPlayer.fish && !fishingRod.fishingPlayer.fish.isBaitUpdate && isReeling == 0f && stretchToDistance > Mathf.Lerp(0.001f, 0.2f, fishingReel.GetDragForce()) && fishingRod.fishingPlayer.DragFishStrengthDiff < 0f)
{
num2 = fishingRod.fishingPlayer.fish.currentSpeed;
num2 *= ((!fishingHands.fishingFloat) ? FLC.ropeFishIncMargin : FLC.ropeFishFloatIncMargin);
num2 = ((fishingReel.GetDragForce() != 0f) ? (num2 * (stretchToDistance * Mathf.Lerp(20f, 1f, fishingReel.GetDragForce()))) : (num2 * (stretchToDistance * 50f)));
if (!fishingRod.fishingPlayer.fish.isJerked)
{
}
lineState = LineState.REEL_OUT;
}
num = num2;
if (isReeling > 0f)
{
lineState = LineState.REEL_IN;
}
else if (isReeling < 0f)
{
lineState = LineState.REEL_OUT;
}
if (num < 0f && !CanReelIn())
{
num = 0f;
}
currentRope.rate = num;
if (fishingRod.fishingPlayer.fish == null || fishingRod.fishingPlayer.fish.isBaitUpdate || fishingRod.fishingPlayer.fish.isJerked)
{
canUseProtection = false;
}
if (isReeling > 0f)
{
canUseProtection = false;
}
isReeling = 0f;
}
public void UpdateTension()
{
float num = ((!fishingRod.fishingPlayer.isJerkOn) ? 0f : 0.2f);
float num2 = currentTension;
currentTension = 0f;
if (fishingRod.fishingPlayer.currentState == FishingPlayer.PlayerState.WATCH_FISH)
{
return;
}
currentTension = stretchToDistance / FLC.ropeStretchBreakThreshold;
if ((bool)fishingRod.fishingPlayer.fish)
{
if (fishingRod.fishingPlayer.fishingController.fishCanBePulled)
{
currentTryReelTension = 0f;
pumpTension = 0f;
}
if (currentTryReelTension > 0f)
{
tryPullTension += currentTryReelTension * Time.deltaTime;
}
else
{
tryPullTension -= 2f * Time.deltaTime;
}
tryPullTension = Mathf.Clamp(tryPullTension, 0f, 1f);
currentTension += tryPullTension;
pumpTension -= 0.08f * Time.deltaTime;
pumpTension = Mathf.Clamp(pumpTension, 0f, 1f);
currentTension += pumpTension;
}
if (fishingHands.GetEquipmentDurability() <= 1f)
{
currentTension /= Mathf.Lerp(0.5f, 1.5f, fishingHands.GetEquipmentDurability());
}
else
{
currentTension /= Mathf.Lerp(1.5f, 3f, fishingHands.GetEquipmentDurability() - 1f);
}
if (!fishingRod.fishingPlayer.IsSomethingOnBait())
{
currentTension = 0f;
}
bool flag = (bool)fishingRod.fishingPlayer.boatSimulator && fishingRod.isOnRodStand;
if (stretchToDistance > FLC.ropeStretchBreakThreshold * 1f && !flag && (bool)fishingRod.fishingPlayer.fish && !fishingRod.fishingPlayer.fish.isInNetArea && !fishingRod.fishingPlayer.fish.isWatchingFish)
{
currentTension = 1f;
if (stretchToDistance > FLC.ropeStretchInstantBreakThreshold)
{
Debug.LogError("Line break quick stretchTimer" + stretchToDistance + " " + currentTension + " " + fishingHands.reel.currentDrag);
stretchTimer += Time.deltaTime;
if (!gameController.iceLevel && stretchTimer > 1f && fishingHands.reel.currentDrag > 0f)
{
fishingRod.fishingPlayer.LineBreak(Utilities.GetTranslation("HUD_MESSAGE/LINE_BROKE_TENSION"), 1f);
Debug.LogError("Line BREAK quick " + stretchToDistance + " " + currentTension + " " + fishingHands.reel.currentDrag);
currentRope.regenerateRope(true);
return;
}
}
else
{
stretchTimer = 0f;
}
}
else
{
stretchTimer = 0f;
}
currentTension = Mathf.Clamp(currentTension, 0f, 1f);
if (flag)
{
currentTension = 0f;
}
if ((bool)fishingHands.fishingPlayer.fish && fishingHands.fishingPlayer.fish.isInNetArea)
{
currentTension = 0f;
}
if ((bool)fishingHands.fishingPlayer.fish && fishingHands.fishingPlayer.fish.isTryingBait)
{
currentTension = 0f;
}
if ((bool)fishingHands.fishingPlayer.fish && fishingHands.fishingPlayer.fish.IsItTinyFish())
{
currentTension *= 0.2f;
}
if ((bool)fishingHands.fishingPlayer.fish && fishingHands.fishingPlayer.fish.isOnGround)
{
currentTension = 1f;
if (breakTensionTimer > 0.1f)
{
Debug.LogError("Fish isOnGround break");
breakTensionTimer = 0.1f;
}
}
if (currentTension >= 1f)
{
currentTension = 1f;
breakTensionTimer -= Time.deltaTime;
if (breakTensionTimer <= 0f && (!gameController.fightTest || ((bool)fishingHands.fishingPlayer.fish && fishingHands.fishingPlayer.fish.isOnGround)))
{
fishingRod.fishingPlayer.LineBreak(Utilities.GetTranslation("HUD_MESSAGE/LINE_BROKE_TENSION"), 1f);
Debug.LogError("Line break tension " + stretchToDistance + " " + currentTension + " ");
return;
}
}
if (fishingHands.fishingPlayer.pullForce == 0f && (fishingHands.reel.currentDrag == 0f || !fishingHands.reel.isDragActive))
{
currentTension = 0f;
}
if (num2 < 1f && currentTension >= 1f)
{
gameController.hudManager.hudFishing.StartTensionAlarm(true);
}
else if (num2 >= 1f && currentTension < 1f)
{
gameController.hudManager.hudFishing.StartTensionAlarm(false);
breakTensionTimer = 1.5f;
}
if (currentTension > 0.5f)
{
UtilitiesInput.SetVibration(0, true, Mathf.Lerp(0.1f, 0.55f, Mathf.InverseLerp(0.5f, 1f, currentTension)));
}
else if (UtilitiesInput.GetVibration(0) > 0f)
{
UtilitiesInput.StopVibration(true);
}
num2 = currentTension;
}
public void ReelLine(float direction)
{
isReeling = direction;
}
public void CalculateLooseLengths()
{
if (stretchToDistance > 0.1f)
{
looseLength = 0f;
looseLengthColliders = 0f;
}
else
{
looseLength = currentRope.getLength() - fishingRod.GetThrowObjectDistance();
looseLengthColliders = currentRope.getLengthColliders() - fishingRod.GetThrowObjectDistance();
}
if ((bool)fishingHands.fishingFloat)
{
looseLengthFloat = floatRope.getLength() - fishingRod.GetBaitFloatDistance();
}
}
public void UpdateLooseFactor()
{
bool flag = isLoose;
stretchFactor = currentRope.getLength() - currentRope.getLengthColliders();
stretchToDistance = stretchFactor / Mathf.Clamp(currentRope.getLength(), 0.1f, 666f);
if ((bool)fishingHands.fishingFloat)
{
CheckFloatRopeTension();
}
looseTensionFactor = looseLength;
looseTensionFactor = Mathf.InverseLerp(0f, FLC.fishingLineLooseThreshold, 1f - Mathf.Clamp01(looseTensionFactor));
isLoose = looseTensionFactor < 0.95f;
isLooseCanReel = isLoose;
looseTensionFactorColliders = looseLengthColliders;
looseTensionFactorColliders = Mathf.InverseLerp(0f, FLC.fishingLineLooseThreshold, 1f - Mathf.Clamp01(looseTensionFactorColliders));
isLooseColliders = looseTensionFactorColliders < 0.95f;
if ((bool)fishingHands.fishingFloat && (bool)fishingHands.fishingPlayer.fish && UtilitiesInput.isReelingIn)
{
float num = fishingRod.GetThrowObjectDistance() + fishingRod.GetBaitFloatDistance() - fishingRod.GetBaitDistance();
if (fishingRod.GetBaitDistance() < fishingRod.GetThrowObjectDistance() || num > 0.1f || looseLengthFloat > 0.05f)
{
isLoose = true;
isLooseColliders = true;
looseTensionFactor = 0f;
}
}
if (!fishingHands.fishingPlayer.gameController.iceLevel)
{
UpdateSegmentsDamping();
}
}
public void LateUpdate()
{
if ((bool)fishingHands && (bool)fishingHands.fishingPlayer && Time.timeScale != 0f)
{
if (fishingHands.fishingPlayer.gameController.iceLevel)
{
UpdateIceCollision(fishingHands.fishingPlayer.drillingController.currentHole);
}
if (lineType == LineType.FLY)
{
UpdateFlyLine();
}
UpdateFakeStraightLine();
UpdateFakeFloatLine();
UpdateReelLine();
}
}
private void FixedUpdate()
{
if ((bool)fishingHands && (bool)fishingHands.fishingPlayer && lineType == LineType.FLY)
{
UpdateFlyLine();
}
}
public void CheckFloatRopeTension()
{
float num = floatRope.getLength() - floatRope.getLengthColliders();
float num2 = num / Mathf.Clamp(floatRope.getLength(), 0.1f, 666f);
if (num2 > 0.3f && fishingHands.bait.isOnWater)
{
string text = "stretchFactorFloat " + num + " stretchToDistanceFloat: " + num2 + " floatPos " + fishingHands.fishingFloat.transform.position;
if (fishingHands.fishingPlayer.newFloatRopeRegenerate)
{
string text2 = text;
text = text2 + " FloatRope getLength: " + floatRope.getLength() + " getLengthColliders: " + floatRope.getLengthColliders();
Vector3 vector = fishingHands.bait.transform.position - fishingHands.fishingFloat.transform.position;
Vector3 vector2 = fishingHands.fishingFloat.transform.position - fishingHands.bait.transform.position;
vector = vector.normalized * num;
vector2 = vector2.normalized * fishingHands.floatRopeDepth;
fishingHands.fishingFloat.transform.position = fishingHands.bait.transform.position + vector2;
text2 = text;
text = string.Concat(text2, " floatPos: ", fishingHands.fishingFloat.transform.position, " baitToFloat: ", vector2);
floatRope.CalculateTotalLength();
currentRope.CalculateTotalLength();
text2 = text;
text = text2 + " FloatRope 2 getLength: " + floatRope.getLength() + " getLengthColliders: " + floatRope.getLengthColliders();
}
else if (floatRope.getLength() > fishingHands.maxFloatDistFight)
{
FixFloatDistance();
}
else
{
string text2 = text;
text = text2 + " FloatRope getLength: " + floatRope.getLength() + " getLengthColliders: " + floatRope.getLengthColliders();
floatRope.regenerateRope(true);
}
Debug.LogError(text);
}
}
public void FixFloatDistance()
{
if ((bool)fishingHands.fishingPlayer.fish && fishingHands.fishingPlayer.fish.isWatchingFish)
{
Debug.LogError("FixFloatDistance isWatchingFish");
}
else if (floatRope.getLength() > fishingHands.maxFloatDistFight)
{
Debug.LogError("FloatRope getLength: " + floatRope.getLength() + " getLengthColliders: " + floatRope.getLengthColliders());
Vector3 vector = (fishingHands.fishingFloat.transform.position - fishingHands.bait.transform.position).normalized * fishingHands.maxFloatDistFight;
fishingHands.fishingFloat.transform.position = fishingHands.bait.transform.position + vector;
floatRope.regenerateRope(true);
floatRope.CalculateTotalLength();
currentRope.CalculateTotalLength();
}
}
public void UpdateFakeStraightLine()
{
if (!gameController)
{
return;
}
if (fishingHands.fishingRod.isOnRodStand)
{
if (!fishingHands.fakeStraightLine.enabled)
{
fishingHands.fakeStraightLine.enabled = true;
currentRope.meshRenderer.enabled = false;
}
}
else if (fishingHands.fishingPlayer.currentState == FishingPlayer.PlayerState.WATCH_FISH)
{
fishingHands.fakeStraightLine.enabled = true;
currentRope.meshRenderer.enabled = false;
}
else if (((bool)fishingHands.fishingPlayer.fish || (bool)fishingHands.fishingPlayer.junk || GameController.Instance.stopBaitOnWater) && fishingHands.fishingPlayer.currentState != FishingPlayer.PlayerState.WATCH_FISH)
{
if (fishingHands.fishingRod.bendAngle < fishingHands.fakeStraightLineThreshold && currentRope.totalLength < 100f && !gameController.iceLevel)
{
if (!currentRope.meshRenderer.enabled)
{
fishingHands.fakeStraightLine.enabled = false;
currentRope.meshRenderer.enabled = true;
currentRope.generateOverallMesh();
}
}
else if (!fishingHands.fakeStraightLine.enabled)
{
fishingHands.fakeStraightLine.enabled = true;
currentRope.meshRenderer.enabled = false;
}
}
else if (lineState == LineState.FLY)
{
fishingHands.fakeStraightLine.enabled = true;
currentRope.meshRenderer.enabled = false;
}
else if (!fishingHands.baitWasThrown)
{
if (!gameController.iceLevel)
{
fishingHands.fakeStraightLine.enabled = true;
currentRope.meshRenderer.enabled = false;
}
}
else if (!currentRope.meshRenderer.enabled)
{
fishingHands.fakeStraightLine.enabled = false;
currentRope.meshRenderer.enabled = true;
currentRope.generateOverallMesh();
}
if (gameController.iceLevel)
{
fishingHands.fakeStraightLine.enabled = true;
fishingHands.fakeIceLine.enabled = fishingHands.fakeStraightLine.enabled && !fishingHands.fishingPlayer.fish;
currentRope.meshRenderer.enabled = false;
}
if (lineType == LineType.FLY)
{
fishingHands.fakeLeaderLine.enabled = fishingHands.fakeStraightLine.enabled;
}
if (fishingHands.fakeStraightLine.enabled)
{
Transform transform = ((!gameController.iceLevel) ? currentRope.controlPoints[1].obj.transform : fishingHands.fakeLineIceTarget);
if (fishingHands.fishingPlayer.currentState == FishingPlayer.PlayerState.WATCH_FISH)
{
transform = fishingHands.bait.ropeRigidbody.transform;
}
float num = Vector3.Distance(fishingHands.fakeStraightLine.transform.parent.position, transform.position);
num /= fishingHands.fishingPlayer.vrHandsParent.localScale.y;
if (lineType == LineType.FLY && !gameController.iceLevel)
{
fishingHands.fakeLeaderLine.transform.localScale = new Vector3(fishingHands.fakeLeaderLine.transform.localScale.x, num, fishingHands.fakeLeaderLine.transform.localScale.z);
num -= fishingHands.lineLeaderLength;
fishingHands.swivel.localPosition = Vector3.forward * (num - 0.003f);
}
fishingHands.fakeStraightLine.transform.parent.LookAt(transform);
float num2 = ((!fishingHands.baitWasThrown || fishingHands.fishingPlayer.currentState == FishingPlayer.PlayerState.WATCH_FISH) ? fishingHands.fakeStraightLineThickness.x : fishingHands.fakeStraightLineThickness.y);
fishingHands.fakeStraightLine.transform.localScale = new Vector3(num2, num, num2);
if (gameController.iceLevel)
{
transform = currentRope.controlPoints[1].obj.transform;
fishingHands.fakeIceLine.transform.parent.LookAt(transform);
fishingHands.fakeIceLine.transform.localScale = new Vector3(fishingHands.fakeIceLine.transform.localScale.x, Vector3.Distance(fishingHands.fakeIceLine.transform.parent.position, transform.position), fishingHands.fakeIceLine.transform.localScale.z);
}
if (lineType == LineType.FLY && fishingHands.fishingPlayer.currentState == FishingPlayer.PlayerState.FISHING_NET)
{
fishingHands.fakeStraightLine.enabled = false;
}
}
}
public void UpdateFakeFloatLine()
{
if ((bool)fishingHands.fishingFloat && !fishingHands.baitWasThrown)
{
fishingHands.fakeFloatLine.enabled = true;
floatRope.meshRenderer.enabled = false;
fishingHands.fakeFloatLine.transform.parent.position = floatRope.controlPoints[1].obj.transform.position;
fishingHands.fakeFloatLine.transform.parent.LookAt(floatRope.controlPoints[0].obj.transform);
fishingHands.fakeFloatLine.transform.localScale = new Vector3(fishingHands.fakeFloatLine.transform.localScale.x, Vector3.Distance(fishingHands.fakeFloatLine.transform.parent.position, floatRope.controlPoints[0].obj.transform.position) / fishingHands.fishingPlayer.vrHandsParent.localScale.y, fishingHands.fakeFloatLine.transform.localScale.z);
}
else
{
fishingHands.fakeFloatLine.enabled = false;
if ((bool)fishingHands.fishingFloat)
{
floatRope.meshRenderer.enabled = true;
}
}
}
public float GetTension()
{
return currentTension;
}
public float GetDynamicRopeLength()
{
return currentRope.getLength();
}
public bool isMaxLength()
{
return GetDynamicRopeLength() >= fishingReel.maxLineLength;
}
public bool CanReelIn()
{
if (gameController.iceLevel)
{
return currentRope.getLength() > 0.13f;
}
return currentRope.getLength() > 0.3f;
}
public bool CanReelOut()
{
return canReelOut;
}
public void UpdateCanReelOut()
{
if (gameController.iceLevel)
{
canReelOut = true;
}
else if (looseLength > 1.5f && canReelOut)
{
canReelOut = false;
}
else if (looseLength < 1.3f && !canReelOut)
{
canReelOut = true;
}
}
public void UpdateSegmentsDamping()
{
SoftJointLimit softJointLimit = default(SoftJointLimit);
FishingLineController.SegmentParameters segmentParameters = null;
currentRope.ropeStretchThreshold = FLC.ropeStretchThreshold;
for (int i = 0; i < currentRope.lstSegments.Count; i++)
{
segmentParameters = ((!fishingHands.baitWasThrown && !fishingHands.isFlyRig) ? FLC.idle : ((!fishingHands.baitWasThrown && fishingHands.isFlyRig) ? FLC.air : ((!(currentRope.getLength() < 3.2f)) ? FLC.GetSegmentParameters(currentRope.lstSegments[i], i, looseTensionFactorColliders, currentRope.getLength(), !fishingHands.ThrowObjectOnWater()) : FLC.near)));
currentRope.lstSegments[i].body.useGravity = segmentParameters.gravity;
currentRope.lstSegments[i].body.drag = segmentParameters.drag;
currentRope.lstSegments[i].body.angularDrag = segmentParameters.angularDrag;
float mass = ((!fishingHands.fishingFloat) ? (segmentParameters.massNormal * currentRope.getSegmentProperties().length) : segmentParameters.massFloat);
currentRope.lstSegments[i].body.mass = mass;
softJointLimit.limit = segmentParameters.swingLimit;
if (currentRope.lstSegments[i].prev != null)
{
currentRope.lstSegments[i].prev.joint.GetComponent<ConfigurableJoint>().angularYLimit = softJointLimit;
currentRope.lstSegments[i].prev.joint.GetComponent<ConfigurableJoint>().angularZLimit = softJointLimit;
}
if (currentRope.lstSegments[i].next != null)
{
currentRope.lstSegments[i].next.joint.GetComponent<ConfigurableJoint>().angularYLimit = softJointLimit;
currentRope.lstSegments[i].next.joint.GetComponent<ConfigurableJoint>().angularZLimit = softJointLimit;
}
}
if (floatRope == null)
{
return;
}
for (int j = 0; j < floatRope.lstSegments.Count; j++)
{
segmentParameters = (fishingHands.baitWasThrown ? FLC.GetFloatSegmentParameters(floatRope.lstSegments[j], looseTensionFactorColliders, !fishingHands.ThrowObjectOnWater()) : FLC.idle);
floatRope.lstSegments[j].body.useGravity = segmentParameters.gravity;
floatRope.lstSegments[j].body.drag = segmentParameters.drag;
floatRope.lstSegments[j].body.angularDrag = segmentParameters.angularDrag;
float mass2 = segmentParameters.massFloat * floatRope.getSegmentProperties().length;
floatRope.lstSegments[j].body.mass = mass2;
softJointLimit.limit = segmentParameters.swingLimit;
if (floatRope.lstSegments[j].prev != null)
{
floatRope.lstSegments[j].prev.joint.GetComponent<ConfigurableJoint>().angularYLimit = softJointLimit;
floatRope.lstSegments[j].prev.joint.GetComponent<ConfigurableJoint>().angularZLimit = softJointLimit;
}
if (floatRope.lstSegments[j].next != null)
{
floatRope.lstSegments[j].next.joint.GetComponent<ConfigurableJoint>().angularYLimit = softJointLimit;
floatRope.lstSegments[j].next.joint.GetComponent<ConfigurableJoint>().angularZLimit = softJointLimit;
}
}
}
public void UpdateIceCollision(Hole hole)
{
if (!fishingHands.bait.isOnWater)
{
fishingHands.fakeLineIceTarget.position = currentRope.controlPoints[1].obj.transform.position;
}
else
{
if (hole == null)
{
return;
}
Vector3 position = hole.Data.Position;
float num = hole.Data.Radius * 0.4f;
float depth = hole.Data.Depth;
if (fishingHands.fakeStraightLine.enabled)
{
num = hole.Data.Radius * 0.52f;
Vector3 vector = position;
Vector3 position2 = fishingHands.fakeStraightLine.transform.position;
Vector3 vector2 = currentRope.controlPoints[1].obj.transform.position - position2;
Vector3 vector3 = hole.Data.Position;
RaycastHit hitInfo = default(RaycastHit);
if (Physics.Raycast(position2, vector2.normalized, out hitInfo, 10f, LayerMask.GetMask("Ice", "Terrain")))
{
vector3 = hitInfo.point;
}
vector3.y = hole.Data.Position.y;
Vector3 vector4 = vector3 - position;
float num2 = vector4.magnitude - num;
vector = ((!(num2 < 0f)) ? (hole.Data.Position + vector4.normalized * num) : vector3);
if (!fishingHands.fishingPlayer.fish)
{
vector.y += 0.05f;
}
fishingHands.fakeLineIceTarget.position = vector;
}
if (!FLC.updateIceCollision || !fishingHands.bait.isOnWater || (bool)fishingHands.fishingPlayer.fish)
{
return;
}
List<int> list = new List<int>();
Vector3 zero = Vector3.zero;
Vector3 vector5 = position;
Vector3 zero2 = Vector3.zero;
Vector3 zero3 = Vector3.zero;
float num3 = 0f;
for (int i = 0; i < currentRope.lstSegments.Count; i++)
{
zero = currentRope.lstSegments[i].seg.transform.position;
vector5.y = zero.y;
zero3 = vector5 - zero;
num3 = zero3.magnitude;
if (!(zero.y < position.y + 0.05f) || !(zero.y > position.y - depth - 0.05f))
{
continue;
}
if (num3 > num)
{
zero2 = vector5 + (zero - vector5).normalized * num;
currentRope.lstSegments[i].body.AddForce(zero3 * FLC.iceCollisionForce, FLC.iceCollisionForceMode);
currentRope.lstSegments[i].seg.transform.position = zero2;
if (list.Count == 0 && i <= 0)
{
}
}
list.Add(i);
}
currentRope.generateOverallMesh();
}
}
public void UpdateFlyLine()
{
if (flyLineType == FlyLineType.SINKING || !fishingHands.baitWasThrown || (bool)fishingHands.fishingPlayer.fish || currentRope.lstSegments.Count <= 2)
{
return;
}
int num = ((fishingHands.bait.flyType == Bait.FlyType.DRY) ? 1 : 2);
if (flyLineType == FlyLineType.SINK_TIP)
{
num = 3;
}
Vector3 zero = Vector3.zero;
for (int i = 0; i < currentRope.lstSegments.Count - num; i++)
{
zero = currentRope.lstSegments[i].seg.transform.position;
if (zero.y < 0f)
{
zero.y = 0f;
currentRope.lstSegments[i].seg.transform.position = zero;
}
}
currentRope.generateOverallMesh();
}
public void UpdateReelLine()
{
if ((bool)fishingHands.reelLineParent && (bool)fishingHands.reel.reelLineFinish)
{
if (fishingHands.updateLeftArmFly && !fishingHands.fishingRod.isOnRodStand)
{
fishingHands.reelLineParent.position = fishingHands.flyReelLineParent.transform.position;
fishingHands.reelLine.transform.localScale = new Vector3(fishingHands.reelLine.transform.localScale.x, Vector3.Distance(fishingHands.fishingRod.reelLineAttach.position, fishingHands.reelLine.transform.position) / fishingHands.fishingPlayer.vrHandsParent.localScale.y, fishingHands.reelLine.transform.localScale.z);
fishingHands.reelLineParent.LookAt(fishingHands.fishingRod.reelLineAttach.position, base.transform.right);
}
else
{
fishingHands.reelLine.transform.localScale = new Vector3(fishingHands.reelLine.transform.localScale.x, Vector3.Distance(fishingHands.fishingRod.reelLineAttach.position, fishingHands.reel.reelLineFinish.position) / fishingHands.fishingPlayer.vrHandsParent.localScale.y, fishingHands.reelLine.transform.localScale.z);
fishingHands.reelLineParent.position = fishingHands.reel.reelLineFinish.position;
fishingHands.reelLineParent.LookAt(fishingHands.fishingRod.reelLineAttach.position, base.transform.right);
}
}
}
[Button]
public void CalculateWeightDurability()
{
if (durability <= 1f)
{
weightDurability = Mathf.Lerp(0f, 40f, Mathf.Pow(durability, 2f));
}
else
{
weightDurability = Mathf.Lerp(45f, 85f, Mathf.Pow(durability - 1f, 2f));
}
}
public void RemoveLineOverhead(float addPercent)
{
CalculateLooseLengths();
if (!(looseLengthColliders < 0f))
{
float num = Mathf.Max(looseLength, looseLengthColliders);
if (num > 0.005f)
{
num += currentRope.getLength() * addPercent;
}
num = Mathf.Clamp(num, 0f, 666f);
Debug.Log("lineOverhead: " + num + " looseLength " + looseLength + " looseLengthColliders " + looseLengthColliders);
currentRope.changeLength(0f - num);
}
}
[Button]
public void RemoveLineOverheadZero()
{
RemoveLineOverhead(0f);
}
[Button]
public void RemoveLineOverheadOne()
{
RemoveLineOverhead(0.1f);
}
[Button]
public void SetLengthWithOutTensionTest()
{
SetLengthWithTension(0f);
}
[Button]
public void SetLengthWithTensionTest()
{
SetLengthWithTension(0.1f);
}
public void SetLengthWithTension(float tension)
{
float throwObjectDistance = fishingRod.GetThrowObjectDistance();
throwObjectDistance *= 1f - tension;
currentRope.setLength(throwObjectDistance);
}
[Button]
public void FixLooseColliders()
{
if (stretchFactor > 0f)
{
currentRope.changeLength(stretchFactor);
}
}
[Button]
public void SetLineLength()
{
}
[Button]
public void AddLineLength()
{
currentRope.changeLength(0.1f);
}
}