You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Implement inherits_script() for NativeScript and PluginScript
(cherry picked from commit 2dcd064056)
This commit is contained in:
@@ -112,7 +112,25 @@ void NativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder)
|
||||
#endif
|
||||
|
||||
bool NativeScript::inherits_script(const Ref<Script> &p_script) const {
|
||||
WARN_PRINT_ONCE("Inheritance needs to be implemented in NativeScript.");
|
||||
Ref<NativeScript> ns = p_script;
|
||||
if (ns.is_null()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const NativeScriptDesc *other_s = ns->get_script_desc();
|
||||
if (!other_s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const NativeScriptDesc *s = get_script_desc();
|
||||
|
||||
while (s) {
|
||||
if (s == other_s) {
|
||||
return true;
|
||||
}
|
||||
s = s->base_data;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user