add 'blocking' entity property

This commit is contained in:
MihailRis
2024-07-10 04:56:02 +03:00
parent 60f4f33180
commit e0358fe2db
6 changed files with 19 additions and 4 deletions
+10
View File
@@ -404,6 +404,16 @@ void Entities::render(Assets* assets, ModelBatch& batch, const Frustum& frustum,
}
}
bool Entities::hasBlockingInside(AABB aabb) {
auto view = registry.view<EntityId, Transform>();
for (auto [entity, eid, transform] : view.each()) {
if (eid.def.blocking && aabb.contains(transform.pos)) {
return true;
}
}
return false;
}
std::vector<Entity> Entities::getAllInside(AABB aabb) {
std::vector<Entity> collected;
auto view = registry.view<Transform>();
+1
View File
@@ -188,6 +188,7 @@ public:
void loadEntity(const dynamic::Map_sptr& map);
void loadEntity(const dynamic::Map_sptr& map, Entity entity);
void onSave(const Entity& entity);
bool hasBlockingInside(AABB aabb);
std::vector<Entity> getAllInside(AABB aabb);
void despawn(entityid_t id);
dynamic::Value serialize(const Entity& entity);
+1
View File
@@ -24,6 +24,7 @@ struct EntityDef {
std::vector<std::pair<size_t, AABB>> boxSensors {};
std::vector<std::pair<size_t, float>> radialSensors {};
std::string skeletonName = name;
bool blocking = true;
struct {
bool enabled = true;