modules/gdextensions/environment/spider_anim/stage.cpp
void SpiderStage::eat(const InsectSprite *p_killed) {
	ERR_FAIL_NULL(root);
	ERR_FAIL_NULL(p_killed);

	auto f = std::find(insects.begin(), insects.end(), *p_killed);
	if (f != insects.end()) {
		insects.detach(f); // remove killed bug from insects list
		root->remove_child(const_cast<InsectSprite *>(p_killed)); // and free
		dirty_insects++;
		insects_eaten++;
	}
}
// all reference should be invalidate after removing any insect
all reference should be invalidate after removing any insect
all reference should be invalidate after removing any insect
void SpiderStage::eat(const InsectSprite *p_killed) {
	ERR_FAIL_NULL(root);
	ERR_FAIL_NULL(p_killed);
	auto f = std::find(insects.begin(), insects.end(), *p_killed);
	if (f != insects.end()) {
		insects.detach(f); 
		root->remove_child(const_cast<InsectSprite *>(p_killed)); 
		dirty_insects++;
		insects_eaten++;
	}
}
void SpiderStage :: eat ( const InsectSprite * p_killed ) { ERR_FAIL_NULL ( root ) ; ERR_FAIL_NULL ( p_killed ) ; auto f = std :: find ( insects . begin ( ) , insects . end ( ) , * p_killed ) ; if ( f != insects . end ( ) ) { insects . detach ( f ) ; root -> remove_child ( const_cast < InsectSprite * > ( p_killed ) ) ; dirty_insects ++ ; insects_eaten ++ ; } }
all reference should be invalidate after removing any insect
all reference should be invalidate after removing any insect
// remove killed bug from insects list // and free