提交修改
This commit is contained in:
@@ -11,31 +11,22 @@ namespace NBF
|
||||
Start,
|
||||
Float,
|
||||
Weight,
|
||||
Tail,
|
||||
Virtual,
|
||||
Tail
|
||||
}
|
||||
|
||||
|
||||
private FishingLineSolver _solver;
|
||||
|
||||
[Header("Node")] [SerializeField] private NodeType nodeType = NodeType.Tail;
|
||||
[SerializeField] public Rigidbody body;
|
||||
[SerializeField] private MonoBehaviour interaction;
|
||||
private ConfigurableJoint _joint;
|
||||
|
||||
[Header("Segment To Next Logical Node")] [Min(0f)] [SerializeField]
|
||||
private float segmentLengthToNext = 0.5f;
|
||||
|
||||
[Min(0)] [SerializeField] private int fixedVirtualNodesToNext = 2;
|
||||
|
||||
[Header("Runtime")] [SerializeField] private bool runtimeVirtualNode;
|
||||
[SerializeField] private int runtimeChainIndex = -1;
|
||||
|
||||
[Header("Debug")] [SerializeField] private bool drawDebugGizmo = true;
|
||||
[Min(0.001f)] [SerializeField] private float debugGizmoRadius = 0.03f;
|
||||
[SerializeField] private Color logicalNodeColor = new(0.2f, 0.9f, 0.2f, 1f);
|
||||
[SerializeField] private Color virtualNodeColor = new(1f, 0.6f, 0.1f, 1f);
|
||||
|
||||
|
||||
|
||||
[SerializeField] private List<FishingLineNodeFeature> features = new();
|
||||
[SerializeField] private List<FishingLineNodeMotionFeature> motionFeatures = new();
|
||||
private bool featureCacheReady;
|
||||
@@ -55,40 +46,12 @@ namespace NBF
|
||||
public Rigidbody Body => body;
|
||||
|
||||
public MonoBehaviour Interaction => interaction;
|
||||
|
||||
public float SegmentLengthToNext
|
||||
{
|
||||
get => segmentLengthToNext;
|
||||
set => segmentLengthToNext = Mathf.Max(0f, value);
|
||||
}
|
||||
|
||||
public int FixedVirtualNodesToNext
|
||||
{
|
||||
get => fixedVirtualNodesToNext;
|
||||
set => fixedVirtualNodesToNext = Mathf.Max(0, value);
|
||||
}
|
||||
|
||||
public bool IsRuntimeVirtualNode => runtimeVirtualNode;
|
||||
public ConfigurableJoint Joint => _joint;
|
||||
|
||||
public int RuntimeChainIndex => runtimeChainIndex;
|
||||
|
||||
public Vector3 Position => transform.position;
|
||||
|
||||
public string GetDebugName()
|
||||
{
|
||||
return runtimeVirtualNode
|
||||
? $"V[{runtimeChainIndex}]"
|
||||
: $"{nodeType}[{runtimeChainIndex}]";
|
||||
}
|
||||
|
||||
public string GetDebugSummary()
|
||||
{
|
||||
var bodySummary = body == null
|
||||
? "NoBody"
|
||||
: $"v:{body.linearVelocity.magnitude:F2}";
|
||||
|
||||
return $"{GetDebugName()} pos:{Position} next:{segmentLengthToNext:F2} {bodySummary}";
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
@@ -98,6 +61,7 @@ namespace NBF
|
||||
private void Awake()
|
||||
{
|
||||
_solver = GetComponentInParent<FishingLineSolver>();
|
||||
_joint = GetComponent<ConfigurableJoint>();
|
||||
EnsureFeatureCache();
|
||||
}
|
||||
|
||||
@@ -120,24 +84,8 @@ namespace NBF
|
||||
}
|
||||
|
||||
segmentLengthToNext = Mathf.Max(0f, segmentLengthToNext);
|
||||
fixedVirtualNodesToNext = Mathf.Max(0, fixedVirtualNodesToNext);
|
||||
}
|
||||
|
||||
public void SetRuntimeVirtual(bool isVirtual, int chainIndex)
|
||||
{
|
||||
runtimeVirtualNode = isVirtual;
|
||||
runtimeChainIndex = chainIndex;
|
||||
|
||||
if (isVirtual)
|
||||
{
|
||||
nodeType = NodeType.Virtual;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetVisualPosition(Vector3 position)
|
||||
{
|
||||
transform.position = position;
|
||||
}
|
||||
|
||||
#region Feature
|
||||
|
||||
@@ -206,8 +154,7 @@ namespace NBF
|
||||
t.OnLineBreakRequested();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void EnsureFeatureCache()
|
||||
{
|
||||
@@ -293,13 +240,6 @@ namespace NBF
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (!drawDebugGizmo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Gizmos.color = runtimeVirtualNode ? virtualNodeColor : logicalNodeColor;
|
||||
Gizmos.DrawSphere(transform.position, debugGizmoRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user