MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / useTrigger

Method useTrigger

src/Core/Script/GameObject.cpp:339–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337 }
338
339 void GameObject::useTrigger(const std::string& trNsp, const std::string& trGrp,
340 const std::string& trName, const std::string& callAlias)
341 {
342 if (trName == "*")
343 {
344 std::vector<std::string> allTrg
345 = m_triggers.getAllTriggersNameFromTriggerGroup(trNsp, trGrp);
346 for (const std::string& triggerName : allTrg)
347 {
348 this->useTrigger(trNsp, trGrp, triggerName,
349 (Utils::String::occurencesInString(callAlias, "*")
350 ? Utils::String::replace(callAlias, "*", triggerName)
351 : ""));
352 }
353 }
354 else
355 {
356 bool triggerNotFound = true;
357 for (auto& triggerPair : m_registeredTriggers)
358 {
359 if (triggerPair.first.lock()
360 == m_triggers.getTrigger(trNsp, trGrp, trName).lock())
361 {
362 triggerNotFound = false;
363 }
364 }
365 if (triggerNotFound)
366 {
367 const std::string callbackName = (callAlias.empty())
368 ? trNsp + "." + trGrp + "." + trName
369 : callAlias;
370 this->registerTrigger(
371 m_triggers.getTrigger(trNsp, trGrp, trName), callbackName);
372 m_triggers.getTrigger(trNsp, trGrp, trName)
373 .lock()
374 ->registerEnvironment(m_id, m_environment, callbackName, &m_active);
375 }
376 else
377 {
378 const std::string callbackName = (callAlias.empty())
379 ? trNsp + "." + trGrp + "." + trName
380 : callAlias;
381 m_triggers.getTrigger(trNsp, trGrp, trName)
382 .lock()
383 ->unregisterEnvironment(m_environment);
384 m_triggers.getTrigger(trNsp, trGrp, trName)
385 .lock()
386 ->registerEnvironment(m_id, m_environment, callbackName, &m_active);
387 }
388 }
389 }
390
391 void GameObject::removeTrigger(const std::string& trNsp, const std::string& trGrp,
392 const std::string& trName) const

Callers 1

LoadClassGameObjectFunction · 0.80

Calls 9

registerTriggerMethod · 0.95
occurencesInStringFunction · 0.85
lockMethod · 0.80
getTriggerMethod · 0.80
registerEnvironmentMethod · 0.80
unregisterEnvironmentMethod · 0.80
replaceFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected