refactor: 优化 BodyModule 身体模块系统
Made-with: Cursor
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using AibisDream.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using AibisDream.Kit;
|
||||
|
||||
@@ -24,14 +23,10 @@ namespace AibisDream.FixSystem
|
||||
|
||||
#region 系统状态
|
||||
|
||||
public bool isInDialog;
|
||||
public bool isActive = true;
|
||||
public bool isCableRetracted = true; // 线缆是否收起
|
||||
|
||||
[SerializeField] private Transform retractedPos; // 收起位置
|
||||
[SerializeField] private float dropDownDuration = 0.5f; // 放下动画时长
|
||||
[SerializeField] private float swingDuration = 0.3f; // 摆动动画时长
|
||||
[SerializeField] private float swingAngle = 15f; // 摆动角度
|
||||
|
||||
[HideInInspector] public ISocket curSocket;
|
||||
[HideInInspector] public BodyModule curBodyModule;
|
||||
@@ -46,17 +41,6 @@ namespace AibisDream.FixSystem
|
||||
LoadCableState();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
EnumEventSystem.Global.Register(InteractionEventEnum.DialogEnd, HandleDialogueComplete);
|
||||
EnumEventSystem.Global.Register(InteractionEventEnum.DialogStart, HandleDialogueStart);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EnumEventSystem.Global.UnRegister(InteractionEventEnum.DialogEnd, HandleDialogueComplete);
|
||||
EnumEventSystem.Global.UnRegister(InteractionEventEnum.DialogStart, HandleDialogueStart);
|
||||
}
|
||||
|
||||
private void InitComponentRefs()
|
||||
{
|
||||
@@ -140,16 +124,6 @@ namespace AibisDream.FixSystem
|
||||
|
||||
#region 系统可用状态
|
||||
|
||||
private void HandleDialogueStart()
|
||||
{
|
||||
isInDialog = true;
|
||||
}
|
||||
|
||||
private void HandleDialogueComplete()
|
||||
{
|
||||
isInDialog = false;
|
||||
}
|
||||
|
||||
public void Disable_plugInput()
|
||||
{
|
||||
isActive = false;
|
||||
@@ -160,15 +134,6 @@ namespace AibisDream.FixSystem
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询插线系统是否可用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsPlugAvailable()
|
||||
{
|
||||
return isActive && !isInDialog;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void PullUpCable()
|
||||
@@ -177,7 +142,7 @@ namespace AibisDream.FixSystem
|
||||
//禁用plug交互
|
||||
Disable_plugInput();
|
||||
ResetPlug();
|
||||
PlugRef.SetPhysicCableActive(false);
|
||||
// PlugRef.SetPhysicCableActive(false);
|
||||
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName =
|
||||
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
|
||||
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
|
||||
@@ -192,12 +157,11 @@ namespace AibisDream.FixSystem
|
||||
public void DropDownCable()
|
||||
{
|
||||
if (!isCableRetracted) return;
|
||||
Debug.Log("DorpDown");
|
||||
PlugRef.PullUpSocket();
|
||||
CableReelRef.ResetRotation();
|
||||
PlugRef.transform.DOMove(PlugRef.GetStartPos(), 0.1f).OnComplete(() =>
|
||||
{
|
||||
PlugRef.SwitchToPhysicCableState();
|
||||
// PlugRef.SwitchToPhysicCableState();
|
||||
isCableRetracted = false;
|
||||
SaveCableState();
|
||||
// 添加一个短暂的延迟来确保状态正确设置
|
||||
@@ -221,7 +185,6 @@ namespace AibisDream.FixSystem
|
||||
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
|
||||
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
|
||||
isCableRetracted = true;
|
||||
//SaveCableState();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user