Files
zeling_v2/Assets/Scripts/World/WorldMarker.cs
2026-05-12 15:34:08 +08:00

69 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
namespace BaseGames.World
{
/// <summary>
/// 世界标记点(架构 21_LiquidPuzzleModule §14
/// 用于在地图/小地图上标注目标、NPC、兴趣点等。
/// 通过事件频道通知 UI 层显示/隐藏图标。
/// </summary>
public class WorldMarker : MonoBehaviour
{
[Header("标记配置")]
[SerializeField] private WorldMarkerType _markerType = WorldMarkerType.Objective;
[SerializeField] private string _markerId = "";
[SerializeField] private string _labelKey = ""; // 本地化 Key
[Header("事件频道")]
[SerializeField] private WorldMarkerEventChannelSO _onMarkerActivated;
[SerializeField] private WorldMarkerEventChannelSO _onMarkerDeactivated;
public WorldMarkerType MarkerType => _markerType;
public string MarkerId => _markerId;
public string LabelKey => _labelKey;
private bool _isActive;
public bool IsActive => _isActive;
// ── 公共 API ──────────────────────────────────────────────────────
public void Activate()
{
if (_isActive) return;
_isActive = true;
_onMarkerActivated?.Raise(this);
}
public void Deactivate()
{
if (!_isActive) return;
_isActive = false;
_onMarkerDeactivated?.Raise(this);
}
// ── 编辑器辅助 ────────────────────────────────────────────────────
private void OnDrawGizmosSelected()
{
Gizmos.color = _markerType switch
{
WorldMarkerType.Objective => Color.yellow,
WorldMarkerType.NPC => Color.cyan,
WorldMarkerType.PointOfInterest => Color.green,
WorldMarkerType.Exit => Color.blue,
WorldMarkerType.Secret => Color.magenta,
_ => Color.white,
};
Gizmos.DrawWireSphere(transform.position, 0.4f);
}
}
/// <summary>世界标记类型(架构 21_LiquidPuzzleModule §14。</summary>
public enum WorldMarkerType
{
Objective,
NPC,
PointOfInterest,
Exit,
Secret,
}
}