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

Method tick

source/game/StarEffectEmitter.cpp:33–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33void EffectEmitter::tick(float dt, EntityMode mode) {
34 if (mode == EntityMode::Master) {
35 m_activeSources.set(std::move(m_newSources));
36 m_newSources.clear();
37 } else {
38 if (!m_newSources.empty())
39 throw StarException("EffectEmitters can only be added to the master entity.");
40 }
41 if (m_renders) {
42 eraseWhere(m_sources, [](EffectSourcePtr const& source) { return source->expired(); });
43
44 for (auto& ps : m_sources)
45 ps->tick(dt);
46
47 Set<pair<String, String>> current;
48 for (auto& ps : m_sources) {
49 pair<String, String> entry = {ps->suggestedSpawnLocation(), ps->kind()};
50 current.add(entry);
51 if (!m_activeSources.get().contains(entry)) {
52 ps->stop();
53 }
54 }
55 for (auto& c : m_activeSources.get()) {
56 if (!current.contains(c)) {
57 m_sources.append(Root::singleton().effectSourceDatabase()->effectSourceConfig(c.second)->instance(c.first));
58 }
59 }
60 }
61}
62
63void EffectEmitter::reset() {
64 m_sources.clear();

Callers

nothing calls this directly

Calls 15

StarExceptionClass · 0.85
eraseWhereFunction · 0.85
singletonClass · 0.85
effectSourceConfigMethod · 0.80
effectSourceDatabaseMethod · 0.80
setMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
expiredMethod · 0.45
kindMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected