feat(Signal):实现信号传输的单向连续传播
This commit is contained in:
@@ -108,6 +108,11 @@ namespace Script.Gameplay.Facility
|
||||
|
||||
public virtual void OnSignalReceived(bool active, GameObject sender)
|
||||
{
|
||||
if (isEnableSendSignal)
|
||||
{
|
||||
SendSignal(active, sender);
|
||||
}
|
||||
|
||||
if (active)
|
||||
{
|
||||
CurrentNeedSignalCount++;
|
||||
@@ -130,20 +135,30 @@ namespace Script.Gameplay.Facility
|
||||
set => isEnableSendSignal = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="active">发送true or false</param>
|
||||
/// <param name="sender">让此物体触发发送的来源者</param>
|
||||
public virtual void SendSignal(bool active, GameObject sender)
|
||||
{
|
||||
if(!IsEnableSendSignal) return;
|
||||
if (ConnectionLines != null)
|
||||
{
|
||||
if (ISignalSender.IsSendToSignalSender(sender))
|
||||
{
|
||||
// 防止信号回传给发送者自己
|
||||
BUGManager.Instance.LogStackOverflowBUG(this.transform);
|
||||
return;
|
||||
}
|
||||
// if (ISignalSender.IsSendToSignalSender(this.gameObject))
|
||||
// {
|
||||
// // 防止信号回传给发送者自己
|
||||
// BUGManager.Instance.LogStackOverflowBUG(this.transform);
|
||||
// return;
|
||||
// }
|
||||
|
||||
foreach (var line in ConnectionLines)
|
||||
{
|
||||
// 排除掉为sender的连接线
|
||||
if (line.gameObject == sender)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
line.OnSignalReceived(active, this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user