提交修改
This commit is contained in:
@@ -311,7 +311,8 @@ namespace NBF
|
||||
|
||||
private List<float> previousWeights = Enumerable.Repeat(0f, 10).ToList();
|
||||
private float bendSmooth = 1f;
|
||||
public float maxRodStrength = 10f;
|
||||
public float maxRodStrength = 1f;
|
||||
|
||||
public float CurrentTension01
|
||||
{
|
||||
get
|
||||
@@ -330,109 +331,54 @@ namespace NBF
|
||||
return Mathf.Clamp01(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void BendControl()
|
||||
{
|
||||
var _ccdik = Asset.CCDIK;
|
||||
|
||||
// Vector3 vector = (FishEntity.CurrentFishInFight
|
||||
// ? FishEntity.CurrentFishInFight.transform.position
|
||||
// : fishingLine.currentLineHandler.LineConnector_1.transform.position);
|
||||
|
||||
var isThrowing = PlayerItem.Owner.State >= PlayerState.Fishing;
|
||||
|
||||
Vector3 vector = Line.Bobber.transform.position;
|
||||
//
|
||||
// float num = Vector3.Distance(_ccdik.solver.bones.Last().transform.position, vector);
|
||||
// float num2 = 0.05f;
|
||||
// if (currentFish)
|
||||
// {
|
||||
// float num3 = Vector3.Angle(base.transform.forward,
|
||||
// (currentFish.transform.position - transform.position).normalized) / 180f;
|
||||
// num2 = Mathf.Clamp(CurrentTension01 * num3, 0.05f, 1f);
|
||||
// }
|
||||
// else if (!isThrowing)
|
||||
// {
|
||||
// float num4 = 0.3f;
|
||||
// if (Lure)
|
||||
// {
|
||||
// num4 *= 0.6f;
|
||||
// }
|
||||
//
|
||||
// if (Bobber)
|
||||
// {
|
||||
// num4 *= 0.8f;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// float num5 = 1.5f;
|
||||
// if (num < num5)
|
||||
// {
|
||||
// num2 = Mathf.Lerp(num2, num4, 1f - num / num5);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// float num6 = 0.3f;
|
||||
// if (isThrowing)
|
||||
// {
|
||||
// num6 = 0.1f;
|
||||
// }
|
||||
// else if (!currentFish)
|
||||
// {
|
||||
// num6 = 0.2f;
|
||||
// }
|
||||
var state = PlayerItem.Owner.State;
|
||||
|
||||
// float target = num2 * num6;
|
||||
|
||||
float target = 0;
|
||||
|
||||
float item = Mathf.MoveTowards(_ccdik.solver.IKPositionWeight, target, Time.deltaTime * bendSmooth);
|
||||
Vector3 vector = Line.Lure.transform.position;
|
||||
|
||||
// 当前物体的朝向与指向 Lure 的方向之间的夹角,在 0(完全对齐)到 1(完全相反)之间的一个比例值
|
||||
float headingAlignment = Vector3.Angle(base.transform.forward,
|
||||
(Line.Lure.transform.position - transform.position).normalized) / 180f;
|
||||
// 经过朝向调制后的有效张力
|
||||
var effectiveTension = Mathf.Clamp(CurrentTension01 * headingAlignment, 0f, 1f);
|
||||
|
||||
float multiple = 0;
|
||||
if (state == PlayerState.Fight)
|
||||
{
|
||||
multiple = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiple = 0.1f;
|
||||
}
|
||||
|
||||
float targetWeight = effectiveTension * multiple;
|
||||
if (targetWeight > 0)
|
||||
{
|
||||
// Debug.Log($"CurrentTension01={CurrentTension01} LinelenghtDiferent={Line.LinelenghtDiferent} Tension={PlayerItem.Tension} num2={effectiveTension} num3={headingAlignment} num6={multiple}");
|
||||
}
|
||||
|
||||
if (state == PlayerState.Prepare)
|
||||
{
|
||||
targetWeight = 0.002f;
|
||||
}
|
||||
|
||||
float item = Mathf.MoveTowards(_ccdik.solver.IKPositionWeight, targetWeight, Time.deltaTime * bendSmooth);
|
||||
previousWeights.RemoveAt(0);
|
||||
previousWeights.Add(item);
|
||||
float num7 = previousWeights.Average();
|
||||
// if ((bool)FishEntity.CurrentFishInFight && FishEntity.CurrentFishInFight.IsCatched)
|
||||
if(currentFish)
|
||||
float averageWeight = previousWeights.Average();
|
||||
if (currentFish)
|
||||
{
|
||||
num7 = Math.Min(num7, 0.01f);
|
||||
averageWeight = Math.Min(averageWeight, 0.01f);
|
||||
}
|
||||
|
||||
_ccdik.solver.SetIKPosition(vector);
|
||||
_ccdik.solver.SetIKPositionWeight(num7);
|
||||
|
||||
// if (!currentFish)
|
||||
// {
|
||||
// //未中鱼
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // Vector3 vector = (FishEntity.CurrentFishInFight
|
||||
// // ? FishEntity.CurrentFishInFight.transform.position
|
||||
// // : fishingLine.currentLineHandler.LineConnector_1.transform.position);
|
||||
//
|
||||
// var ccdik = Asset.CCDIK;
|
||||
//
|
||||
// Vector3 vector = Line.Bobber.transform.position;
|
||||
// // float num = Vector3.Distance(ccdik.solver.bones.Last().transform.position, vector);
|
||||
// float num2 = 0.05f;
|
||||
//
|
||||
// float num6 = 0.3f;
|
||||
// // if (isThrowing)
|
||||
// // {
|
||||
// // num6 = 0.1f;
|
||||
// // }
|
||||
// // else if (!FishEntity.CurrentFishInFight)
|
||||
// // {
|
||||
// // num6 = 0.2f;
|
||||
// // }
|
||||
//
|
||||
// float target = num2 * num6;
|
||||
// float item = Mathf.MoveTowards(ccdik.solver.IKPositionWeight, target, Time.deltaTime * bendSmooth);
|
||||
// previousWeights.RemoveAt(0);
|
||||
// previousWeights.Add(item);
|
||||
// float num7 = previousWeights.Average();
|
||||
//
|
||||
// ccdik.solver.SetIKPosition(vector);
|
||||
// ccdik.solver.SetIKPositionWeight(num7);
|
||||
_ccdik.solver.SetIKPositionWeight(averageWeight);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user