Closed metaphore closed 11 months ago
What about extracting the sorting logic to a separate open fun onSort()
method? That way you could more easily add logic before and after sorting. I personally don't like that logic has to be "copy & pasted" when overriding something because it could happen that the original source changes and then you need to be aware of that and also adjust your code.
It is safer to do something like:
override fun onTick() {
// either add stuff here ...
super.onSort() // <-- this can also be skipped by users if they never care about sorting in their system
// ... or here ...
family.forEach{ onTickEntity(it) }
// ... or here
}
Yep, a great idea!
Here's a small change that allows for fully custom
IteratingSystem.onTick()
implementations.It happened so I needed to modify the entity processing flow of the
IteratingSystem
by inserting one extra call right after the sorting is done and before the entity iteration. Like this:But it turns out, that I cannot fully replicate the original logic as the sorting-related fields are private.