Files
2025TapTapGameJam/Assets/Script/Gameplay/Facility/LeverInteractController.cs

97 lines
2.3 KiB
C#

using System.Collections.Generic;
using UnityEngine;
using Script.Gameplay.Interface;
using Script.Gameplay.Connect;
namespace Script.Gameplay.Facility
{
public class LeverInteractController : MonoBehaviour, IInteractable, IEditableComponent, IConnectable, ISignalSender
{
#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);
// 可选:拉杆动画
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 GameObject GetGameObject()
{
return gameObject;
}
public string GetConnectableName() => gameObject.name;
public List<ConnectionLine> ConnectionLines { get; set; }= new List<ConnectionLine>();
public void SignalActive(bool active, GameObject sender)
{
//
}
public void SendSignal(bool active)
{
if (ConnectionLines != null)
{
foreach (var line in ConnectionLines)
{
line.SignalActive(active, this.gameObject);
}
}
}
#endregion
}
}