feat: Add WorldStateFlagAttribute and custom property drawer for enhanced dialogue management

- Implemented WorldStateFlagAttribute to mark string fields as world state flags.
- Created NarrativeNPCEditor for custom inspector to visualize dialogue version activation states.
- Developed WorldStateFlagDrawer to provide dropdown menu for known flags in the inspector.
- Introduced ActorModule for managing DialogueActorSO assets, including viewing, creating, and deleting actors.
- Added DialogueModule for managing DialogueSequenceSO assets with detailed previews and action bars.
- Established QuestModule for managing QuestSO assets, including objectives and branches.
- Implemented QuestManagerPostprocessor to automatically refresh QuestManager's quest list on asset changes.
This commit is contained in:
2026-05-24 00:36:11 +08:00
parent 520f84999b
commit 446fd5dcd0
22 changed files with 1908 additions and 101 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections;
using BaseGames.Core;
using BaseGames.Core.Events;
using BaseGames.Dialogue;
using UnityEngine;
namespace BaseGames.EventChain
@@ -59,7 +60,7 @@ namespace BaseGames.EventChain
public class BossDefeatedCondition : ChainCondition
{
public string bossId;
private bool _met;
[System.NonSerialized] private bool _met;
public override void Register(EventChainManager m) => m.OnBossDefeated += Check;
public override void Unregister(EventChainManager m) => m.OnBossDefeated -= Check;
public override bool IsMet() => _met;
@@ -80,7 +81,7 @@ namespace BaseGames.EventChain
public class AbilityUnlockedCondition : ChainCondition
{
public string abilityId;
private bool _met;
[System.NonSerialized] private bool _met;
public override void Register(EventChainManager m) => m.OnAbilityUnlocked += Check;
public override void Unregister(EventChainManager m) => m.OnAbilityUnlocked -= Check;
public override bool IsMet() => _met;
@@ -92,7 +93,7 @@ namespace BaseGames.EventChain
public class CollectibleCollectedCondition : ChainCondition
{
public string itemId;
private bool _met;
[System.NonSerialized] private bool _met;
public override void Register(EventChainManager m) => m.OnCollectiblePickedUp += Check;
public override void Unregister(EventChainManager m) => m.OnCollectiblePickedUp -= Check;
public override bool IsMet() => _met;
@@ -104,7 +105,7 @@ namespace BaseGames.EventChain
public class RoomEnteredCondition : ChainCondition
{
public string sceneName;
private bool _met;
[System.NonSerialized] private bool _met;
public override void Register(EventChainManager m) => m.OnRoomEntered += Check;
public override void Unregister(EventChainManager m) => m.OnRoomEntered -= Check;
public override bool IsMet() => _met;
@@ -116,7 +117,7 @@ namespace BaseGames.EventChain
public class DialogueCompletedCondition : ChainCondition
{
public string npcId;
private bool _met;
[System.NonSerialized] private bool _met;
public override void Register(EventChainManager m) => m.OnDialogueCompleted += Check;
public override void Unregister(EventChainManager m) => m.OnDialogueCompleted -= Check;
public override bool IsMet() => _met;
@@ -128,7 +129,7 @@ namespace BaseGames.EventChain
public class ChainCompletedCondition : ChainCondition
{
public string chainId;
private bool _met;
[System.NonSerialized] private bool _met;
public override void Register(EventChainManager m) => m.OnChainCompleted += Check;
public override void Unregister(EventChainManager m) => m.OnChainCompleted -= Check;
public override bool IsMet() => _met;
@@ -167,11 +168,18 @@ namespace BaseGames.EventChain
[CreateAssetMenu(menuName = "BaseGames/EventChain/Action/SetFlag")]
public class SetFlagAction : ChainAction
{
[WorldStateFlag]
public string flagId;
public bool value = true;
public override IEnumerator ExecuteAsync(MonoBehaviour runner)
{
ServiceLocator.GetOrDefault<ISaveService>()?.SetFlag(flagId, value);
var saveService = ServiceLocator.GetOrDefault<ISaveService>();
if (saveService == null)
{
Debug.LogError($"[SetFlagAction] ISaveService 未注册,标志 '{flagId}' 无法持久化。", this);
yield break;
}
saveService.SetFlag(flagId, value);
yield break;
}
}