44 lines
1009 B
C#
44 lines
1009 B
C#
using NBC;
|
|
using NBF;
|
|
using Obi;
|
|
using UnityEngine;
|
|
|
|
public class Rope : MonoBehaviour
|
|
{
|
|
private FRod _rod;
|
|
public bool isFloatRope;
|
|
[SerializeField] private ObiRope rope;
|
|
|
|
[SerializeField] private ObiRopeCursor cursor;
|
|
|
|
[SerializeField] private float percentageElasticity = 0.2f;
|
|
|
|
private float stretchScale;
|
|
|
|
private void Awake()
|
|
{
|
|
rope = GetComponent<ObiRope>();
|
|
}
|
|
|
|
public void Init(FRod rod)
|
|
{
|
|
_rod = rod;
|
|
}
|
|
|
|
public void LineLength_OnValueChanged(float length)
|
|
{
|
|
cursor = cursor == null ? GetComponent<ObiRopeCursor>() : cursor;
|
|
var old = stretchScale;
|
|
stretchScale = Mathf.Clamp(length - percentageElasticity, 0f, float.PositiveInfinity);
|
|
// cursor.ChangeLength(length);
|
|
if (stretchScale != old)
|
|
{
|
|
Log.Info($"rope name={gameObject.name} stretchScale={stretchScale}");
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
rope.stretchingScale = stretchScale;
|
|
}
|
|
} |