MCPcopy Create free account
hub / github.com/Hopson97/HopsonCraft / triggerBlocks

Method triggerBlocks

Source/World/World.cpp:254–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254void World::triggerBlocks()
255{
256 m_state = State::Triggering;
257 for (auto& block : m_triggerBlocks)
258 {
259 auto& p = block.first;
260 auto& b = block.second;
261 block.second.getType().trigger(*this, b, {int(p.x),
262 int(p.y),
263 int(p.z)});
264 }
265 /*
266 * When blocks are triggered, they have potential to trigger yet more blocks.
267 * Usually, you would just clear the triggered blocks here
268 * But, this would cause the blocks that get triggered during the triggering of blocks to not get
269 * triggered, because the std::vector would be cleared.
270 *
271 * So, instead, I add them into a different std::vector if the block is triggered during this
272 * state of the world (State::Triggering)
273 */
274 m_triggerBlocks = std::move(m_sheduledTriggerBlocks);
275}
276
277
278void World::drawWorld(Renderer::Master& renderer, const Camera& camera)

Callers

nothing calls this directly

Calls 1

triggerMethod · 0.45

Tested by

no test coverage detected