Open limbonaut opened 7 months ago
One of godot-cpp's design goals is to have the same API as internally in the engine (at least as much as possible), so, to add an is_class_static()
method to godot-cpp, we'd need to first add it to the engine itself.
Couldn't agree more. An alternative to adding this method to the engine perhaps could be exposing/implementing methods like is_class_ptr
?
Yeah, if we can add is_class_ptr()
to godot-cpp, that could work.
We'd need to make sure that that would work even in the case where one GDExtension received an object which is of a class from another GDExtension, but where the first GDExtension didn't generate a class binding for it (because it wasn't aware of the 2nd extension).
Describe the project you are working on
Behavior tree framework: https://github.com/limbonaut/limboai
Describe the problem or limitation you are having in your project
I need to efficiently check if a task instance is of a certain class without comparing strings all the time. I need to do that not only in the framework code. It's a fairly useful thing.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
In the Godot Engine code, there is an instance method called
is_class_ptr
which can be used withClass::get_class_ptr_static()
to make such checks. In thegodot-cpp
, we already haveget_class_static()
added byGDCLASS
macro. Having also an instance methodvirtual bool is_class_static(StringName cn)
would provide an efficient comparison method to the already existing functionality.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
Use
is_class()
instead, which is a String-based comparison.Is there a reason why this should be core and not an add-on in the asset library?
It's as useful as
is_class()
but faster, and utilized already existing functionality ingodot-cpp
.