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

Method tickShared

source/game/StarNpc.cpp:584–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582}
583
584void Npc::tickShared(float dt) {
585 if (m_hitDamageNotificationLimiter)
586 m_hitDamageNotificationLimiter--;
587
588 m_songbook->update(*entityMode(), world());
589
590 m_effectEmitter->setSourcePosition("normal", position());
591 m_effectEmitter->setSourcePosition("mouth", position() + mouthOffset());
592 m_effectEmitter->setSourcePosition("feet", position() + feetOffset());
593 m_effectEmitter->setSourcePosition("headArmor", headArmorOffset() + position());
594 m_effectEmitter->setSourcePosition("chestArmor", chestArmorOffset() + position());
595 m_effectEmitter->setSourcePosition("legsArmor", legsArmorOffset() + position());
596 m_effectEmitter->setSourcePosition("backArmor", backArmorOffset() + position());
597
598 m_effectEmitter->setDirection(m_humanoid.facingDirection());
599 m_effectEmitter->tick(dt, *entityMode());
600
601 m_humanoid.setMovingBackwards(m_movementController->movingDirection() != m_movementController->facingDirection());
602 m_humanoid.setFacingDirection(m_movementController->facingDirection());
603 m_humanoid.setRotation(m_movementController->rotation());
604
605 ActorMovementModifiers firingModifiers;
606 if (auto fireableMain = as<FireableItem>(handItem(ToolHand::Primary))) {
607 if (fireableMain->firing()) {
608 if (fireableMain->stopWhileFiring())
609 firingModifiers.movementSuppressed = true;
610 else if (fireableMain->walkWhileFiring())
611 firingModifiers.runningSuppressed = true;
612 }
613 }
614
615 if (auto fireableAlt = as<FireableItem>(handItem(ToolHand::Alt))) {
616 if (fireableAlt->firing()) {
617 if (fireableAlt->stopWhileFiring())
618 firingModifiers.movementSuppressed = true;
619 else if (fireableAlt->walkWhileFiring())
620 firingModifiers.runningSuppressed = true;
621 }
622 }
623
624 m_armor->setupHumanoid(m_humanoid, false);
625
626 m_tools->suppressItems(!canUseTool());
627 m_tools->tick(dt, m_shifting.get(), {});
628
629 if (auto overrideDirection = m_tools->setupHumanoidHandItems(m_humanoid, position(), aimPosition()))
630 m_movementController->controlFace(*overrideDirection);
631
632 m_humanoid.animate(dt);
633}
634
635LuaCallbacks Npc::makeNpcCallbacks() {
636 LuaCallbacks callbacks;

Callers

nothing calls this directly

Calls 15

setSourcePositionMethod · 0.80
setMovingBackwardsMethod · 0.80
movingDirectionMethod · 0.80
setFacingDirectionMethod · 0.80
stopWhileFiringMethod · 0.80
walkWhileFiringMethod · 0.80
setupHumanoidMethod · 0.80
suppressItemsMethod · 0.80
controlFaceMethod · 0.80
animateMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected