void MultiPartEntity::addPart(Part& part, float x, float y) { part.setPosition(x, y); part.setParent(this); part.setTeam(getTeam()); m_parts.push_back(part); // The texture rect acts as a bounding box float right = x + part.getWidth(); float bottom = y + part.getHeight(); float width = std::max(right, getWidth()); float height = std::max(bottom, getHeight()); setTextureRect(sf::IntRect(0, 0, width, height)); }