UI系统优化

This commit is contained in:
2026-05-25 11:54:37 +08:00
parent c7057db27d
commit 3c812cfb41
130 changed files with 4738 additions and 477 deletions

View File

@@ -16,7 +16,8 @@
"BaseGames.Enemies",
"BaseGames.Dialogue",
"Unity.Addressables",
"Unity.ResourceManager"
"Unity.ResourceManager",
"BaseGames.Localization"
],
"autoReferenced": true,
"overrideReferences": false,

View File

@@ -143,6 +143,13 @@ namespace BaseGames.Quest
/// 相比 <see cref="FilterQuests"/> 不分配新列表,适合高频调用场景。
/// </summary>
void FillFilterQuests(System.Func<string, QuestStateEnum, bool> predicate, System.Collections.Generic.List<string> result);
/// <summary>
/// 根据 questId 查找对应的 QuestSO 资产。
/// 返回 true 时 quest 非空;未注册或 ID 无效时返回 falsequest 为 null。
/// UI 层通过此方法取得 QuestSO无需在各 HUD 组件中重复注入完整的任务数据库。
/// </summary>
bool TryGetQuest(string questId, out QuestSO quest);
}
/// <summary>

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1b7e9d569a19aa44aaaf2fc8fd4324a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -32,7 +32,7 @@ namespace BaseGames.Quest
[SerializeField] private DialogueSequenceSO _completedDialogue;
[Header("交互选项")]
[Tooltip("勾选后任务进行中Active 且未完成)时交互提示变为"放弃任务",交互即触发 AbandonQuest。\n" +
[Tooltip("勾选后任务进行中Active 且未完成)时交互提示变为\"放弃任务\",交互即触发 AbandonQuest。\n" +
"适合允许玩家主动放弃的支线任务;主线任务建议保持取消勾选。")]
[SerializeField] private bool _allowAbandon;

View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using BaseGames.Core;
using BaseGames.Core.Events;
using BaseGames.Core.Save;
using QuestStateEnum = BaseGames.Core.Events.QuestState;
@@ -1079,6 +1081,13 @@ namespace BaseGames.Quest
private QuestSO GetQuestSO(string id)
=> _questIndex != null && _questIndex.TryGetValue(id, out var q) ? q : null;
/// <inheritdoc cref="IQuestManager.TryGetQuest"/>
public bool TryGetQuest(string questId, out QuestSO quest)
{
quest = GetQuestSO(questId);
return quest != null;
}
/// <summary>
/// 优先从预缓存表查找 compositeKeyO(1),零字符串分配);
/// 缓存未命中时 fallback 到 CompositeKey() 动态构建(运行时新增的目标)。

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using BaseGames.Core;
using BaseGames.Dialogue;
using BaseGames.Localization;
namespace BaseGames.Quest
{
@@ -10,7 +12,7 @@ namespace BaseGames.Quest
/// 资产路径: Assets/ScriptableObjects/Quest/Quest_{questId}.asset
/// </summary>
[CreateAssetMenu(menuName = "BaseGames/Quest/Quest")]
public class QuestSO : ScriptableObject
public class QuestSO : ScriptableObject, ILocalizableAsset
{
[Header("标识")]
[Tooltip("任务唯一 ID如 \"Quest_FindMushroom\"。运行时由 QuestManager 以此为键索引,必须全局唯一。")]
@@ -270,6 +272,18 @@ namespace BaseGames.Quest
return false;
}
#endif
public IEnumerable<LocalizationKeyRef> GetLocalizationKeys()
{
if (!string.IsNullOrEmpty(displayNameKey))
yield return new LocalizationKeyRef(displayNameKey, "Quest", nameof(displayNameKey));
if (!string.IsNullOrEmpty(descriptionKey))
yield return new LocalizationKeyRef(descriptionKey, "Quest", nameof(descriptionKey));
if (objectives != null)
foreach (var obj in objectives)
if (obj != null && !string.IsNullOrEmpty(obj.displayTextKey))
yield return new LocalizationKeyRef(obj.displayTextKey, "Quest", "objectives.displayTextKey");
}
}
[Serializable]