refactor(Facility): 使用继承让所有机关都拥有了独自的 可交互 可编辑 可连接设定。大面积重构

This commit is contained in:
2025-10-22 17:34:58 +08:00
parent 3cdd41ea49
commit 3a0b202325
61 changed files with 1516 additions and 889 deletions

View File

@@ -0,0 +1,50 @@
using System.Collections.Generic;
using Script.Gameplay.Connect;
using Script.Gameplay.Interface;
using UnityEngine;
namespace Script.Gameplay.Facility
{
public class ConsoleController : BaseFacilityController
{
[SerializeField] private List<MonoBehaviour> controlTarget;
[SerializeField] private bool IsBeActive = false;
private List<ISignalReceiver> controlTargetSignalReceiver = new List<ISignalReceiver>();
private bool lastSendSignal = false;
void Awake()
{
foreach (var target in controlTarget)
{
if (target is ISignalReceiver receiver)
{
controlTargetSignalReceiver.Add(receiver);
}
else
{
if(target != null)
Debug.Log(target.name + " is not a supported control target");
}
}
}
public override void OnSignalReceived(bool active, GameObject sender)
{
base.OnSignalReceived(active, sender);
IsBeActive = active;
}
public override void Interact(GameObject interactor)
{
if (IsBeActive && controlTargetSignalReceiver != null)
{
var signal = !lastSendSignal;
foreach (var receiver in controlTargetSignalReceiver)
{
receiver.OnSignalReceived(signal, this.gameObject);
}
lastSendSignal = signal;
}
}
}
}