Add independent review reports for Minimap system (Rounds 8, 9, and 26)
- Round 8 report highlights improvements in architecture, editor usability, and data robustness, with a total score of 80/100. - Round 9 report focuses on editor extension capabilities, identifying issues with room data indexing and layout editing, resulting in a score of 76/100. - Round 26 report evaluates the system against commercial standards, noting new issues and confirming previous fixes, with a score of 95.8/100.
This commit is contained in:
53
Assets/_Game/Scripts/World/Map/MapPinConfigSO.cs
Normal file
53
Assets/_Game/Scripts/World/Map/MapPinConfigSO.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BaseGames.Core.Save;
|
||||
|
||||
namespace BaseGames.World.Map
|
||||
{
|
||||
/// <summary>
|
||||
/// 集中管理标记类型(PinType)与对应 Sprite 的映射配置。
|
||||
/// 替代原先分散在 MapPanel 和 MinimapHUD 中各自维护的 PinSpriteEntry 数组,
|
||||
/// 两个 UI 组件共享同一资产引用,保证标记外观统一且便于策划修改。
|
||||
/// <para>内部使用 <see cref="Dictionary{TKey,TValue}"/> 惰性缓存,GetSprite 为 O(1) 查找。</para>
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "BaseGames/World/Map/PinConfig")]
|
||||
public class MapPinConfigSO : ScriptableObject
|
||||
{
|
||||
[SerializeField] private PinSpriteEntry[] _entries;
|
||||
|
||||
private Dictionary<PinType, Sprite> _cache;
|
||||
|
||||
/// <summary>
|
||||
/// 根据 PinType 返回对应 Sprite(O(1) 哈希查找)。
|
||||
/// 首次调用时惰性构建内部字典;entries 中无匹配项时返回 null。
|
||||
/// </summary>
|
||||
public Sprite GetSprite(PinType type)
|
||||
{
|
||||
EnsureCache();
|
||||
return _cache.TryGetValue(type, out var s) ? s : null;
|
||||
}
|
||||
|
||||
private void EnsureCache()
|
||||
{
|
||||
if (_cache != null) return;
|
||||
_cache = new Dictionary<PinType, Sprite>();
|
||||
if (_entries == null) return;
|
||||
foreach (var e in _entries)
|
||||
_cache[e.PinType] = e.Sprite;
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
// 编辑器修改配置后立即重建缓存,确保 Play Mode 前数据已就绪
|
||||
_cache = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>标记类型与显示精灵的映射表项。</summary>
|
||||
[System.Serializable]
|
||||
public class PinSpriteEntry
|
||||
{
|
||||
public PinType PinType;
|
||||
public Sprite Sprite;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user