| 65 | } |
| 66 | |
| 67 | void ContainerObject::update(float dt, uint64_t currentStep) { |
| 68 | Object::update(dt, currentStep); |
| 69 | |
| 70 | if (isMaster()) { |
| 71 | for (auto const& drop : take(m_lostItems)) |
| 72 | world()->addEntity(ItemDrop::createRandomizedDrop(drop, position())); |
| 73 | |
| 74 | if (m_crafting.get()) |
| 75 | tickCrafting(dt); |
| 76 | |
| 77 | if (m_autoCloseCooldown > 0) { |
| 78 | m_autoCloseCooldown -= 1; |
| 79 | if (m_autoCloseCooldown <= 0) { |
| 80 | --m_count; |
| 81 | if (m_count <= 0) { |
| 82 | m_count = 0; |
| 83 | m_opened.set(0); |
| 84 | } else { |
| 85 | m_autoCloseCooldown = configValue("autoCloseCooldown").toInt(); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | m_ageItemsTimer.update(world()->epochTime()); |
| 91 | if (m_ageItemsTimer.elapsedTime() > configValue("ageItemsEvery", 10).toDouble()) { |
| 92 | double elapsedTime = m_ageItemsTimer.elapsedTime() * configValue("itemAgeMultiplier", 1.0f).toDouble(); |
| 93 | for (auto& item : m_items->items()) { |
| 94 | if (Root::singleton().itemDatabase()->ageItem(item, elapsedTime)) |
| 95 | itemsUpdated(); |
| 96 | } |
| 97 | m_ageItemsTimer.setElapsedTime(0.0); |
| 98 | } |
| 99 | |
| 100 | if (take(m_runUpdatedCallback)) |
| 101 | m_scriptComponent.invoke("containerCallback"); |
| 102 | |
| 103 | } else { |
| 104 | setImageKey("key", toString(m_currentState)); |
| 105 | setImageKey("state", m_crafting.get() ? "crafting" : "idle"); |
| 106 | |
| 107 | m_animationFrameCooldown -= 1; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | void ContainerObject::render(RenderCallback* renderCallback) { |
| 112 | auto assets = Root::singleton().assets(); |
nothing calls this directly
no test coverage detected