Example #1
0
void EntitySystem::check(Entity *par_entity)
{
    if(m_entitys.contains(par_entity->m_id))
    {
        // Delete if needed
        if(BitSet::contains(m_entitysMask, par_entity->m_componentsMask) == false)
            removeFromSystem(par_entity);
    }
    else
    {
        // Insert if needed
        if(BitSet::contains(m_entitysMask, par_entity->m_componentsMask) == true)
            insertToSystem(par_entity);
    }
}
void EntitySystem::check(Entity *e)
{
   if (dummy) {
      return;
   }

   bool contains = e->getSystemBits().test(mType);
   bool interested = true; // possibly interested, let's try to prove it wrong.

   std::bitset<64> &componentBits = e->getComponentBits();

   // Check if the entity possesses ALL of the components defined in the aspect.
   if (!allSet.none()) {
      if ((allSet & componentBits) != allSet) {
         interested = false;
      }
      /*for (size_t i = 0; i < allSet.count(); ++i) {
         if (allSet.test(i) && !componentBits.test(i)) {
            interested = false;
            break;
         }
      }*/
   }

   // Check if the entity possesses ANY of the exclusion components, if it does then the system is not interested.
   if (!exclusionSet.none() && interested) {
      interested = !((exclusionSet & componentBits).any());
   }

   // Check if the entity possesses ANY of the components in the oneSet. If so, the system is interested.
   if (!oneSet.none()) {
      interested = (oneSet & componentBits).any();
   }

   if (interested && !contains) {
      insertToSystem(e);
   } else if (!interested && contains) {
      removeFromSystem(e);
   }
}
void EntitySystem::disabled( Entity *e )
{
   if (e->getSystemBits().test(mType)) {
      removeFromSystem(e);
   }
}
GameObject::~GameObject()
{
	//std::cout << "Game Object DeSTORYed lol\n";
	removeFromSystem();
}
Example #5
0
void EntitySystem::disabled(Entity *par_entity)
{
    if(m_entitys.contains(par_entity->m_id))
        removeFromSystem(par_entity);
}