This commit is contained in:
2025-12-27 19:30:17 +08:00
parent 028d054705
commit 040a222bd6
58 changed files with 11043 additions and 3352 deletions

View File

@@ -24,57 +24,5 @@ namespace NBF
/// 水线
/// </summary>
public Transform waterline;
// "previewRotationEnabled": 0,
// "previewRotation": {
// "x": 0.0,
// "y": 0.0,
// "z": 0.0
// },
//
// "idleAnimation": {
// "m_FileID": 0,
// "m_PathID": 2768973905596830902
// },
// "swimAnimation": {
// "m_FileID": 0,
// "m_PathID": 7205922588037503814
// },
// "accelerateAnimation": {
// "m_FileID": 0,
// "m_PathID": 5473833867069321029
// },
// "turnLeftAnimation": {
// "m_FileID": 0,
// "m_PathID": 0
// },
// "turnRightAnimation": {
// "m_FileID": 0,
// "m_PathID": 0
// },
// "shake1Animation": {
// "m_FileID": 0,
// "m_PathID": 748440419864685152
// },
// "shake2Animation": {
// "m_FileID": 0,
// "m_PathID": 748440419864685152
// },
// "shake3Animation": {
// "m_FileID": 0,
// "m_PathID": 748440419864685152
// },
// "StuffedAnimation": {
// "m_FileID": 0,
// "m_PathID": 0
// },
// "useRendererBounds": 0,
// "overrideLengthAxis": 0,
// "lengthAxis": 0,
// "applyLengthFactor": 0,
// "lengthFactor": 0.0,
// "useStuffedAnim": 0,
// "stuffedFrameTime": 0.0
}
}

View File

@@ -54,6 +54,8 @@ namespace NBF
public CCDIK CCDIK;
public Rigidbody LineConnectorRigidbody;
private void Awake()
{
CCDIK = GetComponent<CCDIK>();
@@ -61,6 +63,9 @@ namespace NBF
if (!lineConnector && joints.Length > 0)
{
lineConnector = joints[^1];
// LineConnectorRigidbody = lineConnector.gameObject.AddComponent<Rigidbody>();
// LineConnectorRigidbody.isKinematic = true;
// LineConnectorRigidbody.useGravity = false;
}
}

View File

@@ -1,4 +1,5 @@
using KWS;
using Obi;
using UnityEngine;
public class SceneSettings : MonoBehaviour
@@ -17,7 +18,7 @@ public class SceneSettings : MonoBehaviour
public KWS_Ocean Water;
// public ObiLateFixedUpdater obiFixedUpdater;
// public ObiUpdater obiFixedUpdater;
public LineRenderer LineRenderer;

View File

@@ -6,7 +6,9 @@ namespace NBF
{
protected override void OnInit()
{
var baitConnector = Rod.Hook.hookAsset.baitConnector;
transform.position = baitConnector.position;
transform.SetParent(baitConnector);
}
}
}

View File

@@ -6,7 +6,11 @@ namespace NBF
{
protected override void OnInit()
{
transform.position = Rod.lineHandler.LineConnector_1.transform.position;
// Bobber.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
// lineHandler.LineConnector_1.GetComponent<Rigidbody>();
SetParent(Rod.lineHandler.LineConnector_1.transform);
}
}
}

View File

@@ -22,6 +22,15 @@ namespace NBF
ItemInfo = itemInfo;
}
protected void SetParent(Transform parent)
{
transform.SetParent(parent);
transform.localPosition = Vector3.zero;
transform.localEulerAngles = Vector3.zero;
transform.localScale = Vector3.one;
}
protected abstract void OnInit();
}
}

View File

@@ -4,9 +4,23 @@ namespace NBF
{
public class FHook : FGearBase
{
public HookAsset hookAsset;
private void Awake()
{
hookAsset = GetComponent<HookAsset>();
}
protected override void OnInit()
{
transform.position = Rod.lineHandler.LineConnector_2.transform.position;
transform.rotation = Rod.lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
SetParent(Rod.lineHandler.LineConnector_2.transform);
// var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
// var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
// joint.connectedBody = target;
}
}
}

