Added error checking for config.json

This commit is contained in:
2021-03-08 20:51:58 -05:00
parent fe13bac080
commit de99b127b1
10 changed files with 161 additions and 52 deletions

View File

@ -37,7 +37,8 @@ template <typename T> inline ComponentID getComponentTypeID() noexcept
}
constexpr std::size_t maxComponents = 32;
constexpr std::size_t maxGroups =32;
constexpr std::size_t maxGroups = 32;
constexpr std::size_t maxEntities = 32;
using ComponentBitSet = std::bitset<maxComponents>;
using GroupBitset = std::bitset<maxGroups>;
@ -90,6 +91,14 @@ public:
{
groupBitset[mGroup] = false;
}
std::string tag;
void setTag(std::string t);
Entity* getEntity()
{
return this;
}
template <typename T> bool hasComponent() const
{
@ -124,6 +133,7 @@ class Manager
private:
std::vector<std::unique_ptr<Entity>> entities;
std::array<std::vector<Entity*>, maxGroups> groupedEntities;
std::vector<std::vector<Entity*>> taggedEntities;
public:
void update()
{
@ -159,6 +169,19 @@ public:
{
groupedEntities[mGroup].emplace_back(mEntity);
}
std::vector<Entity*> getEntitiesByTag(std::string t)
{
std::vector<Entity*> taggedEntities;
for (int e = 0; e<=entities.size(); e++)
{
if (entities[e]->tag == t)
{
taggedEntities.emplace_back(entities[e]->getEntity());
}
}
return taggedEntities;
}
std::vector<Entity*>& getGroup(Group mGroup)
{