Patch - Adds component shutdown functionality - V13.6.1
Implements a shutdown mechanism for components and entities, ensuring proper resource release and preventing memory leaks. This change introduces a virtual `Shutdown` method to the `Component` class, allowing derived components to release specific resources when they are removed from an entity or when the entity is destroyed. The `Entity` class now calls the `Shutdown` method on all its components during its own release process. The `EntityManager` now calls the `release()` method when destroying an entity. This enhancement ensures that resources, such as FMOD sound objects and channels in the `AudioComponent`, are properly released, preventing potential resource leaks and improving the stability of the engine.
This commit is contained in:
@@ -48,6 +48,7 @@ public:
|
||||
void DestroyEntity(EntityID id) {
|
||||
auto it = m_Entities.find(id);
|
||||
if (it != m_Entities.end()) {
|
||||
it->second->release();
|
||||
m_Entities.erase(it);
|
||||
m_FreeIDs.push(id); // Recycler l'ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user