using UFS2.Gameplay; using UFS2.Helpers; using UnityEngine; using UnityEngine.UI; public class WaterPointer : MonoBehaviour { public float lineStrenght; private float lineStrenghtEnd; public GameObject sternghtLine; public Image sternghtLineProgressImage; public Vector3 worldPoint; private RectTransform rectTransform; private Color normalFillColor; public Color maxvalueFillColor; public Text distanceText; public Text fishSpeciesText; public Text fishWeightText; public Text fightTimeText; public Text staminaText; public Image _StaminaImage; public GameObject _StaminaContainer; private CanvasGroup _CanvasGroup; private bool isEnabled; private bool isGamePaused; private void OnEnable() { _CanvasGroup = GetComponent(); EscapeMenu.OnEscapeMenuChange += SetEnable; FishEntity.OnSetCurrentFishInFight += FishEntity_OnSetCurrentFishInFight; FishCatchState.OnEnter += Disable; } private void OnDisable() { EscapeMenu.OnEscapeMenuChange -= SetEnable; FishEntity.OnSetCurrentFishInFight -= FishEntity_OnSetCurrentFishInFight; FishCatchState.OnEnter -= Disable; } private void FishEntity_OnSetCurrentFishInFight(FishEntity obj) { if (obj == null) { Disable(); } else { Enable(); } } private void EqBreak(object obj) { Disable(); } private void SetEnable(bool value) { isGamePaused = value; } private void Disable() { _CanvasGroup.alpha = 0f; isEnabled = false; } private void Enable() { bool flag = true; if (!Singleton.Instance.SettingsData.IsFishCursorEnabled) { flag = false; } if (flag) { _CanvasGroup.alpha = 1f; isEnabled = true; } } private void Start() { rectTransform = GetComponent(); normalFillColor = sternghtLineProgressImage.color; } private void LateUpdate() { if (!isEnabled || isGamePaused || !FishEntity.CurrentFishInFight || !Camera.main) { return; } float currentTensionReel = HudManager.CurrentTensionReel01; float currentTensionLine = HudManager.CurrentTensionLine01; float currentTensionRod = HudManager.CurrentTensionRod01; float num = (lineStrenght = Mathf.Max(currentTensionReel, currentTensionLine, currentTensionRod)); lineStrenghtEnd = Mathf.MoveTowards(lineStrenght, num, Time.deltaTime); float num2 = Vector3.Angle(worldPoint - Camera.main.transform.position, Camera.main.transform.forward); if (num2 > -90f && num2 < 90f) { Vector2 vector = Camera.main.WorldToViewportPoint(worldPoint); rectTransform.anchorMin = vector; rectTransform.anchorMax = vector; } if (num > 0f) { if (!sternghtLine.activeSelf) { sternghtLine.SetActive(value: true); } sternghtLineProgressImage.fillAmount = lineStrenghtEnd; if (lineStrenghtEnd > 0.9f) { sternghtLineProgressImage.color = maxvalueFillColor; } else { sternghtLineProgressImage.color = normalFillColor; } } else if (sternghtLine.activeSelf) { sternghtLine.SetActive(value: false); } distanceText.text = GameManager.Instance.ConvertLenghtWithUnit(FishEntity.CurrentFishInFight.rod.fishingLine.ropeToHookDistance); PointerDisplayHandler(); if (GameManager.Instance.isDevModeAllowed) { if ((bool)FishEntity.CurrentFishInFight) { fishWeightText.text = FishEntity.CurrentFishInFight.Weight.ToString("F2") + " KG"; fishSpeciesText.text = FishEntity.CurrentFishInFight.Data.Name.ToString(); fightTimeText.text = "Fight Time: " + FishEntity.CurrentFishInFight.FightTime; staminaText.text = "Stamina: " + FishEntity.CurrentFishInFight.Stamina01; _StaminaImage.fillAmount = FishEntity.CurrentFishInFight.Stamina01; } else { fishWeightText.text = ""; fishSpeciesText.text = ""; fightTimeText.text = ""; staminaText.text = ""; } } else { fishWeightText.text = ""; fishSpeciesText.text = ""; fightTimeText.text = ""; staminaText.text = ""; _StaminaContainer.SetActive(value: false); } } private void PointerDisplayHandler() { FPlayer playerMain = RefferenceHelper.GetPlayerMain(); FRod rod = FishEntity.CurrentFishInFight.rod; if ((bool)playerMain && (bool)rod && (bool)rod.currentLure) { if (!rod.currentLure.waterDisplacement.IsInWater) { worldPoint = rod.currentLure.transform.position; } else { worldPoint = new Vector3(rod.currentLure.transform.position.x, rod.currentLure.waterDisplacement.waterHeightPosition, rod.currentLure.transform.position.z); } } if ((bool)playerMain && (bool)rod && (bool)rod.currentHook) { if (!rod.currentHook.waterDisplacement.IsInWater) { worldPoint = rod.currentHook.transform.position; } else { worldPoint = new Vector3(rod.currentHook.transform.position.x, rod.currentHook.waterDisplacement.waterHeightPosition, rod.currentHook.transform.position.z); } } lineStrenght = Mathf.Clamp(rod.fishingLine.CurrentLineTension / rod.fishingLine.lineStrenght, 0f, 1f); } }