View File

@@ -5,10 +5,14 @@ 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 Transform LureRoot;
public Transform BobberRoot;
public float LineLength = 0.5f;
@@ -20,6 +24,26 @@ namespace NBF
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);
}
}
}

View File

@@ -1,190 +1,190 @@
// using System;
// using NBF;
// using Obi;
// using Unity.VisualScripting;
// using UnityEngine;
//
// public class FLineHandler : MonoBehaviour
// {
// public enum LineType
// {
// None = 0,
// OneSegment = 1,
// TwoSegment = 2,
// ThereSegment = 3
// }
//
// public LineType lineType = LineType.TwoSegment;
//
// public ObiRope obiRopeSegment_1;
//
// public ObiRope obiRopeSegment_2;
//
// public ObiRope obiRopeSegment_3;
//
// public FixedLine LineConnector_0;
//
// public SpringJoint LineConnector_1;
//
// public SpringJoint LineConnector_2;
//
// public SpringJoint LineConnector_3;
//
// // [HideInInspector] public FFishingLine currentRodFishingLineComponent;
//
// // public ObiParticleAttachment toRodConnector;
//
// // public float PhisicsLineOut { get; set; }
//
// public float ObiLineOut;
//
// [HideInInspector] public Rigidbody EndLineRigidbody_0;
//
// [HideInInspector] public Rigidbody EndLineRigidbody_1;
//
// [HideInInspector] public Rigidbody EndLineRigidbody_2;
//
// [HideInInspector] public Rigidbody EndLineRigidbody_3;
//
// // public JointPinchController pinchController;
//
// public FRod Rod;
//
// private Transform waterPlane;
//
//
// // public float ropeToHookDistance;
//
// void Start()
// {
// ObiLineOut = obiRopeSegment_1.stretchingScale;
// if ((bool)LineConnector_0)
// {
// EndLineRigidbody_0 = LineConnector_0.GetComponent<Rigidbody>();
// }
//
// if ((bool)LineConnector_1)
// {
// EndLineRigidbody_1 = LineConnector_1.GetComponent<Rigidbody>();
// }
//
// if ((bool)LineConnector_2)
// {
// EndLineRigidbody_2 = LineConnector_2.GetComponent<Rigidbody>();
// // var fixedJoint = LineConnector_2.GetComponent<FixedJoint>();
// // pinchController = LineConnector_2.gameObject.AddComponent<JointPinchController>();
// }
//
// if ((bool)LineConnector_3)
// {
// EndLineRigidbody_3 = LineConnector_3.GetComponent<Rigidbody>();
// }
//
// waterPlane = GameObject.FindGameObjectWithTag("Water").transform;
//
// Debug.LogError($"rope.restLength={obiRopeSegment_1.restLength} LineConnector_1={LineConnector_1.maxDistance}");
// }
//
//
// void Update()
// {
// if (!Rod) return;
//
//
// // ropeToHookDistance = Vector3.Distance(toRodConnector.transform.position, LineConnector_1.transform.position);
//
// ObiLineOut = 0.1f + Rod.lineLength;
// float target = (0f - Mathf.Clamp(Rod.linelenghtDiferent, -1f, 0f)) * 0.1f;
// if (Rod.linelenghtDiferent >= 0f)
// {
// obiRopeSegment_1.stretchCompliance = Mathf.MoveTowards(obiRopeSegment_1.stretchCompliance, target,
// Time.smoothDeltaTime * (1f * Rod.linelenghtDiferent));
// }
// else
// {
// obiRopeSegment_1.stretchCompliance = Mathf.MoveTowards(obiRopeSegment_1.stretchCompliance, target,
// Time.smoothDeltaTime * 0.1f);
// }
//
// if (Rod.lineLength == 0f)
// {
// obiRopeSegment_1.stretchCompliance = 0f;
// }
//
// if ((bool)obiRopeSegment_2)
// {
// if (!Rod.currentFish)
// {
// obiRopeSegment_2.stretchCompliance = obiRopeSegment_2.stretchingScale * 0.004f;
// }
// else
// {
// obiRopeSegment_2.stretchCompliance = 0f;
// }
//
// //TODO:TEST
// obiRopeSegment_2.stretchingScale = 0.13F;
// }
//
// obiRopeSegment_1.stretchingScale = ObiLineOut;
// obiRopeSegment_1.stretchingScale = 1;
// LineConnector_1.maxDistance = 0.1f + Rod.lineLength;
// if (Input.GetKey(KeyCode.E))
// {
// // var speed = 1;
// // obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// // Debug.Log(obiRopeSegment_1.restLength);
// }
//
// // var addLength = LineConnector_1.maxDistance - obiRopeSegment_1.restLength;
// // if (Mathf.Abs(addLength) > 0.001f)
// // {
// // obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// // }
//
// // if (!Mathf.Approximately(LineConnector_1.maxDistance, obiRopeSegment_1.restLength))
// // {
// // obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// // }
//
// // obiRopeCursor_1.pos
//
//
// // LineConnector_1.minDistance = LineConnector_1.maxDistance;
// }
//
// public void SetSegmentTwoLenght(float lenght)
// {
// LineConnector_2.maxDistance = lenght;
// // obiRopeCursor_2.ChangeLength(lenght);
// // LineConnector_2.minDistance = LineConnector_2.maxDistance;
// }
//
// private void FixedUpdate()
// {
// // BindRod();
// LineWaterDisplacement();
// }
//
// private void BindRod()
// {
// if (!Rod || !Rod.Asset) return;
// LineConnector_0.transform.position = Rod.Asset.lineConnector.position;
// }
//
// private void LineWaterDisplacement()
// {
// if (!waterPlane)
// {
// return;
// }
//
// for (int i = 0; i < obiRopeSegment_1.activeParticleCount; i++)
// {
// if (obiRopeSegment_1.GetParticlePosition(i).y < waterPlane.position.y)
// {
// // obiRopeSegment_1.AddForceParticle(i, Vector3.up * 10f, ForceMode.Acceleration);
// }
// }
// }
// }
using System;
using NBF;
using Obi;
using Unity.VisualScripting;
using UnityEngine;
public class FLineHandler : MonoBehaviour
{
public enum LineType
{
None = 0,
OneSegment = 1,
TwoSegment = 2,
ThereSegment = 3
}
public LineType lineType = LineType.TwoSegment;
public ObiRope obiRopeSegment_1;
public ObiRope obiRopeSegment_2;
public ObiRope obiRopeSegment_3;
public FixedLine LineConnector_0;
public SpringJoint LineConnector_1;
public SpringJoint LineConnector_2;
public SpringJoint LineConnector_3;
// [HideInInspector] public FFishingLine currentRodFishingLineComponent;
// public ObiParticleAttachment toRodConnector;
// public float PhisicsLineOut { get; set; }
public float ObiLineOut;
[HideInInspector] public Rigidbody EndLineRigidbody_0;
[HideInInspector] public Rigidbody EndLineRigidbody_1;
[HideInInspector] public Rigidbody EndLineRigidbody_2;
[HideInInspector] public Rigidbody EndLineRigidbody_3;
// public JointPinchController pinchController;
public FRod Rod;
private Transform waterPlane;
// public float ropeToHookDistance;
void Start()
{
ObiLineOut = obiRopeSegment_1.stretchingScale;
if ((bool)LineConnector_0)
{
EndLineRigidbody_0 = LineConnector_0.GetComponent<Rigidbody>();
}
if ((bool)LineConnector_1)
{
EndLineRigidbody_1 = LineConnector_1.GetComponent<Rigidbody>();
}
if ((bool)LineConnector_2)
{
EndLineRigidbody_2 = LineConnector_2.GetComponent<Rigidbody>();
// var fixedJoint = LineConnector_2.GetComponent<FixedJoint>();
// pinchController = LineConnector_2.gameObject.AddComponent<JointPinchController>();
}
if ((bool)LineConnector_3)
{
EndLineRigidbody_3 = LineConnector_3.GetComponent<Rigidbody>();
}
waterPlane = GameObject.FindGameObjectWithTag("Water").transform;
Debug.LogError($"rope.restLength={obiRopeSegment_1.restLength} LineConnector_1={LineConnector_1.maxDistance}");
}
void Update()
{
if (!Rod) return;
// ropeToHookDistance = Vector3.Distance(toRodConnector.transform.position, LineConnector_1.transform.position);
ObiLineOut = 0.1f + Rod.lineLength;
float target = (0f - Mathf.Clamp(Rod.linelenghtDiferent, -1f, 0f)) * 0.1f;
if (Rod.linelenghtDiferent >= 0f)
{
obiRopeSegment_1.stretchCompliance = Mathf.MoveTowards(obiRopeSegment_1.stretchCompliance, target,
Time.smoothDeltaTime * (1f * Rod.linelenghtDiferent));
}
else
{
obiRopeSegment_1.stretchCompliance = Mathf.MoveTowards(obiRopeSegment_1.stretchCompliance, target,
Time.smoothDeltaTime * 0.1f);
}
if (Rod.lineLength == 0f)
{
obiRopeSegment_1.stretchCompliance = 0f;
}
if ((bool)obiRopeSegment_2)
{
if (!Rod.currentFish)
{
obiRopeSegment_2.stretchCompliance = obiRopeSegment_2.stretchingScale * 0.004f;
}
else
{
obiRopeSegment_2.stretchCompliance = 0f;
}
//TODO:TEST
obiRopeSegment_2.stretchingScale = 0.13F;
}
obiRopeSegment_1.stretchingScale = ObiLineOut;
obiRopeSegment_1.stretchingScale = 1;
LineConnector_1.maxDistance = 0.1f + Rod.lineLength;
if (Input.GetKey(KeyCode.E))
{
// var speed = 1;
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// Debug.Log(obiRopeSegment_1.restLength);
}
// var addLength = LineConnector_1.maxDistance - obiRopeSegment_1.restLength;
// if (Mathf.Abs(addLength) > 0.001f)
// {
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// }
// if (!Mathf.Approximately(LineConnector_1.maxDistance, obiRopeSegment_1.restLength))
// {
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// }
// obiRopeCursor_1.pos
// LineConnector_1.minDistance = LineConnector_1.maxDistance;
}
public void SetSegmentTwoLenght(float lenght)
{
LineConnector_2.maxDistance = lenght;
// obiRopeCursor_2.ChangeLength(lenght);
// LineConnector_2.minDistance = LineConnector_2.maxDistance;
}
private void FixedUpdate()
{
// BindRod();
LineWaterDisplacement();
}
private void BindRod()
{
if (!Rod || !Rod.Asset) return;
LineConnector_0.transform.position = Rod.Asset.lineConnector.position;
}
private void LineWaterDisplacement()
{
if (!waterPlane)
{
return;
}
for (int i = 0; i < obiRopeSegment_1.activeParticleCount; i++)
{
if (obiRopeSegment_1.GetParticlePosition(i).y < waterPlane.position.y)
{
// obiRopeSegment_1.AddForceParticle(i, Vector3.up * 10f, ForceMode.Acceleration);
}
}
}
}

