UI系统优化
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
"BaseGames.Enemies",
|
||||
"BaseGames.Dialogue",
|
||||
"Unity.Addressables",
|
||||
"Unity.ResourceManager"
|
||||
"Unity.ResourceManager",
|
||||
"BaseGames.Localization"
|
||||
],
|
||||
"autoReferenced": true,
|
||||
"overrideReferences": false,
|
||||
|
||||
@@ -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 无效时返回 false,quest 为 null。
|
||||
/// UI 层通过此方法取得 QuestSO,无需在各 HUD 组件中重复注入完整的任务数据库。
|
||||
/// </summary>
|
||||
bool TryGetQuest(string questId, out QuestSO quest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
11
Assets/_Game/Scripts/Quest/QuestEventChannelRegistry.cs.meta
Normal file
11
Assets/_Game/Scripts/Quest/QuestEventChannelRegistry.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b7e9d569a19aa44aaaf2fc8fd4324a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -32,7 +32,7 @@ namespace BaseGames.Quest
|
||||
[SerializeField] private DialogueSequenceSO _completedDialogue;
|
||||
|
||||
[Header("交互选项")]
|
||||
[Tooltip("勾选后,任务进行中(Active 且未完成)时交互提示变为"放弃任务",交互即触发 AbandonQuest。\n" +
|
||||
[Tooltip("勾选后,任务进行中(Active 且未完成)时交互提示变为\"放弃任务\",交互即触发 AbandonQuest。\n" +
|
||||
"适合允许玩家主动放弃的支线任务;主线任务建议保持取消勾选。")]
|
||||
[SerializeField] private bool _allowAbandon;
|
||||
|
||||
|
||||
@@ -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>
|
||||
/// 优先从预缓存表查找 compositeKey(O(1),零字符串分配);
|
||||
/// 缓存未命中时 fallback 到 CompositeKey() 动态构建(运行时新增的目标)。
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user