I'm using Dialogue System and populating dialogue & quest content from Articy. I'm trying to keep as much logic out of Lua and inspector strings as possible for my own sanity; my current structure is that I make heavy use of Dialogue System's eventing & observer components to handle state changes, and use my own coroutines, callbacks, etc., to handle sequencing. I'm just now really digging into Dialogue System's components, though, and I want to make sure I'm not misusing them.
Also, sorry in advance for this being a little hairy—it's a hard thing to put concisely!
Let's say I have the following sequence of events in my game:
- Player interacts with Object, which turns Quest A from Active to Success.
- NPC becomes active next to the player.
- When the player and NPC are done talking, NPC runs away.
- When NPC is out of sight, they are deactivated, and Quest B is changed from Unassigned to Active.
- If the game or scene is loaded while Quest A is Successful and Quest B is Unassigned, NPC should be active. Otherwise, they should be inactive.
- Player interacts with Object, which turns Quest A from Active to Success: Object has a DialogueSystemTrigger. Trigger: OnUse, Action: Set Quest A state to Success.
- NPC becomes active next to the player: A separate object has a Quest State Listener. When Quest A is set to Success, this Listener sets NPC to Active.
- When the player and NPC are done talking, NPC runs away: NPC has a Dialogue Actor component and a DialogueSystemTrigger. Trigger: OnConversationEnd, Action: Begin my 'run away' coroutine.
- When NPC is out of sight, they are deactivated, and Quest B is changed from Unassigned to Active: Exposed UnityAction callback is invoked at the end of my 'run away' coroutine. This calls an OnUse DialogueSystemTrigger, which sets QuestB to Active and deactivates NPC.
- If the game or scene is loaded while Quest A is Successful and Quest B is Unassigned, NPC should be active. Otherwise, they should be inactive: A separate object has a PersistentActiveData component pointing at NPC. Conditions: Quest A state = Success, Quest B state =Active
(Should NPC be active) is equal to eval of (Quest A == Success && Quest B == Active).
In (2), I have a QuestStateListener that is listening for (Quest A == Success), but only on quest state change.
In (4), I have a DialogueSystemTrigger that is setting my NPC inactive 'arbitrarily'—it's at the same time as it sets (Quest B = Active), but not tied to the quest logic.
In (5), I have a PersistentActiveData that is listening for (Quest A == Success && Quest B == Active), but only on scene/game load.
To me, it seems like this could be simplified if there were one component that were listening to quest state change and scene/game load, and would set NPC.SetActive(Quest A == Success && Quest B == Active). Is there a way of doing that, or a better way of paring down my logic?
Thanks!