Replace many uses of is_class with derives_from.

This commit is contained in:
Lukas Tenbrink
2025-09-23 19:35:46 +02:00
parent 3d91a48298
commit 8ef4a43ada
43 changed files with 82 additions and 82 deletions

View File

@ -1936,7 +1936,7 @@ AnimationMixer *AnimationPlayerEditor::fetch_mixer_for_library() const {
return nullptr;
}
// Does AnimationTree have AnimationPlayer?
if (original_node->is_class("AnimationTree")) {
if (original_node->derives_from<AnimationTree>()) {
AnimationTree *src_tree = Object::cast_to<AnimationTree>(original_node);
Node *src_player = src_tree->get_node_or_null(src_tree->get_animation_player());
if (src_player) {
@ -2339,7 +2339,7 @@ void AnimationPlayerEditorPlugin::edit(Object *p_object) {
AnimationMixer *src_node = Object::cast_to<AnimationMixer>(p_object);
bool is_dummy = false;
if (!p_object->is_class("AnimationPlayer")) {
if (!p_object->derives_from<AnimationPlayer>()) {
// If it needs dummy AnimationPlayer, assign original AnimationMixer to LibraryEditor.
_update_dummy_player(src_node);
@ -2409,7 +2409,7 @@ void AnimationPlayerEditorPlugin::_update_dummy_player(AnimationMixer *p_mixer)
}
bool AnimationPlayerEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("AnimationPlayer") || p_object->is_class("AnimationTree") || p_object->is_class("AnimationMixer");
return p_object->derives_from<AnimationPlayer>() || p_object->derives_from<AnimationTree>() || p_object->derives_from<AnimationMixer>();
}
void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
@ -2455,7 +2455,7 @@ AnimationTrackKeyEditEditorPlugin::AnimationTrackKeyEditEditorPlugin() {
}
bool AnimationTrackKeyEditEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("AnimationTrackKeyEdit");
return p_object->derives_from<AnimationTrackKeyEdit>();
}
bool EditorInspectorPluginAnimationMarkerKeyEdit::can_handle(Object *p_object) {
@ -2476,5 +2476,5 @@ AnimationMarkerKeyEditEditorPlugin::AnimationMarkerKeyEditEditorPlugin() {
}
bool AnimationMarkerKeyEditEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("AnimationMarkerKeyEdit");
return p_object->derives_from<AnimationMarkerKeyEdit>();
}

View File

@ -916,7 +916,7 @@ void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(const Vector2 &p_fr
Ref<StyleBox> AnimationNodeStateMachineEditor::_adjust_stylebox_opacity(Ref<StyleBox> p_style, float p_opacity) {
Ref<StyleBox> style = p_style->duplicate();
if (style->is_class("StyleBoxFlat")) {
if (style->derives_from<StyleBoxFlat>()) {
Ref<StyleBoxFlat> flat_style = style;
Color bg_color = flat_style->get_bg_color();
Color border_color = flat_style->get_border_color();

View File

@ -5445,12 +5445,12 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
ERR_FAIL_NULL(node);
NodePath path_to = root->get_path_to(node, true);
if (adding_track_type == Animation::TYPE_BLEND_SHAPE && !node->is_class("MeshInstance3D")) {
if (adding_track_type == Animation::TYPE_BLEND_SHAPE && !node->derives_from<MeshInstance3D>()) {
EditorNode::get_singleton()->show_warning(TTR("Blend Shape tracks only apply to MeshInstance3D nodes."));
return;
}
if ((adding_track_type == Animation::TYPE_POSITION_3D || adding_track_type == Animation::TYPE_ROTATION_3D || adding_track_type == Animation::TYPE_SCALE_3D) && !node->is_class("Node3D")) {
if ((adding_track_type == Animation::TYPE_POSITION_3D || adding_track_type == Animation::TYPE_ROTATION_3D || adding_track_type == Animation::TYPE_SCALE_3D) && !node->derives_from<Node3D>()) {
EditorNode::get_singleton()->show_warning(TTR("Position/Rotation/Scale 3D tracks only apply to 3D-based nodes."));
return;
}
@ -5509,7 +5509,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
} break;
case Animation::TYPE_ANIMATION: {
if (!node->is_class("AnimationPlayer")) {
if (!node->derives_from<AnimationPlayer>()) {
EditorNode::get_singleton()->show_warning(TTR("Animation tracks can only point to AnimationPlayer nodes."));
return;
}

View File

@ -1330,20 +1330,20 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj
return audio;
}
if (p_property == "frame" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D") || p_object->is_class("AnimatedSprite2D") || p_object->is_class("AnimatedSprite3D"))) {
if (p_property == "frame" && (p_object->derives_from<Sprite2D>() || p_object->derives_from<Sprite3D>() || p_object->derives_from<AnimatedSprite2D>() || p_object->derives_from<AnimatedSprite3D>())) {
AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
sprite->set_node(p_object);
return sprite;
}
if (p_property == "frame_coords" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D"))) {
if (p_property == "frame_coords" && (p_object->derives_from<Sprite2D>() || p_object->derives_from<Sprite3D>())) {
AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
sprite->set_as_coords();
sprite->set_node(p_object);
return sprite;
}
if (p_property == "current_animation" && (p_object->is_class("AnimationPlayer"))) {
if (p_property == "current_animation" && (p_object->derives_from<AnimationPlayer>())) {
AnimationTrackEditSubAnim *player = memnew(AnimationTrackEditSubAnim);
player->set_node(p_object);
return player;

View File

@ -282,7 +282,7 @@ void AnimationTreeEditorPlugin::edit(Object *p_object) {
}
bool AnimationTreeEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("AnimationTree");
return p_object->derives_from<AnimationTree>();
}
void AnimationTreeEditorPlugin::make_visible(bool p_visible) {