Files
2025TapTapGameJam/Assets/Script/Gameplay/Interface/ISignalSender.cs

41 lines
1.5 KiB
C#

using System.Collections.Generic;
using UnityEngine;
namespace Script.Gameplay.Interface
{
public interface ISignalSender
{
public bool IsEnableSendSignal { get; set; }
public void SendSignal(bool active, GameObject sender);
public static bool IsSendToSignalSender(GameObject sender)
{
IConnectable connectable = sender.GetComponent<IConnectable>();
// 从连接线中查找是否有连接到ISignalSender的对象
if (connectable != null)
{
foreach (var connectionLine in connectable.ConnectionLines)
{
if (connectionLine != null)
{
GameObject targetObject = null;
if (connectionLine.PointA.GetGameObject() == sender)
{
targetObject = connectionLine.PointB.GetGameObject();
}
else if (connectionLine.PointB.GetGameObject() == sender)
{
targetObject = connectionLine.PointA.GetGameObject();
}
if (targetObject != null && targetObject.GetComponent<ISignalSender>().IsEnableSendSignal)
{
return true;
}
}
}
}
return false;
}
}
}