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

Method update

source/game/StarSpawner.cpp:76–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void 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
106Vec2I Spawner::cellIndexForPosition(Vec2F const& position) const {
107 return Vec2I::floor(position / m_spawnCellSize);

Callers

nothing calls this directly

Calls 8

eraseWhereFunction · 0.85
clientWindowsMethod · 0.80
paddedMethod · 0.80
getEntityMethod · 0.80
despawnEntityMethod · 0.80
entityIdMethod · 0.80
containsMethod · 0.45
positionMethod · 0.45

Tested by

no test coverage detected