2025-10-27 10:31:01 +08:00
|
|
|
using System.Collections.Generic;
|
2025-10-22 17:34:58 +08:00
|
|
|
using UnityEngine;
|
2025-10-27 10:31:01 +08:00
|
|
|
|
2025-10-22 17:34:58 +08:00
|
|
|
namespace Script.Gameplay.Interface
|
|
|
|
|
{
|
|
|
|
|
public interface ISignalSender
|
|
|
|
|
{
|
2025-10-27 10:31:01 +08:00
|
|
|
public bool IsEnableSendSignal { get; set; }
|
2025-10-22 17:34:58 +08:00
|
|
|
public void SendSignal(bool active, GameObject sender);
|
2025-10-27 10:31:01 +08:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2025-10-22 17:34:58 +08:00
|
|
|
}
|
|
|
|
|
}
|