void ComponentManager<T>::reuseComponent(id entity) { assert(deletedComponentsIndex.size() > 0 && "ComponentManager: no reusable components"); entitiesComponentsIndex[entity] = deletedComponentsIndex.back(); deletedComponentsIndex.pop_back(); resetComponent(entity); }
void ComponentManager<T>::addComponent(id entity) { if (hasComponent(entity)) { resetComponent(entity); } else { reserveComponentIndex(entity); deletedComponentsIndex.size() == 0 ? createComponent(entity) : reuseComponent(entity); fireEntityAddedSignal(entity); } }
ComponentNode::~ComponentNode() { COCA_DEBUG_INFO( "~ComponentNode " << getName() << ":" << getComponentId() ); resetComponent(); COCA_DEBUG_INFO( "~ComponentNode end " << getName() << ":" << getComponentId() ); }
ComponentNode::ComponentNode( const std::string& componentId, const std::string& name, INode* parent ) : ANode( name, parent ), _component( 0 ) { resetComponent( componentId ); }