MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / getQuestIndicator

Method getQuestIndicator

source/game/StarQuestManager.cpp:303–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303Maybe<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
355StringSet QuestManager::interestingObjects() {
356 StringSet result;

Callers 1

updateMethod · 0.80

Calls 15

singletonClass · 0.85
questTemplateDatabaseMethod · 0.80
questTemplateMethod · 0.80
jsonMethod · 0.80
assetsMethod · 0.80
getStringMethod · 0.80
customIndicatorMethod · 0.80
positionMethod · 0.45
turnInQuestsMethod · 0.45
canTurnInMethod · 0.45
offeredQuestsMethod · 0.45

Tested by

no test coverage detected