public void OnModuleCrafted(ShipModule module) { logger.Info($"{LOG_TAG}: module crafted {module.SlotType}"); CraftedModule = new CraftedModule(module.SlotType, module.Level, module.Color); if (startedQuests.Count > 0) { bool needTryComplete = false; foreach (var quest in startedQuests) { QuestConditionCollection conditions = null; if (quest.Data.TryGetCompleteConditions(PlayerRace, out conditions)) { if (conditions.HasCondition <ModuleCraftedQuestCondition>()) { needTryComplete = true; } } } if (needTryComplete) { TryCompleteQuest(sendUpdate: true); } } }
public bool TryCompleteQuest(bool sendUpdate) { if (startedQuests.Count > 0) { candidatesToComplete.Clear(); bool wasUpdate = false; foreach (QuestInfo questInfo in startedQuests) { if (questInfo.State == QuestState.started) { QuestData questData = questInfo.Data; if (questData != null) { QuestConditionCollection completeConditions = null; if (questData.CompleteConditions.TryGetValue(PlayerRace, out completeConditions)) { if (completeConditions != null) { if (completeConditions.Check(this)) { questInfo.AddCounter(1); if (questInfo.Counter >= completeConditions.Repeat) { candidatesToComplete.Add(questInfo); } else { wasUpdate = true; } } } } } } } CraftedModule = null; KilledNpc = null; CreatedStructure = null; if (wasUpdate || sendUpdate) { SendQuestsUpdate(); } if (candidatesToComplete.Count > 0) { foreach (QuestInfo candidateQuest in candidatesToComplete) { QuestConditionCollection completeConditions = null; if (candidateQuest.Data.TryGetCompleteConditions(PlayerRace, out completeConditions)) { foreach (QuestCondition condition in completeConditions.Conditions) { if (condition.IsClearVariable) { condition.ResetVariable(this); } } } candidateQuest.SetState(QuestState.ready); Hashtable hash = new Hashtable { { (int)SPC.NewQuest, candidateQuest.GetInfo() }, { (int)SPC.Info, GetInfo() } }; MmoMessage.ReceiveNewQuests(CustomEventCode.NewQuestReady, hash); logger.Info($"{LOG_TAG}: Quest Ready => {candidateQuest.Id}, counter => {candidateQuest.Counter}"); } return(true); } } return(false); }