Replies: 2 comments 1 reply
-
If the systems are not expected to run regularly (i..e only when a player clicks a specific button, or steps on a specific trap), by all means, use If you're expecting to run the system every frame, or even once every 10,000 frames, you might want to use a normal system with a run condition instead. |
Beta Was this translation helpful? Give feedback.
-
Even though I do like this pattern, I still have to ask out of curiosity: why not just use events? Or rather, did you discover some case that can't be elegantly handled with events? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In my current project, I have found myself frequently wanting to call functions which benefit from system dependency injection. I recently discovered
Commands.run_system
andCommmands.run_system_with_input
, which allows me to queue up calls without needing to pass around dependencies manually.As an example borrowed from my Cursor implementation:
If I wanted to call
on_player_joined
andon_player_left
directly as functions, I would have to instead pass references to all of their dependencies, which also means including their dependencies in the parent function. This quickly leads to dependency hell, which is avoided by queueing them as system commands. This does, however, come with the downside of being harder/impossible to parallelize.Is this a good practice? Is there a more idiomatic way of doing this?
Beta Was this translation helpful? Give feedback.
All reactions