using UnityEngine; using Script.Gameplay.Interface; using Script.Gameplay.Connect; namespace Script.Gameplay.Facility { public class LeverInteractController : MonoBehaviour, IInteractable, IEditableComponent, IConnectable { #region Interactable public bool Interactable = true; private bool isPulled = false; public string GetInteractPrompt() { return "按F拉动拉杆"; } public void Interact(GameObject interactor) { if (!Interactable) return; isPulled = !isPulled; SendSignal(isPulled, interactor); // 可选:拉杆动画 Debug.Log(isPulled ? "Lever pulled down" : "Lever reset"); } public void OnGazeEnter(GameObject editor) { // 可选:高亮拉杆 } public void OnGazeExit(GameObject editor) { // 可选:取消高亮 } #endregion #region EditableComponent [SerializeField] private bool isActive = true; public bool IsActive { get => isActive; set { isActive = value; Interactable = isActive; } } public string ComponentName { get; set; } = "Lever"; public LockLevel LockLevel => LockLevel.Red; #endregion #region Connectable public void OnGazeEnter() { } public void OnGazeExit() { } public Vector3 GetPosition() => transform.position; public string GetConnectableName() => gameObject.name; public ConnectionLine OutputConnectionLine { get; set; } public ConnectionLine InputConnectionLine { get; set; } public bool IsConnectedOutput { get; set; } public bool IsConnectedInput { get; set; } public void ReceiveSignal(bool active, GameObject sender) { // 拉杆通常不响应输入信号 } public void SendSignal(bool active, GameObject sender) { if (OutputConnectionLine != null) { OutputConnectionLine.ReceiveSignal(active); } } #endregion } }