fix(fix-system): 优化线缆收起的复位与拉回表现

This commit is contained in:
2026-07-26 13:03:39 +08:00
parent 56eab46b0c
commit 3ed8999bbb
@@ -7,6 +7,10 @@ namespace AibisDream.FixSystem
public class CableSystem : MonoBehaviour
{
private const string CableRetractedKey = "$global.cableRetracted";
private const float RetractResetDuration = 0.06f;
private const float PullUpDuration = 0.1f;
private DG.Tweening.Sequence _pullUpSequence;
#region
@@ -138,16 +142,35 @@ namespace AibisDream.FixSystem
public void PullUpCable()
{
if (isCableRetracted) return;
if (isCableRetracted || _pullUpSequence != null) return;
//禁用plug交互
Disable_plugInput();
ResetPlug();
// PlugRef.SetPhysicCableActive(false);
// 强制收线不能复用 ResetPlugReturnToStartPosition 会启动线缆的自动回收,
// 紧接着再 DOMove 会让两个流程争抢插头位置,插在插孔上时尤其像直接平移消失。
PlugRef.PullUpSocket();
BodyModuleSystem.CloseModuleSlots(null);
AudioManager.Instance.PlaySfx("event:/ActionFB/mods_close");
AudioManager.Instance.PlaySfx("event:/FollowInput/plugdrop");
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName =
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
PlugRef.transform.DOMove(retractedPos.position, 0.1f).OnComplete(() =>
_pullUpSequence?.Kill();
PlugRef.transform.DOKill(false);
_pullUpSequence = DOTween.Sequence()
// 先快速从插孔复位,消除“跨场景直线吸走”的观感。
.Append(PlugRef.transform.DOMove(PlugRef.GetStartPos(), RetractResetDuration)
.SetEase(Ease.OutCubic))
// 再由线盘向上收走。
.Append(PlugRef.transform.DOMove(retractedPos.position, PullUpDuration)
.SetEase(Ease.InCubic))
.Join(PlugRef.transform.DORotateQuaternion(retractedPos.rotation, PullUpDuration)
.SetEase(Ease.InCubic))
.OnComplete(() =>
{
_pullUpSequence = null;
PhysicCableRef.GetComponent<LineRenderer>().enabled = false;
isCableRetracted = true;
SaveCableState();
@@ -156,7 +179,9 @@ namespace AibisDream.FixSystem
public void DropDownCable()
{
if (!isCableRetracted) return;
if (!isCableRetracted && _pullUpSequence == null) return;
_pullUpSequence?.Kill();
_pullUpSequence = null;
PlugRef.PullUpSocket();
CableReelRef.ResetRotation();
PlugRef.transform.DOMove(PlugRef.GetStartPos(), 0.1f).OnComplete(() =>
@@ -174,6 +199,9 @@ namespace AibisDream.FixSystem
public void SetRetractCable()
{
_pullUpSequence?.Kill();
_pullUpSequence = null;
// 禁用物理线缆和普通线缆
PhysicCableRef.GetComponent<LineRenderer>().enabled = false;
CableRef.HideCable();