public QuestWatchItem(string title, int entryNumber, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) { this.title = title; this.entryNumber = entryNumber; this.frequency = frequency; this.luaExpression = string.Format("return Item[\"{0}\"].Entry_{1}_State", new System.Object[] { DialogueLua.StringToTableIndex(title), entryNumber }); this.questChangedHandler = questChangedHandler; DialogueManager.AddLuaObserver(luaExpression, frequency, OnLuaChanged); }
/// <summary> /// Removes a quest state observer. To be removed, the title, frequency, and delegate must /// all match. /// </summary> /// <param name='title'> /// Title of the quest. /// </param> /// <param name='entryNumber'> /// The entry number (1...Entry Count) in the quest. /// </param> /// <param name='frequency'> /// Frequency that the quest state is being checked. /// </param> /// <param name='questChangedHandler'> /// Quest changed handler delegate. /// </param> public static void RemoveQuestStateObserver(string title, int entryNumber, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) { foreach (var questWatchItem in questWatchList) { if (questWatchItem.Matches(title, entryNumber, frequency, questChangedHandler)) { questWatchItem.StopObserving(); } } questWatchList.RemoveAll(questWatchItem => questWatchItem.Matches(title, entryNumber, frequency, questChangedHandler)); }
/// <summary> /// Adds a quest state observer. /// </summary> /// <param name='title'> /// Title of the quest. /// </param> /// <param name='entryNumber'> /// The entry number (1...Entry Count) in the quest. /// </param> /// <param name='frequency'> /// Frequency to check the quest state. /// </param> /// <param name='questChangedHandler'> /// Delegate to call when the quest state changes. This should be in the form: /// <code>void MyDelegate(string title, QuestState newState) {...}</code> /// </param> public static void AddQuestStateObserver(string title, int entryNumber, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) { questWatchList.Add(new QuestWatchItem(title, entryNumber, frequency, questChangedHandler)); }
public bool Matches(string title, int entryNumber, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) { return(string.Equals(title, this.title) && (entryNumber == this.entryNumber) && (frequency == this.frequency) && (questChangedHandler == this.questChangedHandler)); }
public bool Matches(string title, int entryNumber, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) { return string.Equals(title, this.title) && (entryNumber == this.entryNumber) && (frequency == this.frequency) && (questChangedHandler == this.questChangedHandler); }
/// <summary> /// Removes a quest state observer. To be removed, the title, frequency, and delegate must /// all match. /// </summary> /// <param name='title'> /// Title of the quest. /// </param> /// <param name='entryNumber'> /// The entry number (1...Entry Count) in the quest. /// </param> /// <param name='frequency'> /// Frequency that the quest state is being checked. /// </param> /// <param name='questChangedHandler'> /// Quest changed handler delegate. /// </param> public static void RemoveQuestStateObserver(string title, int entryNumber, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) { foreach (var questWatchItem in questWatchList) { if (questWatchItem.Matches(title, entryNumber, frequency, questChangedHandler)) questWatchItem.StopObserving(); } questWatchList.RemoveAll(questWatchItem => questWatchItem.Matches(title, entryNumber, frequency, questChangedHandler)); }