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

Method forAllEntities

source/game/StarEntityMap.cpp:209–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void EntityMap::forAllEntities(EntityCallback const& callback, function<bool(EntityPtr const&, EntityPtr const&)> sortOrder) const {
210 // Even if there is no sort order, we still copy pointers to a temporary
211 // list, so that it is safe to call addEntity from the callback.
212 List<EntityPtr const*> allEntities;
213 allEntities.reserve(m_spatialMap.size());
214 for (auto const& entry : m_spatialMap.entries())
215 allEntities.append(&entry.second.value);
216
217 if (sortOrder) {
218 allEntities.sort([&sortOrder](EntityPtr const* a, EntityPtr const* b) {
219 return sortOrder(*a, *b);
220 });
221 }
222
223 for (auto ptr : allEntities)
224 callback(*ptr);
225}
226
227EntityPtr EntityMap::findEntity(RectF const& boundBox, EntityFilter const& filter) const {
228 EntityPtr res;

Callers 4

updateMethod · 0.45
processMethod · 0.45
makeWorldCallbacksFunction · 0.45
updateMethod · 0.45

Calls 4

reserveMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected