| 198 | */ |
| 199 | |
| 200 | void Entity::DestroyComponent(ComponentIndex index) |
| 201 | { |
| 202 | if (HasComponent(index)) |
| 203 | { |
| 204 | // We get the component and we alert existing components of the deleted one |
| 205 | BaseComponent& component = *m_components[index].get(); |
| 206 | for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) |
| 207 | { |
| 208 | if (i != index) |
| 209 | m_components[i]->OnComponentDetached(component); |
| 210 | } |
| 211 | |
| 212 | component.SetEntity(nullptr); |
| 213 | |
| 214 | m_components[index].reset(); |
| 215 | m_componentBits.Reset(index); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | } |
no test coverage detected