| 74 | } |
| 75 | |
| 76 | void Spawner::update(float dt) { |
| 77 | if (!m_facade) |
| 78 | return; |
| 79 | |
| 80 | for (auto const& window : m_facade->clientWindows()) { |
| 81 | if (window != RectF()) |
| 82 | activateRegion(window.padded(m_windowActivationBorder)); |
| 83 | } |
| 84 | |
| 85 | eraseWhere(m_activeSpawnCells, [dt](auto& p) { |
| 86 | return (p.second -= dt) < 0.0f; |
| 87 | }); |
| 88 | |
| 89 | eraseWhere(m_spawnedEntities, [this](EntityId entityId) { |
| 90 | auto entity = m_facade->getEntity(entityId); |
| 91 | if (!entity) |
| 92 | return true; |
| 93 | |
| 94 | if (!m_activeSpawnCells.contains(cellIndexForPosition(entity->position()))) { |
| 95 | m_facade->despawnEntity(entity->entityId()); |
| 96 | return true; |
| 97 | } |
| 98 | |
| 99 | return false; |
| 100 | }); |
| 101 | |
| 102 | if (m_active && m_debug) |
| 103 | debugShowSpawnCells(); |
| 104 | } |
| 105 | |
| 106 | Vec2I Spawner::cellIndexForPosition(Vec2F const& position) const { |
| 107 | return Vec2I::floor(position / m_spawnCellSize); |
nothing calls this directly
no test coverage detected