using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Obi; using UnityEngine; namespace NBF { public class FLine : FGearBase { public ObiSolver Solver; [SerializeField] private ObiParticleAttachment startParticleAttachment; [SerializeField] private bool isLureConnect; [SerializeField] private RodLine rodLine; [SerializeField] private Rope fishingRope; [SerializeField] private Rope bobberRope; public LureController Lure; public BobberController Bobber; // public float LineLength = 0.5f; private float _groundSetting = 0.5f; private float _LineOnSpool = 100f; private float _LineThickness = 0.0007f; // public event Action OnLinePulled; protected override void OnInit() { var tipRb = Rod.Asset.LineConnectorRigidbody; startParticleAttachment.target = tipRb.transform; // transform.position = Rod.transform.position; if (isLureConnect) { Lure.SetJoint(tipRb); Lure.EnableCollision(false); // isFloatingMethodUsed.Value = false; } else { Bobber.SetJoint(tipRb); Lure.SetJoint(Bobber.rbody); Lure.gameObject.SetActive(true); Lure.EnableCollision(false); Lure.SetKinematic(false); // isFloatingMethodUsed.Value = true; // GetComponentInChildren().targetSurface = // MonoBehaviourSingleton.Instance.WaterSurface; } // onLureInit.Raise(lure.gameObject); GetComponentsInChildren(includeInactive: true).ToList().ForEach(delegate(Transform i) { i.gameObject.SetActive(true); }); StartCoroutine(test()); fishingRope.Init(Rod); bobberRope.Init(Rod); // rodLine.GenerateLineRendererRope(guides.ToArray(), _LineThickness); } private IEnumerator test() { yield return 1; Lure.gameObject.SetActive(false); Lure.gameObject.SetActive(true); } // 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) // { // // } // protected override void OnInit() // { // var rodTip = Rod.Asset.lineConnector; // startParticleAttachment.target = rodTip; // Solver = transform.parent.GetComponent(); // rodLine.gameObject.SetActive(false); // var rodType = (ItemSubType)Rod.ItemInfo.Config.Type; // if (rodType == ItemSubType.RodSpine || rodType == ItemSubType.RodBolo) // { // rodLine.gameObject.SetActive(true); // } // else if (rodType == ItemSubType.RodTele) // { // bobberRope.gameObject.SetActive(true); // BobberRoot.gameObject.SetActive(true); // var bobberConfigurableJoint = BobberRoot.GetComponent(); // bobberConfigurableJoint.connectedBody = Rod.Asset.LineConnectorRigidbody;; // } // // LureRoot.gameObject.SetActive(true); // fishingRope.gameObject.SetActive(true); // // SceneSettings.Instance.obiFixedUpdater.solvers.Add(Solver); // } } }