升级obi

This commit is contained in:
2026-01-22 22:08:21 +08:00
parent 120b8cda26
commit 20f14322bc
1067 changed files with 149894 additions and 29583 deletions

View File

@@ -1,4 +1,8 @@
using Obi;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Obi;
using UnityEngine;
namespace NBF
@@ -11,39 +15,110 @@ namespace NBF
[SerializeField] private RodLine rodLine;
[SerializeField] private Rope fishingRope;
[SerializeField] private Rope bobberRope;
public Transform LureRoot;
public Transform BobberRoot;
public LureController Lure;
public BobberController Bobber;
public float LineLength = 0.5f;
// 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 rodTip = Rod.Asset.lineConnector;
startParticleAttachment.target = rodTip;
Solver = transform.parent.GetComponent<ObiSolver>();
rodLine.gameObject.SetActive(false);
var rodType = (ItemSubType)Rod.ItemInfo.Config.Type;
if (rodType == ItemSubType.RodSpine || rodType == ItemSubType.RodBolo)
var tipRb = Rod.Asset.LineConnectorRigidbody;
startParticleAttachment.target = tipRb.transform;
// transform.position = Rod.transform.position;
if (isLureConnect)
{
rodLine.gameObject.SetActive(true);
Lure.SetJoint(tipRb);
Lure.EnableCollision(false);
// isFloatingMethodUsed.Value = false;
}
else if (rodType == ItemSubType.RodTele)
else
{
bobberRope.gameObject.SetActive(true);
BobberRoot.gameObject.SetActive(true);
var bobberConfigurableJoint = BobberRoot.GetComponent<ConfigurableJoint>();
bobberConfigurableJoint.connectedBody = Rod.Asset.LineConnectorRigidbody;;
Bobber.SetJoint(tipRb);
Lure.SetJoint(Bobber.rbody);
Lure.gameObject.SetActive(true);
Lure.EnableCollision(false);
Lure.SetKinematic(false);
// isFloatingMethodUsed.Value = true;
// GetComponentInChildren<Buoyancy>().targetSurface =
// MonoBehaviourSingleton<GameWater>.Instance.WaterSurface;
}
LureRoot.gameObject.SetActive(true);
fishingRope.gameObject.SetActive(true);
// SceneSettings.Instance.obiFixedUpdater.solvers.Add(Solver);
// onLureInit.Raise(lure.gameObject);
GetComponentsInChildren<Transform>(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<ObiRopeExtrudedRenderer>().ToList())
{
item.enabled = true;
}
}
public void SetObiRopeStretch(float value)
{
fishingRope.LineLength_OnValueChanged(value);
}
// public void Initialize(Transform rodTarget, Rigidbody tipRb, List<Transform> guides)
// {
//
// }
// protected override void OnInit()
// {
// var rodTip = Rod.Asset.lineConnector;
// startParticleAttachment.target = rodTip;
// Solver = transform.parent.GetComponent<ObiSolver>();
// 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<ConfigurableJoint>();
// bobberConfigurableJoint.connectedBody = Rod.Asset.LineConnectorRigidbody;;
// }
//
// LureRoot.gameObject.SetActive(true);
// fishingRope.gameObject.SetActive(true);
// // SceneSettings.Instance.obiFixedUpdater.solvers.Add(Solver);
// }
}
}