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

Method update

source/game/objects/StarContainerObject.cpp:67–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67void 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
111void ContainerObject::render(RenderCallback* renderCallback) {
112 auto assets = Root::singleton().assets();

Callers

nothing calls this directly

Calls 15

takeFunction · 0.85
singletonClass · 0.85
toStringFunction · 0.85
toIntMethod · 0.80
elapsedTimeMethod · 0.80
toDoubleMethod · 0.80
itemsMethod · 0.80
ageItemMethod · 0.80
itemDatabaseMethod · 0.80
setElapsedTimeMethod · 0.80
addEntityMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected