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

Method tickMaster

source/game/StarStatusController.cpp:479–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477}
478
479void StatusController::tickMaster(float dt) {
480 m_statCollection.tickMaster(dt);
481
482 m_recentHitsGiven.tick(1);
483 m_recentDamageGiven.tick(1);
484 m_recentDamageTaken.tick(1);
485
486 bool statusImmune = statPositive("statusImmunity");
487
488 if (!statusImmune && m_movementController->liquidPercentage() > m_minimumLiquidStatusEffectPercentage) {
489 auto liquidsDatabase = Root::singleton().liquidsDatabase();
490 if (auto liquidSettings = liquidsDatabase->liquidSettings(m_movementController->liquidId())) {
491 for (auto const& effect : liquidSettings->statusEffects)
492 addEphemeralEffect(jsonToEphemeralStatusEffect(effect));
493 }
494 }
495
496 if (m_environmentStatusEffectUpdateTimer.wrapTick()) {
497 PolyF collisionBody = m_movementController->collisionBody();
498 List<PersistentStatusEffect> entityEffects;
499 if (!statusImmune) {
500 m_parentEntity->world()->forEachEntity(collisionBody.boundBox(),
501 [this, collisionBody, &entityEffects](EntityPtr const& e) {
502 if (auto entity = as<StatusEffectEntity>(e)) {
503 auto statusEffectArea = entity->statusEffectArea();
504 statusEffectArea.translate(entity->position());
505 if (m_parentEntity->world()->geometry().polyIntersectsPoly(statusEffectArea, collisionBody))
506 entityEffects.appendAll(entity->statusEffects());
507 }
508 });
509 }
510 setPersistentEffects("entities", entityEffects);
511
512 if (!statusImmune && m_appliesEnvironmentStatusEffects)
513 setPersistentEffects("environment", m_parentEntity->world()->environmentStatusEffects(m_parentEntity->position()).transformed(jsonToPersistentStatusEffect));
514
515 if (!statusImmune && m_appliesWeatherStatusEffects)
516 addEphemeralEffects(m_parentEntity->world()->weatherStatusEffects(m_parentEntity->position()).transformed(jsonToEphemeralStatusEffect));
517 }
518
519 m_primaryScript.update(m_primaryScript.updateDt(dt));
520 for (auto& p : m_uniqueEffects) {
521 p.second.script.update(p.second.script.updateDt(dt));
522 auto metadata = m_uniqueEffectMetadata.getNetElement(p.second.metadataId);
523 if (metadata->duration)
524 *metadata->duration -= dt;
525 }
526
527 for (auto const& key : m_uniqueEffects.keys()) {
528 auto& uniqueEffect = m_uniqueEffects[key];
529 auto metadata = m_uniqueEffectMetadata.getNetElement(uniqueEffect.metadataId);
530 if (metadata->duration && *metadata->duration <= 0.0f)
531 removeUniqueEffect(key);
532 else if ((metadata->duration && statPositive("statusImmunity")) || (uniqueEffect.effectConfig.blockingStat && statPositive(*uniqueEffect.effectConfig.blockingStat)))
533 removeUniqueEffect(key);
534 }
535
536 DirectivesGroup parentDirectives;

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
liquidPercentageMethod · 0.80
liquidsDatabaseMethod · 0.80
liquidSettingsMethod · 0.80
wrapTickMethod · 0.80
polyIntersectsPolyMethod · 0.80
appendAllMethod · 0.80
updateDtMethod · 0.80
getNetElementMethod · 0.80
tickMethod · 0.45
liquidIdMethod · 0.45

Tested by

no test coverage detected