| 31 | } |
| 32 | |
| 33 | void 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 | |
| 63 | void EffectEmitter::reset() { |
| 64 | m_sources.clear(); |
nothing calls this directly
no test coverage detected