using UnityEngine;
using UnityEngine.Events;
namespace SK.Framework
{
///
/// 可瞄准物体基类
///
public class AimableObject : MonoBehaviour, IAimableObject
{
#region NonPublic Variables
[SerializeField] protected string description;
[SerializeField] protected float aimableDistance = 2f;
[SerializeField] protected UnityEvent onEnter;
[SerializeField] protected UnityEvent onExit;
[SerializeField] protected UnityEvent onStay;
#endregion
#region Public Properties
///
/// 物体描述
///
public string Description
{
get
{
return description;
}
}
///
/// 可瞄准检测的距离
///
public float AimableDistance
{
get
{
return aimableDistance;
}
}
#endregion
#region NonPublic Methods
//进入事件
protected virtual void OnEnter() { }
//退出事件
protected virtual void OnExit() { }
//停留事件
protected virtual void OnStay() { }
#endregion
#region Public Methods
///
/// 瞄准进入
///
public void Enter()
{
OnEnter();
onEnter?.Invoke();
}
///
/// 瞄准退出
///
public void Exit()
{
OnExit();
onExit?.Invoke();
}
///
/// 瞄准停留
///
public void Stay()
{
OnStay();
onStay?.Invoke();
}
#endregion
}
}