View File

@@ -6,7 +6,12 @@ namespace NBF
{
protected override void OnInit()
{
transform.position = Rod.lineHandler.LineConnector_1.transform.position;
// Lure.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
// lineHandler.LineConnector_1.GetComponent<Rigidbody>();
// LureHookWaterDisplacement = Lure.GetComponent<FWaterDisplacement>();
SetParent(Rod.lineHandler.LineConnector_1.transform);
}
}
}

View File

@@ -28,9 +28,14 @@ namespace NBF
public FBait Bait;
public FLure Lure;
public FWeight Weight;
public FLine Line;
// public FLine Line;
/// <summary>
/// 鱼线处理器
/// </summary>
public FLineHandler lineHandler;
public Transform GearRoot;
// public FWaterDisplacement LureHookWaterDisplacement;
@@ -81,7 +86,7 @@ namespace NBF
ItemInfo lineItemInfo = null;
// CreateFishingHandler();
CreateFishingHandler();
// children.Sort();
foreach (var child in children)
@@ -141,40 +146,26 @@ namespace NBF
Reel.Init(player, this);
}
// if (Bobber)
// {
// Bobber.Init(Player, this);
// Bobber.transform.position = lineHandler.LineConnector_1.transform.position;
// Bobber.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
// lineHandler.LineConnector_1.GetComponent<Rigidbody>();
// }
//
// if (Hook)
// {
// Hook.Init(Player, this);
// Hook.transform.position = lineHandler.LineConnector_2.transform.position;
// Hook.transform.rotation = lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
// var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
// var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
// joint.connectedBody = target;
// // LureHookWaterDisplacement = Hook.GetComponent<FWaterDisplacement>();
// }
//
// if (Bait)
// {
// Bait.Init(Player, this);
// Bait.transform.position = Hook.hookAsset.baitConnector.position;
// Bait.transform.SetParent(Hook.hookAsset.baitConnector);
// }
//
// if (Lure)
// {
// Lure.Init(Player, this);
// Lure.transform.position = lineHandler.LineConnector_1.transform.position;
// Lure.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
// lineHandler.LineConnector_1.GetComponent<Rigidbody>();
// // LureHookWaterDisplacement = Lure.GetComponent<FWaterDisplacement>();
// }
if (Bobber)
{
Bobber.Init(Player, this);
}
if (Hook)
{
Hook.Init(Player, this);
// LureHookWaterDisplacement = Hook.GetComponent<FWaterDisplacement>();
}
if (Bait)
{
Bait.Init(Player, this);
}
if (Lure)
{
Lure.Init(Player, this);
}
if (Weight)
{
@@ -190,6 +181,50 @@ namespace NBF
}
public void CreateFishingHandler()
{
if (lineHandler == null)
{
Debug.LogError("创建钓组=====");
var rodType = (ItemSubType)ItemInfo.Config.Type;
if (rodType == ItemSubType.RodTele)
{
CreateObiFishingLine(0);
}
else if (rodType == ItemSubType.RodSpine || rodType == ItemSubType.RodBolo)
{
CreateObiFishingLine(1);
}
}
}
public void CreateObiFishingLine(int currentLineTypeIndex)
{
// if ((bool)Owner.Gears.Reel && !currentLineHandler)
if (!lineHandler)
{
var indexNames = new[] { "FFishingLine_0", "FFishingLine_1" };
var path =
$"Assets/ResRaw/Prefabs/{indexNames[currentLineTypeIndex]}.prefab"; //$"GameItemsPrefabs/Lines/{indexNames[currentLineTypeIndex]}";
var prefab = Assets.Load<GameObject>(path);
// var toRodConnector = rodAsset.lineConnector.GetComponent<Rigidbody>();
GameObject obj = Instantiate(prefab, GearRoot.position, Quaternion.identity, GearRoot);
lineHandler = obj.GetComponent<FLineHandler>();
// lineHandler.transform.SetParent(toRodConnector.transform);
lineHandler.transform.position = Asset.lineConnector.position;
lineHandler.LineConnector_0.target = Asset.lineConnector; //.GetComponent<Rigidbody>();
// lineHandler.toRodConnector.target = rodAsset.lineConnector;
lineHandler.Rod = this;
// var obiSolver = lineHandler.GetComponent<ObiSolver>();
// SceneSettings.Instance.obiFixedUpdater.solvers.Add(obiSolver);
}
}
public void SetRing(RodRingAsset ringAsset)
{
if (Asset.rings == null || Asset.rings.Length < 1) return;