Browse Source

get all ents which implement a trait

opengl-renderer-broken
Martin Dørum 4 years ago
parent
commit
ca776fc1ba
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      libswan/include/swan/WorldPlane.h

+ 9
- 0
libswan/include/swan/WorldPlane.h View File

@@ -40,6 +40,15 @@ public:

Iter<Entity *> getEntsInArea(Vec2 center, float radius);

template<typename T>
Iter<Entity *>getEntsOfType() {
return mapFilter(entities_.begin(), entities_.end(), [](Entity *ent) -> std::optional<T *> {
if (T *e = dynamic_cast<T *>(ent); e != nullptr)
return e;
return std::nullopt;
});
}

BodyTrait::HasBody *spawnPlayer();
void breakBlock(TilePos pos);


Loading…
Cancel
Save