24 lines
695 B
C#
24 lines
695 B
C#
using UnityEngine;
|
||
|
||
namespace BaseGames.World
|
||
{
|
||
/// <summary>
|
||
/// 幻影可交互机关。继承 DirectionalInteractable,额外响应 PhantomBody 层(太虚斩形态)。
|
||
/// </summary>
|
||
public class PhantomInteractable : DirectionalInteractable
|
||
{
|
||
private int _phantomBodyLayer;
|
||
|
||
private void Awake() => _phantomBodyLayer = LayerMask.NameToLayer("PhantomBody");
|
||
|
||
private void OnTriggerEnter2D(Collider2D other)
|
||
{
|
||
bool isPlayer = other.CompareTag("Player");
|
||
bool isPhantom = other.gameObject.layer == _phantomBodyLayer;
|
||
|
||
if (!isPlayer && !isPhantom) return;
|
||
TryActivate();
|
||
}
|
||
}
|
||
}
|