| 381 | } |
| 382 | |
| 383 | void Object::update(float dt, uint64_t) { |
| 384 | if (!inWorld()) |
| 385 | return; |
| 386 | |
| 387 | if (isMaster()) { |
| 388 | m_tileDamageStatus->recover(m_config->tileDamageParameters, dt); |
| 389 | |
| 390 | if (m_liquidCheckTimer.wrapTick()) |
| 391 | checkLiquidBroken(); |
| 392 | |
| 393 | if (auto orientation = currentOrientation()) { |
| 394 | auto frame = clamp<int>(std::floor(m_animationTimer / orientation->animationCycle * orientation->frames), 0, orientation->frames - 1); |
| 395 | if (m_currentFrame != frame) { |
| 396 | m_currentFrame = frame; |
| 397 | setImageKey("frame", toString(frame)); |
| 398 | } |
| 399 | |
| 400 | m_animationTimer = std::fmod(m_animationTimer + dt, orientation->animationCycle); |
| 401 | } |
| 402 | |
| 403 | m_networkedAnimator->update(dt, nullptr); |
| 404 | m_networkedAnimator->setFlipped(direction() == Direction::Left, m_animationCenterLine); |
| 405 | |
| 406 | m_scriptComponent.update(m_scriptComponent.updateDt(dt)); |
| 407 | |
| 408 | } else { |
| 409 | m_networkedAnimator->update(dt, &m_networkedAnimatorDynamicTarget); |
| 410 | m_networkedAnimatorDynamicTarget.updatePosition(position() + m_animationPosition); |
| 411 | } |
| 412 | |
| 413 | if (m_lightFlickering) |
| 414 | m_lightFlickering->update(dt); |
| 415 | |
| 416 | for (auto& timer : m_emissionTimers) |
| 417 | timer.tick(dt); |
| 418 | |
| 419 | if (world()->isClient()) |
| 420 | m_scriptedAnimator.update(); |
| 421 | } |
| 422 | |
| 423 | void Object::render(RenderCallback* renderCallback) { |
| 424 | renderParticles(renderCallback); |
no test coverage detected