public bool TryToDeactivate()
{
if (allowDeactivation)
{
//TODO: Check the deactivation count. If it's a fully deactivated simulation island, then try to deactivate !:)
//DO NOT WORRY ABOUT THREAD SAFETY HERE.
//TryToDeactivate will be called sequentially in a 'limited work per frame' scheme.
//Avoids load balancing problems and makes implementation easier.
if (isActive && deactivationCandidateCount == memberCount)
{
isActive = false;
return true;
}
return false;
}
else
{
//Reset the allow deactivation flag so we don't stay inactive forever.
allowDeactivation = true;
return false;
}
}