protected virtual void OnQuestFinished() { QuestFinished?.Invoke(this, new QuestEventArgs() { Quest = this }); }
/// <summary> /// Tries to finish a quest for the owner. /// </summary> /// <param name="quest">The quest to turn in.</param> /// <returns>True if the quest was successfully turned in; false if the owner did not have the <paramref name="quest"/> /// in their active quest list, if the quest was invalid, or if they did not have the requirements needed /// to finish the quest.</returns> public bool TryFinishQuest(IQuest <TCharacter> quest) { // Make sure they even have this in their active quests if (!_activeQuests.Contains(quest)) { return(false); } // Check for the finish requirements if (!quest.FinishRequirements.HasRequirements(Owner)) { return(false); } // Ensure there is room to give them the reward(s) if (!quest.Rewards.CanGive(Owner)) { NotifyCannotGiveQuestRewards(quest); return(false); } Debug.Assert(quest.Repeatable || !HasCompletedQuest(quest), "Uh-oh, this user has already completed this quest!"); // Remove from the active quests and give the rewards var removed = _activeQuests.Remove(quest); Debug.Assert(removed); // Add the quest to the completed quests list _completedQuests.Add(quest); quest.Rewards.Give(Owner); // Raise events OnQuestFinished(quest); if (QuestFinished != null) { QuestFinished.Raise(this, EventArgsHelper.Create(quest)); } return(true); }
private void OnQuestFinished() { QuestFinished?.Invoke(this, null); }