Replies: 4 comments 3 replies
-
I originally added that because it seemed messy to connect to signals in possibly obscure scripts/nodes. It makes it hard to track when something happens and looks disorganized to me. It also makes it easier if you want to add a step in between. Without priority signals you would signal main.gd to create players right after the map is loaded from maps.gd. If you wanted to add a step in between (for example, role/task assignment) you would need to edit multiple scripts. Another reason is that you could use the priority after a step (like map loading) and just assume everything related to that was done without having to try and find what signal to connect to (and then have to somehow navigate to that script/node). The current priority system is definitely clunky, every single script/script instance is referenced every single time a priority signal is emitted. And as you said it uses arbitrary numbers instead of something more descriptive. Using signals from each individual thing has its problems too, as I described before it’s harder to change the order and add steps. To me the priority signals seem cleaner, and they make it easy to tell at a glance what happens when (assuming proper documentation and/or something like a priority enum). |
Beta Was this translation helpful? Give feedback.
-
It's been grinding my gears while I was drawing up the network connections and stuff like that for starting the game when I was trying to fit in the distribution of character customization to that place. I think having the priority signals would definitely make sense in an organizational stand point. It makes much easier to understand if we have a central script (game manager), that is used to emit certain signals, and every other script that's in relation to it, is started from there based on the signals. However, I think in its current form it doesn't really live up to our expectations, which is, that when godot does something in a weird order (which in this case is that the map is only instanced for some reason after all signals have been emitted, even though the switch scene function has been invoked in the middle - maybe the scene is only effectively switched once we get back to the main loop?), it doesn't really make much difference. What I was thinking about, along @monban 's idea, is what if we actually had signals in each script that are emitted when each state_change_priority function is completed? |
Beta Was this translation helpful? Give feedback.
-
When we talked about this a few hours ago @nicemicro, you were stuck at work and couldn't properly respond. Now I'm at work, and don't have time to type out a proper response. The troubles of a team in many timezones 😁 I'll summarize for now. Based on what @TheSecondReal0 and @nicemicro said, I think we're using signals incorrectly at the moment. Signals (which are basically an implementation of the observer pattern) are great when things need to happen in response to other things, but you want to retain loose coupling between them. Order shouldn't matter. I think our best way ahead would be to not use signals for events that need to happen in a particular pattern. Instead, when the game moves into the I'll elaborate more after work, in case this isn't clear. |
Beta Was this translation helpful? Give feedback.
-
If we end up keeping the signals, we can improve it by moving away from sending arbitrary numbers in It also means you're not calling a function in literally every node that uses a priority thing (which is what happens currently). It comes with all the benefits of a priority enum without the inherent jankiness of the current It doesn't really go with the idea that signals notify about stuff that just happened, but why should we constrain ourselves to a single use of such a powerful tool? |
Beta Was this translation helpful? Give feedback.
-
Back in #255, @TheSecondReal0 introduced a priority system for game state signals. I think this was done to prevent a race condition of some sort. I appreciate the need for it, but I was never quite satisfied because the priorities were always a bit nebulous to me, magic numbers like
priority 3
don't mean much, and make the code harder to reason about.We discussed replacing the priorities with an enum, so for example instead of
priority 3
we would havepriority Network
or something like that. I think the real source of the problem is thatGameManager
is too important, too much is controlled from there. If the map load needs to happen after a network event, I would rather the map controller listen for an event from the network manager, rather than everybody depend on game controller.I've created a branch that doesn't use the priorities, with the plan to then go back and create new signals to create the correct dependency chain. Much to my surprise, after removing the priority (leaving everything hanging off the same
GameManager
signals, which I'm still not super happy with) the game still functions! Is there some kind of race condition that only happens sometimes, or am I missing something? Can we safely remove this functionality?Beta Was this translation helpful? Give feedback.
All reactions