using System; using System.Collections.Generic; using System.Linq; using Obi; using Obvious.Soap; using UnityEngine; public class FishingLine : MonoBehaviour { [SerializeField] private ObiParticleAttachment startParticleAttachment; [SerializeField] private bool isLureConnect; [SerializeField] private Lure lure; [SerializeField] private BobberController bobberController; [SerializeField] private ScriptableEventGameObject onLureInit; [SerializeField] private RodLine rodLine; [SerializeField] private BoolVariable isFloatingMethodUsed; [SerializeField] private Rope fishingRope; public float LineLength = 0.5f; private float _groundSetting = 0.5f; private float _LineOnSpool = 100f; private float _LineThickness = 0.0007f; public event Action OnLinePulled; public void SetUnrolledLineValue(float lentgth) { LineLength = lentgth; LineLength = Mathf.Clamp(LineLength, _groundSetting, _LineOnSpool); if (LineLength == _groundSetting) { this.OnLinePulled?.Invoke(); } } public void EnableLineRenderers() { foreach (ObiRopeExtrudedRenderer item in GetComponentsInChildren().ToList()) { item.enabled = true; } } public void SetObiRopeStretch(float value) { fishingRope.LineLength_OnValueChanged(value); } public void Initialize(Transform rodTarget, Rigidbody tipRb, List guides) { startParticleAttachment.target = tipRb.transform; base.transform.position = rodTarget.position; if (isLureConnect) { lure.SetJoint(tipRb); lure.EnableCollision(enable: false); isFloatingMethodUsed.Value = false; } else { bobberController.SetJoint(tipRb); bobberController.gameObject.SetActive(value: true); lure.gameObject.SetActive(value: true); lure.EnableCollision(enable: false); isFloatingMethodUsed.Value = true; GetComponentInChildren().targetSurface = MonoBehaviourSingleton.Instance.WaterSurface; } onLureInit.Raise(lure.gameObject); GetComponentsInChildren(includeInactive: true).ToList().ForEach(delegate(Transform i) { i.gameObject.SetActive(value: true); }); rodLine.GenerateLineRendererRope(guides.ToArray(), _LineThickness); } }