PhysicsComponent2D: Disable simulation when entity is disabled

This commit is contained in:
Jérôme Leclercq 2020-07-03 16:27:30 +02:00
parent 83cf358d02
commit 884a34704d
2 changed files with 16 additions and 0 deletions

View File

@ -99,6 +99,8 @@ namespace Ndk
void OnComponentDetached(BaseComponent& component) override; void OnComponentDetached(BaseComponent& component) override;
void OnDetached() override; void OnDetached() override;
void OnEntityDestruction() override; void OnEntityDestruction() override;
void OnEntityDisabled() override;
void OnEntityEnabled() override;
struct PendingPhysObjectStates struct PendingPhysObjectStates
{ {

View File

@ -117,5 +117,19 @@ namespace Ndk
m_object.reset(); m_object.reset();
} }
void PhysicsComponent2D::OnEntityDisabled()
{
NazaraAssert(m_object, "Invalid physics object");
m_object->EnableSimulation(false);
}
void PhysicsComponent2D::OnEntityEnabled()
{
NazaraAssert(m_object, "Invalid physics object");
m_object->EnableSimulation(true);
}
ComponentIndex PhysicsComponent2D::componentIndex; ComponentIndex PhysicsComponent2D::componentIndex;
} }