Removes code duplication in instance_(de)?activate_region.

The code is still kind of fat, and in the wrong place, and in need of revision (all operations on deactivated instances are linear in the total count of all instances; the current instance storage mechanism should be an instantiable object; there is no reason not to use a spatial hashing algorithm alongside them). But I'll deal with that later.