feat(Cycle):实现循环提前检测,修复交互提示消失,按键绑定的事件在重启的时候没能正确,触发循环的提前检测有错误

This commit is contained in:
2025-10-27 10:31:01 +08:00
parent e8b9f47067
commit 9646483fa6
36 changed files with 6743 additions and 5221 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Script.Gameplay.Connect;
using Script.Gameplay.Global;
using Script.Gameplay.Interface;
using UnityEngine;
@@ -15,6 +16,7 @@ namespace Script.Gameplay.Facility
[SerializeField] protected int needSignalCount = 1;
[SerializeField] protected int currentSignalCount = 0;
[SerializeField] protected string componentName;
[SerializeField] protected bool isEnableSendSignal = false;
public virtual bool IsEnableInteract
{
@@ -44,12 +46,13 @@ namespace Script.Gameplay.Facility
get => isEnableConnect;
set => isEnableConnect = value;
}
public virtual int NeedSignalCount
{
get => needSignalCount;
set => needSignalCount = value;
}
public virtual int CurrentNeedSignalCount
{
get => currentSignalCount;
@@ -111,7 +114,7 @@ namespace Script.Gameplay.Facility
}
else
{
CurrentNeedSignalCount = Mathf.Max(0, CurrentNeedSignalCount- 1);
CurrentNeedSignalCount = Mathf.Max(0, CurrentNeedSignalCount - 1);
}
if (CurrentNeedSignalCount < NeedSignalCount)
@@ -121,10 +124,24 @@ namespace Script.Gameplay.Facility
// Implement signal received logic here
}
public bool IsEnableSendSignal
{
get => isEnableSendSignal;
set => isEnableSendSignal = value;
}
public virtual void SendSignal(bool active, GameObject sender)
{
if(!IsEnableSendSignal) return;
if (ConnectionLines != null)
{
if (ISignalSender.IsSendToSignalSender(sender))
{
// 防止信号回传给发送者自己
BUGManager.Instance.LogStackOverflowBUG(this.transform);
return;
}
foreach (var line in ConnectionLines)
{
line.OnSignalReceived(active, this.gameObject);

View File

@@ -17,6 +17,17 @@ namespace Script.Gameplay.Facility
public override void Interact(GameObject interactor)
{
if (!IsEnableInteract) return;
PullLever();
}
public override void OnSignalReceived(bool active, GameObject sender)
{
base.OnSignalReceived(active, sender);
PullLever();
}
private void PullLever()
{
isPulled = !isPulled;
SendSignal(isPulled, this.gameObject);
// 可选:拉杆动画
@@ -30,17 +41,7 @@ namespace Script.Gameplay.Facility
// 旋转拉杆回到初始位置
transform.rotation = Quaternion.Euler(0f, 0f, 0f);
}
//Debug.Log(isPulled ? "Lever pulled down" : "Lever reset");
}
public override void OnGazeEnter(GameObject go)
{
// 可选:高亮拉杆
}
public override void OnGazeExit(GameObject go)
{
// 可选:取消高亮
}
}
}