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,35 @@
using System.Collections.Generic;
using UnityEngine;
using Script.Gameplay.Connect;
namespace Script.Gameplay.Facility
{
public class PressurePlateController : BaseFacilityController
{
[SerializeField] private LayerMask detectLayer = ~0; // 检测所有层可在Inspector中指定
[SerializeField] private Vector3 plateSize = new Vector3(1, 0.2f, 1);
[SerializeField] private Vector3 plateOffset = Vector3.up * 0.1f;
private bool lastState = false;
private void FixedUpdate()
{
if (!isEnableInteract) return;
bool hasObject = Physics.CheckBox(transform.position + plateOffset, plateSize * 0.5f, Quaternion.identity, detectLayer);
if (hasObject != lastState)
{
SendSignal(hasObject, this.gameObject);
lastState = hasObject;
}
}
#if UNITY_EDITOR
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireCube(transform.position + plateOffset, plateSize);
}
#endif
}
}