From 0be262e684cd2c6453b1e5f18662b1d364696fb5 Mon Sep 17 00:00:00 2001 From: Bruno Araujo Date: Fri, 29 Mar 2019 17:30:48 -0300 Subject: [PATCH] Minor updates - Global flags event on set - Typo in DiplomataEventController - Better error description on Item.Find - Removing duplicated SendQuestStateChange --- Diplomata/DiplomataEventController.cs | 19 +++++++++++++++++-- Diplomata/DiplomataTalkable.cs | 2 +- Diplomata/Models/Item.cs | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Diplomata/DiplomataEventController.cs b/Diplomata/DiplomataEventController.cs index 2217746..601d5bd 100644 --- a/Diplomata/DiplomataEventController.cs +++ b/Diplomata/DiplomataEventController.cs @@ -37,7 +37,12 @@ public class DiplomataEventController /// Happens every time a context ends. /// public event Action OnContextEnd; - + + /// + /// Happens every time a flag is set. + /// + public event Action OnSetFlag; + /// /// Trigger the event OnQuestStart with the quest data that have started. /// @@ -79,7 +84,7 @@ public void SendItemWasCaught(Item itemWasCaught) } /// - /// Trigger the event OnContextEnd whit the ended context data. + /// Trigger the event OnContextEnd with the ended context data. /// /// public void SendContextEnd(Context context) @@ -87,5 +92,15 @@ public void SendContextEnd(Context context) if (OnContextEnd != null) OnContextEnd(context); } + + /// + /// Trigger the event OnSetFlag when a flag is set. + /// + /// The flag. + public void SendOnSetFlag(Flag flag) + { + if (OnSetFlag != null) + OnSetFlag(flag); + } } } diff --git a/Diplomata/DiplomataTalkable.cs b/Diplomata/DiplomataTalkable.cs index 4b79a94..fdf7e96 100644 --- a/Diplomata/DiplomataTalkable.cs +++ b/Diplomata/DiplomataTalkable.cs @@ -1013,6 +1013,7 @@ public void NextMessage() if (flag != null) { flag.value = effect.globalFlag.value; + DiplomataManager.EventController.SendOnSetFlag(flag); } else { @@ -1042,7 +1043,6 @@ public void NextMessage() else { quest.SetState(effect.questAndState.questStateId); - DiplomataManager.EventController.SendQuestStateChange(quest); if (OnQuestStateChangeLocal != null) OnQuestStateChangeLocal(quest); diff --git a/Diplomata/Models/Item.cs b/Diplomata/Models/Item.cs index 31aa01a..5e3fa6c 100644 --- a/Diplomata/Models/Item.cs +++ b/Diplomata/Models/Item.cs @@ -322,7 +322,7 @@ public static Item Find(Item[] items, string name, string language = "English") return item; } } - Debug.LogError("This item doesn't exist."); + Debug.LogError($"This item \"{name}\" doesn't exist."); return null; }