-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GDScript support for defining virtual/prototype/must-override methods in base classes #1631
Comments
With the new GDScript syntax, this would be better implemented as an We could also replicate the |
Every method in GDScript is virtual so let's use something else. That |
I'm creating a plugin like the Command Palette. |
At the moment you can use |
Nice idea, but it still doesn't look intuitive for the user |
I even think some Godot classes can benefit from having this feature. |
I want to reopen the conversation on implementing support for these kinds of methods. If there were interest in this kind of feature, I'd be interested in implementing it. Some questions posed to me by @aaronfranke were:
Note: There is a PR currently open implementing abstract classes (godotengine/godot#67777). This PR uses an In the context of that PR, I think that abstract methods should only be allowed on abstract classes. I also believe that if class A extends abstract class B, then class A should implement all the abstract methods of class B, or else it should also be declared abstract. If an abstract method is not properly implemented, then a warning should pop up on intellisense.
In the PR Aaron created, abstract classes are only checked in debug builds, and I think that I could be convinced either way on this feature. What do others think? |
Describe the project you are working on:
My project has a GUI containing a large number of inter-operating custom controls and related logic modules. There is a need for the various controls and logic modules to inter-communicate. Many controls need to implement the same methods but with different logic.
Describe the problem or limitation you are having in your project:
Due to parser cyclic reference errors I'm using call-groups as a way for the GUI controls and logic modules to intercommunicate. For example, my game has "power", "engines", "weapons" and several other "systems". All of the systems have a power button. When the power system's power button is pressed all other systems are notified of the event. This is done using call_group("pwr","pwr_mstr_pwr_btn_pressed"). Every system must implement the method to receive group call. However, each system has unique logic associated with the master power button press.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Add support to GDScript for method prototypes. There may be a need to also indicate a class is virtual/prototype so the parser/runtime will raise an error only on concrete classes.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Possible options:
If this enhancement will not be used often, can it be worked around with a few lines of script?:
The only work around I have found is to implement methods in base classes to programmatically check that required methods are implemented by descendant classes. This is a crude and rather ugly solution prone to errors and difficult to maintain.
Is there a reason why this should be core and not an add-on in the asset library?:
Not sure if it can be implemented as an add-on.
The text was updated successfully, but these errors were encountered: