Closed vmjcv closed 3 years ago
Ah I saw some new commits and I thought you were done >_< My bad :)
The other merge is done now, just continue on this one and tell me when you're ready.
Hm I wanted to avoid having the utilities as a singleton. Can you try to make the functions static? They should work then without being a singleton
I understand your idea, but godot has very poor support for static functions. It is better to use a singleton to implement the tool class. you can see this https://godotforums.org/discussion/22070/best-practice-is-to-use-a-utility-class-or-node At least now it is a good solution to use a singleton to solve the problem
Another solution is to save game_rng in cfc, and use const Util = preload("util.gd") in every script that needs to use the utils method. like this https://godotengine.org/qa/7374/gdscript-utility-classes
Actually developers much stronger in Godot that myself suggest you avoid singletons: https://twitter.com/NathanGDQuest/status/1330151133197819906
I would like to go that direction because I also like to avoid global variables when possible.
Unfortunately that thread you linked is not clear on what exactly the problems they encountered are. They seem to be moving almost everything out of nodes into utils, which is not what I suggest. I only want to avoid unnecessary singletons (or one single massive singleton)
Way I see it, if it doesn't work with a static function, we can always go back to a singleton, but we should give it a try at least.
Are you done with this pull request then? If so, I'll pull it and see about converting to static functions myself
Wait a minute, I will study it again, if it can be merged, I will tell you here
You merged the code prematurely, should I close that commit at that time? Anyway, I created a new merger