代码提交
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认物理组件
|
||||
/// </summary>
|
||||
public class FishingDefaultPhysicsFeature : FishingLineNodeMotionFeature
|
||||
{
|
||||
[Header("Physics")] [SerializeField] private bool useGravity = true;
|
||||
|
||||
protected override int DefaultPriority => 0;
|
||||
|
||||
public override bool IsSupportedNode(FishingLineNode node)
|
||||
{
|
||||
return node != null && node.Type != FishingLineNode.NodeType.Start;
|
||||
}
|
||||
|
||||
public override bool CanControl()
|
||||
{
|
||||
return Node != null && Node.Body != null && IsSupportedNode(Node);
|
||||
}
|
||||
|
||||
public override void OnMotionActivated()
|
||||
{
|
||||
ApplyPhysicsState();
|
||||
}
|
||||
|
||||
public override void TickMotion(float deltaTime)
|
||||
{
|
||||
ApplyPhysicsState();
|
||||
}
|
||||
|
||||
private void ApplyPhysicsState()
|
||||
{
|
||||
if (Node == null || Node.Body == null || !IsSupportedNode(Node))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Node.Body.useGravity = useGravity;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user