| 301 | } |
| 302 | |
| 303 | Maybe<QuestIndicator> QuestManager::getQuestIndicator(EntityPtr const& entity) const { |
| 304 | Maybe<String> indicatorType; |
| 305 | Vec2F indicatorPos = entity->position() + Vec2F(0, 2.75); |
| 306 | auto questGiver = as<InteractiveEntity>(entity); |
| 307 | |
| 308 | if (questGiver) { |
| 309 | if (!indicatorType) { |
| 310 | for (auto& questId : questGiver->turnInQuests()) { |
| 311 | if (!isActive(questId)) |
| 312 | continue; |
| 313 | auto quest = getQuest(questId); |
| 314 | if (quest->canTurnIn()) { |
| 315 | indicatorType = quest->questReceiverIndicator(); |
| 316 | break; |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | if (!indicatorType) { |
| 322 | auto questTemplateDatabase = Root::singleton().questTemplateDatabase(); |
| 323 | for (auto& questArc : questGiver->offeredQuests()) { |
| 324 | if (canStart(questArc) && questArc.quests.size() > 0) { |
| 325 | auto& questDesc = questArc.quests[0]; |
| 326 | auto questTemplate = questTemplateDatabase->questTemplate(questDesc.templateId); |
| 327 | indicatorType = questTemplate->questGiverIndicator; |
| 328 | break; |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | if (indicatorType) { |
| 335 | Json indicators = Root::singleton().assets()->json("/quests/quests.config:indicators"); |
| 336 | String indicatorImage = indicators.get(*indicatorType).getString("image"); |
| 337 | if (questGiver) |
| 338 | indicatorPos = questGiver->questIndicatorPosition(); |
| 339 | return QuestIndicator{indicatorImage, indicatorPos}; |
| 340 | } |
| 341 | |
| 342 | for (auto& pair : m_quests) { |
| 343 | if (pair.second->state() == QuestState::Active) { |
| 344 | if (auto indicatorImage = pair.second->customIndicator(entity)) { |
| 345 | if (questGiver) |
| 346 | indicatorPos = questGiver->questIndicatorPosition(); |
| 347 | return QuestIndicator{ *indicatorImage, indicatorPos }; |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | return {}; |
| 353 | } |
| 354 | |
| 355 | StringSet QuestManager::interestingObjects() { |
| 356 | StringSet result; |
no test coverage detected