refactor():重构编辑系统,不再需要添加额外的脚本作为可编辑的入口了
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
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 IsEditableActive
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user