ERR_FAIL_COND_V_MSG(type!=p_variant.get_type(),false,"Attempted to "+String(p_operation)+" a variable of type '"+Variant::get_type_name(p_variant.get_type())+"' into a "+where+" of type '"+Variant::get_type_name(type)+"'.");
if(type!=p_variant.get_type()){
returnfalse;
}
if(type!=Variant::OBJECT){
returntrue;
}
#ifdef DEBUG_ENABLED
ObjectIDobject_id=p_variant;
if(object_id==ObjectID()){
returntrue;//fine its null;
}
Object*object=ObjectDB::get_instance(object_id);
ERR_FAIL_COND_V_MSG(object==nullptr,false,"Attempted to "+String(p_operation)+" an invalid (previously freed?) object instance into a '"+String(where)+".");
#else
Object*object=p_variant;
if(object==nullptr){
returntrue;//fine
}
#endif
if(class_name==StringName()){
returntrue;//all good, no class type requested
}
StringNameobj_class=object->get_class_name();
if(obj_class!=class_name){
ERR_FAIL_COND_V_MSG(!ClassDB::is_parent_class(object->get_class_name(),class_name),false,"Attempted to "+String(p_operation)+" an object of type '"+object->get_class()+"' into a "+where+", which does not inherit from '"+String(class_name)+"'.");
}
if(script.is_null()){
returntrue;//all good
}
Ref<Script>other_script=object->get_script();
//check base script..
ERR_FAIL_COND_V_MSG(other_script.is_null(),false,"Attempted to "+String(p_operation)+" an object into a "+String(where)+", that does not inherit from '"+String(script->get_class_name())+"'.");
ERR_FAIL_COND_V_MSG(!other_script->inherits_script(script),false,"Attempted to "+String(p_operation)+" an object into a "+String(where)+", that does not inherit from '"+String(script->get_class_name())+"'.");