Exemplo n.º 1
0
std::ostream& operator<<(std::ostream &out, Entity &e)
{
  const size_t type = e.type->getId();

  out << "{";

  if (type == EntityType::CUSTOM) {
    out << "type:custom, "; 
  } else {
    out << "type:" << type << ", ";
  }
  
  out << "expired:" << (e.expired ? "true" : "false") << ", ";
  out << "visible:" << (e.visible ? "true" : "false") << ", ";
  out << "enabled:" << (e.enabled ? "true" : "false") << ", ";

  IdMap components = e.type->getComponents();

  for (size_t i = 0; i < components.size(); i++) {
    size_t componentId = components.getId(i);
    size_t offset = components.getIndex(componentId);

    ComponentBase *componentBase = e.type->getCore()->getComponent(componentId);
    AnyMemory value = e.components.sub(offset, componentBase->defaultValue.getSize());

    out << componentBase->name << ":" << value << ", ";
  }

  out << "controllers:{";

  IdMap controllers = e.type->getControllers();

  for (size_t i = 0; i < controllers.size(); i++) {
    if (i > 0) {
      out << ",";
    }
    out << controllers.getId(i);
  }

  out << "}}";

  return out;
}
Exemplo n.º 2
0
void addEntityListToMapBasedOnBitSet( EntityList *listener, const IdMap &indices, map<size_t,vector<EntityList*>> &vmap )
{
	for (size_t i = 0; i < indices.size(); i++) {

		size_t id = indices.getId(i);
		auto iterator = vmap.find( id );

		if (iterator == vmap.end()) {
			vmap.insert({id, {listener}});
		} else {
			iterator.second.push_back(listener);
		}
	}
}
Exemplo n.º 3
0
void notifyListsInMap( Entity *e, const IdMap& indices, map<size_t,vector<EntityList*>> &vmap )
{
	for (size_t i = 0; i < indices.size(); i++) {

		size_t id = indices.getId(i);
		auto iterator = vmap.find( id );

		if (iterator != vmap.end()) {
			for (auto &listener : iterator.second) {
				listener.add( e );
			}
		}
	}
}