Changed null check to assert

Changed the null check to clarify that the function should not be called before the entity has been attached to a world.