using UnityEngine; using AibisDream.FixSystem; namespace AibisDream { public class ExpressionSocket : MonoBehaviour, ISocket { private int _subSystemIndex; // 所属表达子模块的索引 private int _socketIndex; // 插槽在子模块中的索引 private bool _isOccupied; private ExpressionCableSystem _cableSystem; public void Initialize(int subSystemIndex, int socketIndex) { _subSystemIndex = subSystemIndex; _socketIndex = socketIndex; _cableSystem = GetComponentInParent(); } public void PlugIn() { if (!_isOccupied) { _isOccupied = true; _cableSystem.OnPlugInserted(_subSystemIndex, _socketIndex); } } public void PlugOut() { if (_isOccupied) { _isOccupied = false; _cableSystem.OnPlugRemoved(_subSystemIndex, _socketIndex); } } public Vector3 GetSocketPos() { return transform.position; } public bool IsAvailable() { return !_isOccupied; } } }