using System; using System.Collections.Generic; using System.Linq; using RootMotion.FinalIK; using UFS2.Gameplay; using UnityEngine; using UnityEngine.Events; public class FRod : MonoBehaviour { public enum RodType { Float = 0, Spinning = 1, Feeder = 2 } public class LureCastArgs { public string mapName; public Vector3 playerPosition; public Vector3 LurePosition; } [Serializable] public class RodPlayTranform : UnityEvent { } [Serializable] public class RodWhooshEvent : UnityEvent { } public RodType rodType = RodType.Spinning; public GameManager.GameRods.Action action; public Transform armatureHandPoster; public Transform reelContainer; private CCDIK _ccdik; [HideInInspector] public bool isDamaged; [HideInInspector] public FFishingLine fishingLine; [HideInInspector] public FPlayer currentPlayer; [HideInInspector] public float throwPower; [HideInInspector] public float throwPowerForSounds; [HideInInspector] public float throwForcePower; [HideInInspector] public float throwForceMaxPower; public float throwMinPower; [HideInInspector] public float throwForceMaxNearPower = 300f; public float throwMinNearPower; public float currentRodStrength; public float maxRodStrength = 10f; [HideInInspector] public int indexOfslot = -1; public bool isThrowing; private bool isTargetNearThrow; [HideInInspector] public float throwNearPower; private bool isTargetFarThrow; private Vector3 newThrowPosition = Vector3.zero; public FWaterDisplacement LureHookWaterDisplacement; public bool isRodCast; private bool isRodTension; public FReel assignReel; [HideInInspector] public FReel currentReel; public FLure assignLure; private FLure _currentLure; public FFloat assignFloat; [HideInInspector] public FFloat currentFloat; public FHook assignHook; [HideInInspector] public FHook currentHook; public FFeeder assignFeeder; [HideInInspector] public FFeeder currentFeeder; public FBait assignBait; [HideInInspector] public FBait currentBait; public FLine assignLine; [HideInInspector] public FLine currentLine; public FWeight assignWeight; [HideInInspector] public FWeight currentWeight; public FFish assignFish; [HideInInspector] public FFish currentFish; [HideInInspector] public FFish takeFish; public FishEntity currentFishEntity; public AudioClip[] audioClips; private AudioSource audioSource; [HideInInspector] public RodSupport dropRodTargetSupport; private float bendSmooth = 1f; private List previousWeights = Enumerable.Repeat(0f, 10).ToList(); public static Action OnEquipmentBreak; public static Action OnFishStrike; public static Action OnLureCast; public static Action OnRodTakeOut; public RodPlayTranform OnRodDamaged; public RodPlayTranform OnLineCuted; public RodPlayTranform OnFishStriked; public RodWhooshEvent OnRodWhooshStart; public RodWhooshEvent OnRodWhooshEnd; private bool isCastSound; private bool isTensionSound = true; [HideInInspector] public bool isStriked; public float CurrentRodStrength01 => currentRodStrength / maxRodStrength; public float CurrentTension01 { get { float value = 0f; if ((bool)currentReel && (bool)fishingLine) { float linePullingForce = currentReel.LinePullingForce; value = Mathf.Min(fishingLine.CurrentLineTension, linePullingForce) / maxRodStrength; } return Mathf.Clamp01(value); } } [HideInInspector] public FLure currentLure { get { return _currentLure; } set { FLure.CurrentLure = value; _currentLure = value; } } public static event Action OnRodDamagedGlobal; public static event Action OnLineCutedGlobal; public static event Action OnFishStrikedGlobal; public static event Action OnRodWhooshStartGlobal; public static event Action OnRodWhooshEndGlobal; public static event Action OnRodTensionGlobal; public static event Action OnDamage; public static event Action OnFishTake; private void Start() { fishingLine = GetComponent(); SetupAudio(); SetupIK(10); } private void OnPostUpdate() { fishingLine.RenderLine(); } private void Update() { BendControll(); CreateAndRenderWeight(); if (InputManager.isCastReset) { CutLine(); } CheckAndConnectReel(); CheckAndConnectLure(); CheckAndConnectFloat(); CheckAndConnectHook(); CheckAndConnectFeeder(); CheckAndConnectFish(); CheckAndConnectBait(); CheckAndConnectLine(); CheckAndConnectWeight(); CalculateRodStrength(); if ((bool)LureHookWaterDisplacement && fishingLine.linelenghtDiferent > 1f) { _ = LureHookWaterDisplacement.transform.position.y; _ = 0.1f; } if (isTargetNearThrow) { if (!isCastSound) { FRod.OnRodWhooshStartGlobal?.Invoke(throwPower, base.transform); isCastSound = true; } float value = currentPlayer.notValidTargetValue / 20f; value = Mathf.Clamp(value, -5f, 5f); newThrowPosition = currentPlayer.currentNearThrowTarget.transform.position + base.transform.forward * value; newThrowPosition.y = base.transform.position.y + 2f; LureHookWaterDisplacement.rigidbody.isKinematic = true; LureHookWaterDisplacement.transform.position = Vector3.MoveTowards(LureHookWaterDisplacement.rigidbody.position, newThrowPosition, Time.deltaTime * 15f); if ((bool)currentFloat) { currentFloat.rigidbody.isKinematic = true; currentFloat.transform.position = Vector3.MoveTowards(currentFloat.rigidbody.position, newThrowPosition, Time.deltaTime * 14f); } if ((bool)currentFeeder) { currentFeeder.rigidbody.isKinematic = true; currentFeeder.transform.position = Vector3.MoveTowards(currentFeeder.rigidbody.position, newThrowPosition, Time.deltaTime * 14f); } if (LureHookWaterDisplacement.transform.position == newThrowPosition) { LureHookWaterDisplacement.rigidbody.isKinematic = false; if ((bool)currentFloat) { currentFloat.rigidbody.isKinematic = false; } if ((bool)currentFeeder) { currentFeeder.rigidbody.isKinematic = false; } isTargetNearThrow = false; throwNearPower = 0f; currentPlayer.ShowHideNearThrowTarget(Vector3.zero, isHide: true); isThrowing = false; LureCastArgs lureCastArgs = new LureCastArgs(); lureCastArgs.playerPosition = currentPlayer.transform.position; lureCastArgs.LurePosition = newThrowPosition; int sceneID = FScriptsHandler.Instance.m_SceneSettings.sceneID; lureCastArgs.mapName = GameManager.Instance.gameLocations[sceneID].name; OnLureCast?.Invoke(lureCastArgs); FRod.OnRodWhooshEndGlobal?.Invoke(base.transform); newThrowPosition = Vector3.zero; isRodCast = true; isCastSound = false; } } if (!isTargetFarThrow) { return; } if (!isCastSound) { FRod.OnRodWhooshStartGlobal?.Invoke(throwPower, base.transform); isCastSound = true; } if (newThrowPosition == Vector3.zero) { newThrowPosition = currentPlayer.transform.position + base.transform.forward * throwForcePower; } float num = Vector3.Distance(base.transform.position, newThrowPosition); newThrowPosition.y = base.transform.position.y + 2f + num * 0.1f; float num2 = 5f + num * 0.35f; LureHookWaterDisplacement.rigidbody.isKinematic = true; LureHookWaterDisplacement.transform.position = Vector3.MoveTowards(LureHookWaterDisplacement.rigidbody.position, newThrowPosition, Time.deltaTime * num2); if ((bool)currentFloat) { currentFloat.rigidbody.isKinematic = true; currentFloat.transform.position = Vector3.MoveTowards(currentFloat.rigidbody.position, newThrowPosition, Time.deltaTime * (num2 - 1f)); } if ((bool)currentFeeder) { currentFeeder.rigidbody.isKinematic = true; currentFeeder.transform.position = Vector3.MoveTowards(currentFeeder.rigidbody.position, newThrowPosition, Time.deltaTime * (num2 - 1f)); } if (LureHookWaterDisplacement.transform.position == newThrowPosition) { LureHookWaterDisplacement.rigidbody.isKinematic = false; if ((bool)currentFloat) { currentFloat.rigidbody.isKinematic = false; } if ((bool)currentFeeder) { currentFeeder.rigidbody.isKinematic = false; } isTargetFarThrow = false; throwForcePower = 0f; isThrowing = false; LureCastArgs lureCastArgs2 = new LureCastArgs(); lureCastArgs2.playerPosition = currentPlayer.transform.position; lureCastArgs2.LurePosition = newThrowPosition; int sceneID2 = FScriptsHandler.Instance.m_SceneSettings.sceneID; lureCastArgs2.mapName = GameManager.Instance.gameLocations[sceneID2].name; OnLureCast?.Invoke(lureCastArgs2); FRod.OnRodWhooshEndGlobal(base.transform); newThrowPosition = Vector3.zero; isRodCast = true; isCastSound = false; } } public bool CheckIsInUse() { if (isThrowing) { return true; } if (throwPower > 0f) { return true; } if ((bool)currentHook) { if (fishingLine.currentLineHandler.PhisicsLineOut == 0f) { return false; } if (currentHook.transform.position.y < 0f) { return true; } } if ((bool)currentLure) { if (fishingLine.currentLineHandler.PhisicsLineOut == 0f) { return false; } if (currentLure.transform.position.y < 0f) { return true; } } if ((bool)currentFish) { return true; } return false; } private void CreateAndRenderWeight() { if ((bool)currentWeight && (bool)fishingLine && (bool)fishingLine.currentLineHandler && fishingLine.currentLineHandler.lineType != FLineHandler.LineType.OneSegment) { int num = fishingLine.currentLineHandler.obiRopeSegment_2.activeParticleCount / 2; for (int i = 0; i < currentWeight.weightObjects.Length; i++) { currentWeight.weightObjects[i].transform.position = fishingLine.currentLineHandler.obiRopeSegment_2.GetParticlePosition(fishingLine.currentLineHandler.obiRopeSegment_2.solverIndices[num + i]); } } } private void CalculateRodStrength() { if ((bool)fishingLine && (bool)fishingLine.currentLineHandler && maxRodStrength != 0f) { currentRodStrength = fishingLine.CurrentLineTension; } } public void Damage() { if (!TutorialManager.Instance && !isDamaged && (!fishingLine || fishingLine.rodLinePoints.Length >= 4) && (!currentFish || !currentFish.isGetFish)) { int num = fishingLine.rodLinePoints.Length / 2; Transform parent = fishingLine.rodLinePoints[num].parent; parent.gameObject.layer = LayerMask.NameToLayer("IgnoreAll"); Rigidbody rigidbody = fishingLine.rodLinePoints[num + 1].parent.gameObject.AddComponent(); rigidbody.isKinematic = true; parent.gameObject.AddComponent().drag = 1f; rigidbody.isKinematic = true; if (!parent.TryGetComponent(out var component)) { component = parent.gameObject.AddComponent(); component.xMotion = ConfigurableJointMotion.Locked; component.yMotion = ConfigurableJointMotion.Locked; component.zMotion = ConfigurableJointMotion.Locked; component.angularXMotion = ConfigurableJointMotion.Free; component.angularYMotion = ConfigurableJointMotion.Free; component.angularZMotion = ConfigurableJointMotion.Free; component.connectedBody = rigidbody; BoxCollider boxCollider = parent.gameObject.AddComponent(); boxCollider.size = Vector3.one * 0.01f; boxCollider.center = new Vector3(-0.1f, 0f, 0f); Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[indexOfslot].SetWearRodReel(GameManager.ItemType.Rod, 0); OnRodDamaged?.Invoke(base.transform); isDamaged = true; FRod.OnDamage?.Invoke(this); OnEquipmentBreak?.Invoke(this); CutLine(); Invoke("MsgDamaged", 2f); } } } private void MsgDamaged() { GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("SET_DAMAGED"), FScriptsHandler.Instance.m_Canvas.transform); } public void CutLine(bool destroyBaits = false) { if (currentPlayer == null) { return; } if ((bool)FishEntity.CurrentFishInFight) { if ((bool)TutorialManager.Instance) { return; } GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("CUT_FISH"), FScriptsHandler.Instance.m_Canvas.transform); OnLineCuted?.Invoke(base.transform); FRod.OnLineCutedGlobal?.Invoke(base.transform); if ((bool)currentHook) { SubLine(1f); } if (!TutorialManager.Instance) { if ((bool)currentLure) { fishingLine.currentLineHandler.PhisicsLineOut = 0f; fishingLine.currentLineHandler.EndLineRigidbody_1.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; isRodCast = false; if (!Singleton.Instance.HasCurrentPlayerSkill(GameManager.Skills.iron_bait)) { Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[indexOfslot].SubLastLeaderItemsByCut(GameManager.ItemType.Bait, this); } SubLine(1f); } else if ((bool)currentHook) { if ((bool)currentFloat) { fishingLine.currentLineHandler.SetSegmentTwoLenght(0.2f); } if ((bool)currentFloat) { currentFloat.currentFloatDeepth = 0.2f; } fishingLine.currentLineHandler.PhisicsLineOut = 0f; if ((bool)fishingLine.currentLineHandler.EndLineRigidbody_1) { fishingLine.currentLineHandler.EndLineRigidbody_1.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)fishingLine.currentLineHandler.EndLineRigidbody_2) { fishingLine.currentLineHandler.EndLineRigidbody_2.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)fishingLine.currentLineHandler.EndLineRigidbody_3) { fishingLine.currentLineHandler.EndLineRigidbody_3.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)currentFloat) { currentFloat.transform.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)currentHook) { currentHook.transform.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[indexOfslot].SubLastLeaderItemsByCut(GameManager.ItemType.Hook, this); isRodCast = false; } } FRod.OnLineCutedGlobal?.Invoke(base.transform); return; } fishingLine.currentLineHandler.PhisicsLineOut = 0f; fishingLine.currentLineHandler.ObiLineOut = 0f; if ((bool)fishingLine.currentLineHandler.EndLineRigidbody_1) { fishingLine.currentLineHandler.EndLineRigidbody_1.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)fishingLine.currentLineHandler.EndLineRigidbody_2) { fishingLine.currentLineHandler.EndLineRigidbody_2.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)fishingLine.currentLineHandler.EndLineRigidbody_3) { fishingLine.currentLineHandler.EndLineRigidbody_3.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)currentFloat) { currentFloat.transform.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)currentHook) { currentHook.transform.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } if ((bool)currentLure) { currentLure.transform.position = fishingLine.currentLineHandler.EndLineRigidbody_0.position; } isRodCast = false; if (!destroyBaits) { return; } if ((bool)currentLure) { Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[indexOfslot].SubLastLeaderItemsByCut(GameManager.ItemType.Bait, this); SubLine(1f); } if ((bool)currentHook) { if ((bool)currentFloat) { fishingLine.currentLineHandler.SetSegmentTwoLenght(0.2f); } if ((bool)currentFloat) { currentFloat.currentFloatDeepth = 0.2f; } Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[indexOfslot].SubLastLeaderItemsByCut(GameManager.ItemType.Hook, this); SubLine(1f); } } private void SetupAudio() { audioSource = base.gameObject.AddComponent(); audioSource.playOnAwake = false; audioSource.spatialBlend = 1f; } private void WhooshSoundsFX(float throwPower) { if (!audioSource.isPlaying) { audioSource.pitch = 1f + Mathf.Clamp01(throwPower * 0.001f); audioSource.volume = 0f + Mathf.Clamp01(throwPower * 0.0005f); audioSource.loop = false; audioSource.clip = audioClips[0]; audioSource.Play(); } } private void WhooshSound() { } private void DamageSoundsFX() { if (!audioSource.isPlaying) { audioSource.pitch = 1.2f; audioSource.volume = 0.1f; audioSource.loop = false; audioSource.clip = audioClips[1]; audioSource.Play(); } } private void CutLineSoundsFX() { if (!audioSource.isPlaying) { audioSource.pitch = 1.2f; audioSource.volume = 0.1f; audioSource.loop = false; audioSource.clip = audioClips[2]; audioSource.Play(); } } private void StrikeSoundsFX() { if (!(audioClips[3] == null) && !audioSource.isPlaying) { audioSource.pitch = 1f; audioSource.volume = 0.02f; audioSource.loop = false; audioSource.clip = audioClips[3]; audioSource.Play(); } } private void BendControll() { if (fishingLine.currentLineHandler == null || isDamaged) { _ccdik.solver.target = null; _ccdik.solver.SetIKPositionWeight(0f); return; } Vector3 vector = (FishEntity.CurrentFishInFight ? FishEntity.CurrentFishInFight.transform.position : fishingLine.currentLineHandler.LineConnector_1.transform.position); float num = Vector3.Distance(_ccdik.solver.bones.Last().transform.position, vector); float num2 = 0.05f; if ((bool)FishEntity.CurrentFishInFight) { float num3 = Vector3.Angle(base.transform.forward, (FishEntity.CurrentFishInFight.transform.position - base.transform.position).normalized) / 180f; num2 = Mathf.Clamp(CurrentTension01 * num3, 0.05f, 1f); } else if (!isThrowing) { float num4 = 0.3f; if ((bool)currentLure) { num4 *= 0.6f; } if ((bool)currentFloat) { num4 *= 0.8f; } if ((bool)currentFeeder) { num4 *= 1f; } float num5 = 1.5f; if (num < num5) { num2 = Mathf.Lerp(num2, num4, 1f - num / num5); } } float num6 = 0.3f; if (isThrowing) { num6 = 0.1f; } else if (!FishEntity.CurrentFishInFight) { num6 = 0.2f; } float target = num2 * num6; float item = Mathf.MoveTowards(_ccdik.solver.IKPositionWeight, target, Time.deltaTime * bendSmooth); previousWeights.RemoveAt(0); previousWeights.Add(item); float num7 = previousWeights.Average(); if ((bool)FishEntity.CurrentFishInFight && FishEntity.CurrentFishInFight.IsCatched) { num7 = Math.Min(num7, 0.01f); } _ccdik.solver.SetIKPosition(vector); _ccdik.solver.SetIKPositionWeight(num7); if ((bool)FishEntity.CurrentFishInFight && (double)num2 > 0.5163254 && !isRodTension) { isRodTension = true; FRod.OnRodTensionGlobal?.Invoke(base.transform); } else if ((double)num2 < 0.363254 && isRodTension) { isRodTension = false; } } private void CheckAndConnectReel() { if ((bool)assignReel && !(assignReel == currentReel)) { if ((bool)currentReel) { UnityEngine.Object.Destroy(currentReel.gameObject); } currentReel = assignReel; assignReel = null; currentReel.transform.SetParent(reelContainer); currentReel.transform.localPosition = Vector3.zero; currentReel.transform.localEulerAngles = Vector3.zero; currentReel.currentRod = this; switch (rodType) { case RodType.Float: fishingLine.CreateObiFishingLine(0); break; case RodType.Spinning: fishingLine.CreateObiFishingLine(1); break; case RodType.Feeder: fishingLine.CreateObiFishingLine(2); break; } } } private void CheckAndConnectLure() { if (rodType == RodType.Spinning && (bool)fishingLine.currentLineHandler && (bool)assignLure && !(assignLure == currentLure)) { if ((bool)currentLure) { UnityEngine.Object.Destroy(currentLure.gameObject); LureHookWaterDisplacement = null; } currentLure = assignLure; assignLure = null; currentLure.currentRod = this; currentLure.transform.position = fishingLine.currentLineHandler.LineConnector_1.transform.position; currentLure.gameObject.GetComponent().connectedBody = fishingLine.currentLineHandler.LineConnector_1.GetComponent(); LureHookWaterDisplacement = currentLure.GetComponent(); } } private void CheckAndConnectHook() { if ((rodType == RodType.Feeder || rodType == RodType.Float) && (bool)fishingLine.currentLineHandler && (bool)assignHook && !(assignHook == currentHook)) { if ((bool)currentHook) { UnityEngine.Object.Destroy(currentHook.gameObject); LureHookWaterDisplacement = null; } currentHook = assignHook; assignHook = null; currentHook.currentRod = this; currentHook.transform.position = fishingLine.currentLineHandler.LineConnector_2.transform.position; currentHook.gameObject.GetComponent().connectedBody = fishingLine.currentLineHandler.LineConnector_2.GetComponent(); LureHookWaterDisplacement = currentHook.GetComponent(); } } private void CheckAndConnectFloat() { if (rodType == RodType.Float && (bool)fishingLine.currentLineHandler && (bool)assignFloat && !(assignFloat == currentFloat)) { if ((bool)currentFloat) { UnityEngine.Object.Destroy(currentFloat.gameObject); } currentFloat = assignFloat; assignFloat = null; currentFloat.currentRod = this; currentFloat.transform.position = fishingLine.currentLineHandler.LineConnector_1.transform.position; currentFloat.gameObject.GetComponent().connectedBody = fishingLine.currentLineHandler.LineConnector_1.GetComponent(); } } private void CheckAndConnectFeeder() { if (rodType == RodType.Feeder && (bool)fishingLine.currentLineHandler && (bool)assignFeeder && !(assignFeeder == currentFeeder)) { if ((bool)currentFeeder) { UnityEngine.Object.Destroy(currentFeeder.gameObject); } currentFeeder = assignFeeder; assignFeeder = null; currentFeeder.currentRod = this; currentFeeder.transform.position = fishingLine.currentLineHandler.LineConnector_3.transform.position; currentFeeder.gameObject.GetComponent().connectedBody = fishingLine.currentLineHandler.LineConnector_3.GetComponent(); } } private void CheckAndConnectFish() { if ((bool)fishingLine.currentLineHandler && (bool)assignFish && !(assignFish == currentFish)) { if ((bool)currentFish) { UnityEngine.Object.Destroy(currentFish.gameObject); } currentFish = assignFish; assignFish = null; OnFishStrike?.Invoke(this); } } private void CheckAndConnectBait() { if ((rodType == RodType.Feeder || rodType == RodType.Float) && (bool)fishingLine.currentLineHandler && (bool)assignBait && (bool)currentHook && !(assignBait == currentBait)) { if ((bool)currentBait) { UnityEngine.Object.Destroy(currentBait.gameObject); } currentBait = assignBait; assignBait = null; currentBait.transform.position = currentHook.baitContainer.position; currentBait.transform.SetParent(currentHook.baitContainer); } } private void CheckAndConnectLine() { if ((bool)fishingLine.currentLineHandler && (bool)assignLine && !(assignLine == currentLine)) { currentLine = assignLine; assignLine = null; if ((bool)fishingLine.currentLineHandler.obiRopeSegment_1) { fishingLine.currentLineHandler.obiRopeSegment_1.GetComponent().material = currentLine.lineMat; } if ((bool)fishingLine.currentLineHandler.obiRopeSegment_2) { fishingLine.currentLineHandler.obiRopeSegment_2.GetComponent().material = currentLine.lineMat; } if ((bool)fishingLine.currentLineHandler.obiRopeSegment_3) { fishingLine.currentLineHandler.obiRopeSegment_3.GetComponent().material = currentLine.lineMat; } fishingLine.lineRenderer.material = currentLine.lineMat; currentReel.SpoolObject.GetComponent().material = currentLine.szpulaMat; fishingLine.lineStrenght = currentLine.strength; OnRodTakeOut?.Invoke(this); } } private void CheckAndConnectWeight() { if ((rodType == RodType.Feeder || rodType == RodType.Float) && (bool)fishingLine.currentLineHandler && (bool)assignWeight && !(assignWeight == currentWeight)) { if ((bool)currentWeight) { UnityEngine.Object.Destroy(currentWeight.gameObject); } currentWeight = assignWeight; assignWeight = null; } } public void DestroyCurrentFish() { Debug.Log("Destroy fish frod"); if ((bool)currentPlayer.currentChwytak) { UnityEngine.Object.Destroy(currentPlayer.currentChwytak.gameObject); currentPlayer.currentChwytak = null; Debug.Log("Destroy chwytak"); } if ((bool)currentFish) { UnityEngine.Object.Destroy(currentFish.gameObject); currentFish = null; } } public void SetupIK(int maxIterations = 3) { _ccdik = GetComponent(); IKSolverCCD solver = _ccdik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostUpdate)); Transform current = _ccdik.solver.bones.FirstOrDefault()?.transform; List list = new List(); while (current != null && current.parent != null) { current = current.parent; if (!current.name.ToLower().Contains("bone") || _ccdik.solver.bones.Any((IKSolver.Bone b) => b.transform == current) || !(current.GetComponent() == null)) { break; } list.Add(current); } if (list.Count >= 2) { List list2 = list; list2.Reverse(); list2.RemoveAt(0); list2.AddRange(_ccdik.solver.bones.Select((IKSolver.Bone b) => b.transform)); _ccdik.solver.SetChain(list2.ToArray(), base.transform); } int num = 14; int num2 = 6; if (_ccdik.solver.bones.Length > num) { List list3 = _ccdik.solver.bones.Select((IKSolver.Bone element) => element.transform).ToList(); while (list3.Count > num) { List list4 = new List(); for (int num3 = list3.Count - 2; num3 > num2; num3 -= 2) { list4.Add(list3[num3].transform); } for (int num4 = 0; num4 < list4.Count; num4++) { if (list3.Count <= num) { break; } list3.Remove(list4[num4]); } } _ccdik.solver.SetChain(list3.ToArray(), base.transform); } AnimationCurve rodActionCurve = FScriptsHandler.Instance.GetRodActionCurve(action); int num5 = _ccdik.solver.bones.Length; for (int num6 = 0; num6 < num5; num6++) { float time = (float)num6 / (float)(num5 - 1); float weight = rodActionCurve.Evaluate(time); _ccdik.solver.bones[num6].weight = weight; } _ccdik.solver.maxIterations = maxIterations; _ccdik.solver.tolerance = 0.001f; } public void CastFish() { if (!currentFish && (bool)takeFish) { Debug.Log("Zaciecie"); if (fishingLine.linelenghtDiferent > 0f) { assignFish = takeFish; takeFish = null; isStriked = false; FRod.OnFishTake?.Invoke(); SubNaturalBait(); } } } public void SubNaturalBait() { if ((bool)currentBait) { Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[indexOfslot].SubNaturalBait(currentBait.gameObject); } } public void SubLine(float value) { if ((bool)currentLine) { Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[indexOfslot].SubLine(value); } } public void ForceThrow(bool isNear = false) { if ((bool)LureHookWaterDisplacement) { if ((bool)currentPlayer.currentNearThrowTarget) { isTargetNearThrow = true; } else { isTargetFarThrow = true; Debug.Log("Throw Force!!!"); OnRodWhooshStart?.Invoke(throwPower, base.transform); } } throwPower = 0f; } private void OnDestroy() { Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[indexOfslot].rod.status = GameManager.PlayerData.CRods.Status.InEquip; if ((bool)fishingLine) { fishingLine.DestroyObiLine(); } if ((bool)currentReel) { UnityEngine.Object.Destroy(currentReel.gameObject); } if ((bool)currentFloat) { UnityEngine.Object.Destroy(currentFloat.gameObject); } if ((bool)currentHook) { UnityEngine.Object.Destroy(currentHook.gameObject); } if ((bool)currentLure) { UnityEngine.Object.Destroy(currentLure.gameObject); } if ((bool)currentFeeder) { UnityEngine.Object.Destroy(currentFeeder.gameObject); } if ((bool)currentFish) { UnityEngine.Object.Destroy(currentFish.gameObject); } if ((bool)currentWeight) { UnityEngine.Object.Destroy(currentWeight.gameObject); } } }